Simulate 100s of clients in Meteor

Meteor is a subscribe publish based application development framework which allows for rapid application development using the same code base. I had the chance of working on one of the most demanding meteor applications ever written. The client is a high profile company working with automation. So basically one of the problems they faced was to simulate tens of thousands of devices in a virtual environment. One of the most logical ways to go would be to dockerize the client and then use docker swarm mode to auto scale the clients. But the code base right now is a monolith and hence dividing the different functionality into micro-services is doable but will take a long time. The client wanted this done like the day before I got my hands dirty.

So even though the long term plan is to use docker swarm, I had to do something amazingly fast and simple that works with the current structure (without too much modifications to existing code base). So the next best thing that could be done was to use bash :). Below is a script I wrote that can be re-used across multiple workstations and run multiple clients to simulate load scenarios for the server. The server of course is on a separate machine than the ones running the clients. Each simulated client will have its own log window. The best part is that memory usage on the workstations does not explode exponentially. So one can only open a single browser window and interact with the client directly.

Of course the script does not have very many checks so extend on it as needed. This works with any meteor applications directly. The bash script is as below.

Now all you need is a special csv file that needs to be given as input to the script for it to launch multiple clients. The csv in this particular case is as below.

# Lines starting with a # are ignored & treated as comments
# Please do not insert any empty lines
# Format for this file is as below
#
# port,macAddress,room_id,room_name,eh_ipaddr_port,workingDir,mongoDB

3000,32:9D:8B:A2:BF:23,undefined,room1,62.20.14.169:3002,/tmp/lisoSim,mongodb://127.0.0.1:3001/meteor
10000,32:9D:8C:A2:BF:23,undefined,room2,62.20.14.169:3002,/tmp/lisoSim,mongodb://127.0.0.1:3001/meteor1
10001,32:9D:8C:A2:BE:23,undefined,room3,62.20.14.169:3002,/tmp/lisoSim,mongodb://127.0.0.1:3001/meteor2
10002,32:9D:8C:A4:BE:23,undefined,room4,62.20.14.169:3002,/tmp/lisoSim,mongodb://127.0.0.1:3001/meteor3
10003,32:9F:8C:A4:BE:23,undefined,room4,62.20.14.169:3002,/tmp/lisoSim,mongodb://127.0.0.1:3001/meteor4

This is pretty much it. One thing to remember is that the script uses the same mongodb for multiple client instances with different database. Put your comments and tell me improvements needed. ENJOY!