Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • S ServerClientTestInNodeJSRedis
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Tashrif Ahmad
  • ServerClientTestInNodeJSRedis
  • Wiki
  • Home

Last edited by Tashrif Ahmad Nov 23, 2021
Page history

Home

This project implements a basic server & client application in Node.js

server.js: The server is listening on 'http://localhost:3000' and is connected to a redis database. It receives an user-name from the client, check in the redis database, if exists, response with 'Hello user-name(in upper case)' else with 'Oops...'.

client.js: Creates a socket.io-client, which connects to the server and sends an user-name to check if it exists in the redis database.

createDatabase.js: If a key named 'user' exists in the 'redis-server', it deletes it and creates a new set named 'user' with 8000 user-name.

loadTester.js: Code for load testing manually. It creates a new client at a given rate and prints number of connected clients every seconds.

my-script.yaml: Script for load testing with 'artillery'. It starts with creating (arrivalRate = ) 200 clients per second to (rampTo = ) 10000 clients per second. 'functions.js' is used to create a random user-name for each clients that it creates. It also generates reports as 'report.json' and 'report.html' format.

How to use

  • Start a redis server at default port. (Head over here 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 report.json.
  • Run artillery report --output report.html report.json to generate graphical report.
Clone repository
  • Home