var http = require('http');var resp = function doResp()
{
console.log(“Second task executed..”);
}
http.createServer(function (req, res) {
console.log(“Task One exeuted..”); // This is task 1
setTimeout(resp,2000); //This is actually how callback is utilized
/* Below statements are task3*//
res.writeHead(200, {‘Content-Type’: ‘text/plain’});
res.end(“Page content is loaded but request is yet processing task 2 in back ground…”);
console.log(“Task three executed..”);
}).listen(9999);
“Task three executed..”
anirbanb2004@Anisoft-Corporation:~/www/loadTest/siegeLog$ siege -c500 -d1 -t5M -lnode1.log http://localhost:9615
** SIEGE 3.0.5
** Preparing 500 concurrent users for battle.
The server is now under siege…
Lifting the server siege… done.
Transactions: 296509 hits
Availability: 100.00 %
Elapsed time: 299.75 secs
Data transferred: 830.79 MB
Response time: 0.00 secs
Transaction rate: 989.19 trans/sec
Throughput: 2.77 MB/sec
Concurrency: 4.20
Successful transactions: 296509
Failed transactions: 0
Longest transaction: 0.20
Shortest transaction: 0.00
FILE: node1.log
anirbanb2004@Anisoft-Corporation:~/www/loadTest/siegeLog$ siege -c500 -d1 -t5M -lnphp1.log http://localhost/loadTest/PHP/
** SIEGE 3.0.5
** Preparing 500 concurrent users for battle.
The server is now under siege…
Lifting the server siege… done.
Transactions: 298656 hits
Availability: 100.00 %
Elapsed time: 299.92 secs
Data transferred: 836.80 MB
Response time: 0.00 secs
Transaction rate: 995.79 trans/sec
Throughput: 2.79 MB/sec
Concurrency: 2.27
Successful transactions: 298656
Failed transactions: 0
Longest transaction: 0.24
Shortest transaction: 0.00
FILE: nphp1.log
Summary : Not much difference. Concurrency is little higher and Longest transaction is also slightly better but nothing real impressive.
500 Concurrent users for 10 minutes with 1 second delay
anirbanb2004@Anisoft-Corporation:~/www/loadTest/siegeLog$ siege -c500 -d1 -t10M -lnode1.log http://localhost:9615
** SIEGE 3.0.5
** Preparing 500 concurrent users for battle.
The server is now under siege…
Lifting the server siege… done.
Transactions: 594697 hits
Availability: 100.00 %
Elapsed time: 599.95 secs
Data transferred: 1666.28 MB
Response time: 0.00 secs
Transaction rate: 991.24 trans/sec
Throughput: 2.78 MB/sec
Concurrency: 3.84
Successful transactions: 594697
Failed transactions: 0
Longest transaction: 0.20
Shortest transaction: 0.00
FILE: node1.log
anirbanb2004@Anisoft-Corporation:~/www/loadTest/siegeLog$ siege -c500 -d1 -t10M -lnphp1.log http://localhost/loadTest/PHP/
** SIEGE 3.0.5
** Preparing 500 concurrent users for battle.
The server is now under siege…
Lifting the server siege… done.
Transactions: 597276 hits
Availability: 100.00 %
Elapsed time: 599.97 secs
Data transferred: 1673.50 MB
Response time: 0.00 secs
Transaction rate: 995.51 trans/sec
Throughput: 2.79 MB/sec
Concurrency: 1.94
Successful transactions: 597276
Failed transactions: 0
Longest transaction: 0.20
Shortest transaction: 0.00
FILE: nphp1.log
500 Concurrent Users for 15 minutes with 1 second delay
anirbanb2004@Anisoft-Corporation:~/www/loadTest/siegeLog$ siege -c500 -d1 -t15M -lnode1.log http://localhost:9615
** SIEGE 3.0.5
** Preparing 500 concurrent users for battle.
The server is now under siege…
Lifting the server siege… done.
Transactions: 892874 hits
Availability: 100.00 %
Elapsed time: 899.25 secs
Data transferred: 2501.74 MB
Response time: 0.00 secs
Transaction rate: 992.91 trans/sec
Throughput: 2.78 MB/sec
Concurrency: 3.74
Successful transactions: 892874
Failed transactions: 0
Longest transaction: 0.25
Shortest transaction: 0.00
FILE: node1.log
anirbanb2004@Anisoft-Corporation:~/www/loadTest/siegeLog$ siege -c500 -d1 -t15M -lnphp1.log http://localhost/loadTest/PHP/
** SIEGE 3.0.5
** Preparing 500 concurrent users for battle.
The server is now under siege…
[error] socket: 1011885824 address is unavailable.: Cannot assign requested address
[error] socket: -213448960 address is unavailable.: Cannot assign requested address
[error] socket: -3631360 address is unavailable.: Cannot assign requested address
Lifting the server siege… done.
Transactions: 893948 hits
Availability: 99.96 %
Elapsed time: 899.70 secs
Data transferred: 2504.75 MB
Response time: 0.00 secs
Transaction rate: 993.61 trans/sec
Throughput: 2.78 MB/sec
Concurrency: 2.25
Successful transactions: 893948
Failed transactions: 335
Longest transaction: 1.01
Shortest transaction: 0.00
FILE: nphp1.log
1K Concurrent users for 10 minutes with 1 Second delay
anirbanb2004@Anisoft-Corporation:~/www/loadTest/siegeLog$ siege -c1000 -d1 -t10M -lnode1.log http://localhost:9615
** SIEGE 3.0.5
** Preparing 1000 concurrent users for battle.
The server is now under siege…
Lifting the server siege… done.
Transactions: 862079 hits
Availability: 100.00 %
Elapsed time: 599.92 secs
Data transferred: 2415.46 MB
Response time: 0.20 secs
Transaction rate: 1436.99 trans/sec
Throughput: 4.03 MB/sec
Concurrency: 281.62
Successful transactions: 862079
Failed transactions: 0
Longest transaction: 0.55
Shortest transaction: 0.00
FILE: node1.log
anirbanb2004@Anisoft-Corporation:~/www/loadTest/siegeLog$ siege -c1000 -d1 -t10M -lnphp1.log http://localhost/loadTest/PHP/
** SIEGE 3.0.5
** Preparing 1000 concurrent users for battle.
The server is now under siege…
Lifting the server siege… done.
Transactions: 1193412 hits
Availability: 100.00 %
Elapsed time: 599.82 secs
Data transferred: 3343.82 MB
Response time: 0.00 secs
Transaction rate: 1989.62 trans/sec
Throughput: 5.57 MB/sec
Concurrency: 5.58
Successful transactions: 1193412
Failed transactions: 0
Longest transaction: 0.54
Shortest transaction: 0.00
FILE: nphp1.log
Summary: This shows the real advantage of node in terms of concurrency. See here with increase in number of concurrent users how the concurrency level increased for Node(281.62) where as for PHP+Apache it is 5.58 still.
- Getting Node experienced people or training your developer to Pro level is costlier
- PHP+Apache stack will consume more swap memory (RAM) when concurrency is more, but Node will be expensive on Processor (CPU) when performing CPU intensive jobs. Scaling up a server is cheaper when only dealing with memory or RAM (obviously within thresold) but if we need processor upgrade (on physical servers) that will be real tough and expensive job.
- If you are not owning dedicated server hosting Node on cloud is costlier than any other options
