Sign inSign up

yanglei99/acmeair-nodejs

By yanglei99

•Updated almost 9 years ago

Auto build acmeair-nodejs

Image
2

1.3K

yanglei99/acmeair-nodejs repository overview

⁠Acme Air in NodeJS

An implementation of the Acme Air benchmark application for NodeJS. This implementation can support multiple datastores; run in several application modes; offer oeration insights and API management capabilities. It also supports running on a variety of runtime platforms including stand-alone bare-metal system, Virtual Machines, docker containers, IBM Bluemix, IBM Bluemix Container Service, Mesos through Marathon...

⁠Content

⁠Runtime Environment

NodeJs⁠

⁠Datastore Choices

Environment variable dbtype is used to determine the datastore choice. MongoDB is default. See under "More on configurations".

⁠Application Mode

Environment variable AUTH_SERVICE is use to determine when Micro-Service is used. Default is Monolitic. See under "More on configurations".

⁠Monolithic

One NodeJS application. The default mode.

⁠Micro-Service

Main NodeJS application delegates to authorization service NodeJS application hosted on host:port, defined in AUTH_SERVICE.

⁠Application Run Platforms
⁠Insights and API Management
  • Enable zipkin tracing with ENABLE_ZIPKIN
  • Enable Swagger API exploring with ENABLE_SWAGGER

⁠How to get started

Assume MongoDB started on 127.0.0.1:27017

⁠Resolve module dependencies
npm install
⁠Run Acmeair in Monolithic on Local
node app.js
	
	
⁠Run Acmeair in Micro-Service on Local
node authservice_app.js
set AUTH_SERVICE=localhost:9443 or export AUTH_SERVICE=localhost:9443
node app.js
⁠Run Acmeair in Micro-Service with Netflix Hystrix Stream enabled on Local
node authservice_app.js
set AUTH_SERVICE=localhost:9443 or export AUTH_SERVICE=localhost:9443
set enableHystrix=true or export enableHystrix=true

node app.js
⁠Enable ZipKin tracing for all the scenarios
export ENABLE_ZIPKIN=true
export ZIPKIN_HOST= your Zipkin collector host
⁠Known issue
⁠Enable Swagger API definition for all the scenarios
export ENABLE_SWAGGER=true
⁠Known issue
  • The Swagger API needs improvements. Especially on how to model sessionid in cookies.
⁠Access Application
http://localhost:9080/

Load the database (under Configure the Acme Air environment)
	preload 10k customers uid[0..9999]@email.com:password, 5 days' flights.  Defined in loader/loader-settings.json
Login
Flights
	such as Singapore to HongKong or Paris to Moscow 
Checkin
	cancel some booked flights
Account
	update account info
Logout	

If hystrix is enabled, it is available at : http://localhost:9080/rest/api/hystrix.stream


⁠More on Configurations

⁠Environment Variables
NameDefaultMeaning
dbtypemongoYou can switch between mongo,cloudant,cassandra for datastore choices. When running on Bluemix, dbtype is automactially discovered from the service the application is bound to.
AUTH_SERVICEBy default, there is only one main NodeJS application for all logics. When defined, in the format of host:port, it enables Micro-Service mode, main NodeJS application delegates to authorization service NodeJS application hosted on host:port.
enableHystrixfalsewhen set to true, it will enable hystrix stream available at /rest/api/hystrix.stream
MONGO_URLMongo database URL. Take precedence over other settings
CLOUDANT_URLCloudant database URL. Take precedence over other settings
CASSANDRA_CPCassandra Contact Points. Take precedence over other settings
CASSANDRA_KSCassandra keyspace. Take precedence over other settings
ENABLE_ZIPKINwhen set to true, it will enable ZipKin integration
ZIPKIN_HOSTzipkin collector scribe host. Take precedence over other settings
ZIPKIN_PORTzipkin collector scribe port. Take precedence over other settings
ENABLE_SWAGGERwhen set to true, it will enable Swagger API exploring. The swagger-ui is at host:port/v1
⁠Configuration for Runtime

Default values are defined here⁠

NameDefaultMeaning
mongoHost127.0.0.1MongoDB host ip
mongoPort27017MongoDB port
mongoConnectionPoolSize10MongoDB connection pool size
cloudant_hostCloudant database host name
cloudant_port443Cloudant database port
cloudant_usernameCloudant database username/API key
cloudant_passwordCloudant database password
cloudant_httpclient.maxTotal200Cloudant http client max connections
cloudant_httpclient.maxPerRoute100Cloudant http client connections per route
cloudant_httpclient.soTimeout5000Cloudant http client socket timeout
cloudant_httpclient.connectionTimeout5000Cloudant http client connection timeout
cassandra_contactPointsCassandra contact points
cassandra_keyspaceacmeair_keyspaceCassandra keyspace
zipkin_host127.0.0.1zipkin collector scribe host
zipkin_port9410zipkin collector scribe port
  • When running on Bluemix, datasource url will be read from bound service information.
  • For Cloudant, you need to follow instruction⁠ to create database and define search index.
  • For Cassandra, you need to follow instruction⁠ to create keyspace and tables.
⁠Configuration for Preload

Default values are defined here⁠

NameDefaultMeaning
MAX_CUSTOMERS10000number of customers
MAX_DAYS_TO_SCHEDULE_FLIGHTS5max number of days to schedule flights
MAX_FLIGHTS_PER_DAY1max flights per day

⁠Other Topics

⁠How to extend with more datasource types
  • Create a folder under dataaccess with the new dbtype name. Look at current implementation for reference.
⁠Data consistency with Acmeair Java

The data format is NOT the same as Acmeair Java. The impact:

  • You can not share database with Acmeair Java.
  • When drive acmeair workload, you need follow the instruction⁠ to use -DusePureIDs=true when starting jmeter.

Tag summary

Content type

Image

Digest

Size

191.1 MB

Last updated

almost 9 years ago

docker pull yanglei99/acmeair-nodejs