|
|
|
This project implements a basic <i>server & client</i> application in <i>Node.js</i><br></br>
|
|
|
|
##
|
|
|
|
**server.js:** The <i>server</i> is listening on 'http://localhost:3000' and is connected to a <i>redis</i> database. It receives an user-name from the client, check in the <i>redis</i> database, if exists, response with <i>'Hello user-name(in upper case)'</i> else with 'Oops...'.<br></br>
|
|
|
|
##
|
|
|
|
**client.js:** Creates a <i>socket.io-client</i>, which connects to the server and sends an <i>user-name</i> to check if it exists in the <i>redis</i> database.<br></br>
|
|
|
|
##
|
|
|
|
**createDatabase.js:** If a <i>key</i> named 'user' exists in the <i>'redis-server'</i>, it deletes it and creates a new <i>set</i> named <i>'user'</i> with 8000 user-name.<br></br>
|
|
|
|
##
|
|
|
|
**loadTester.js:** Code for load testing manually. It creates a new client at a given rate and prints number of connected clients every seconds. <br></br>
|
|
|
|
##
|
|
|
|
**my-script.yaml:** Script for load testing with <i>['artillery'](https://www.artillery.io/)</i>. It starts with creating (arrivalRate = ) 200 clients per second to (rampTo = ) 10000 clients per second. <i>'functions.js'</i> is used to create a random user-name for each clients that it creates. It also generates reports as <i>'report.json'</i> and <i>'report.html'</i> format. <br></br>
|
|
|
|
##
|
|
|
|
**How to use**<br></br>
|
|
|
|
* Start a redis server at default port. (Head over [here](https://redis.io/topics/quickstart) if you are new in redis)
|
|
|
|
* Run ```npm i socket.io redis socket.io-client bluebird async-redis```
|
|
|
|
* Run ```npm run database``` to prepare the database.
|
|
|
|
* Run ```npm run server``` to start the server.
|
|
|
|
* Run ```npm run loadtester``` to load test manually.
|
|
|
|
* Run ```npm run client``` to connect a single client.
|
|
|
|
* Run ```npm install -g artillery``` to install Artillery. (Only works for node.js version >= 12)
|
|
|
|
* Run ```artillery dino``` to test if artillery is working.
|
|
|
|
* Run ```artillery run --output report.json my-script.yaml``` to load test and generate report on <i>report.json</i>.
|
|
|
|
* Run ```artillery report --output report.html report.json``` to generate graphical report. |
|
|
|
\ No newline at end of file |