Skip to content

Instantly share code, notes, and snippets.

@padcom
Created January 23, 2022 14:56
Show Gist options
  • Save padcom/cfde106f1a31a93703f73d9529f92d7d to your computer and use it in GitHub Desktop.
Save padcom/cfde106f1a31a93703f73d9529f92d7d to your computer and use it in GitHub Desktop.
Comparing node.js cluster with docker swarm on Linux (Linux 5.13.0-23-generic #23~20.04.2-Ubuntu SMP x86_64, Intel i7-11700k)

First test is done using Docker Swarm configured so that the demo_web service runs in 16 copies. This is supposed to output the maximum performance because each single-process and single-threaded (as node.js is) would be able to fully utilize the assigned CPU

$ siege http://localhost:5001
** SIEGE 4.0.4
** Preparing 25 concurrent users for battle.
The server is now under siege...^C
Lifting the server siege...
Transactions:		      182728 hits
Availability:		      100.00 %
Elapsed time:		        7.23 secs
Data transferred:	        4.33 MB
Response time:		        0.00 secs
Transaction rate:	    25273.58 trans/sec
Throughput:		        0.60 MB/sec
Concurrency:		       23.95
Successful transactions:      182728
Failed transactions:	           0
Longest transaction:	        0.03
Shortest transaction:	        0.00

This next step is also done on Docker Swarm but with just one instance of the service:

$ siege http://localhost:5001
** SIEGE 4.0.4
** Preparing 25 concurrent users for battle.
The server is now under siege...^C
Lifting the server siege...
Transactions:		       82888 hits
Availability:		      100.00 %
Elapsed time:		        9.01 secs
Data transferred:	        1.98 MB
Response time:		        0.00 secs
Transaction rate:	     9199.56 trans/sec
Throughput:		        0.22 MB/sec
Concurrency:		       24.80
Successful transactions:       82888
Failed transactions:	           0
Longest transaction:	        0.01
Shortest transaction:	        0.00

This next test runs directly on node.js without Docker and is the exact same application:

$ siege http://localhost:5001
** SIEGE 4.0.4
** Preparing 25 concurrent users for battle.
The server is now under siege...^C
Lifting the server siege...
Transactions:		       72250 hits
Availability:		      100.00 %
Elapsed time:		        6.10 secs
Data transferred:	        1.72 MB
Response time:		        0.00 secs
Transaction rate:	    11844.26 trans/sec
Throughput:		        0.28 MB/sec
Concurrency:		       24.85
Successful transactions:       72250
Failed transactions:	           0
Longest transaction:	        0.02
Shortest transaction:	        0.00

This last tests uses a modification of the original application but with clustering:

$ siege http://localhost:5001
** SIEGE 4.0.4
** Preparing 25 concurrent users for battle.
The server is now under siege...^C
Lifting the server siege...
Transactions:		      163496 hits
Availability:		      100.00 %
Elapsed time:		        8.63 secs
Data transferred:	        3.88 MB
Response time:		        0.00 secs
Transaction rate:	    18945.07 trans/sec
Throughput:		        0.45 MB/sec
Concurrency:		       24.46
Successful transactions:      163496
Failed transactions:	           0
Longest transaction:	        0.03
Shortest transaction:	        0.00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment