Comet with Bayeux: node.js vs Jetty and cometd
I’ve been looking at the relative performance of cometD-jetty and node.js for a Bayeux based publish/subscribe server.
I had high hopes for node.js. Apps being written in Javascript should mean pretty big maintainability wins for a normal web development house, versus the rather huge Java codebase that is Jetty.
Unfortunately node.js got thoroughly trounced by Jetty in the not-terribly-scientific benchmarks I conducted.
I used the Jetty load test tool described here to do the load testing. The faye node.js Bayeux library was used as the node.js app.
Both benchmarks were run on the same machine, a 4 core i7 920 @ 2.67GHz (hyperthreading turned on) with 6Gb of RAM.
The final results were as follows:
jetty 6.1.22 (512mb)
100 rooms, 5 rooms per client, 900 clients
---
Messages - Success/Expected = 442758/449601
Messages - Elapsed/Rate = 12192 ms / 36313 messages/s
Messages - Latency Distribution Curve (X axis: Frequency, Y axis: Latency):
@ _ 155 ms (117638)
@ _ 309 ms (256939)
@ _ 462 ms (42652)
@ _ 615 ms (7851)
@ _ 769 ms (3172)
@ _ 922 ms (2961)
@ _ 1076 ms (2885)
@ _ 1229 ms (2028)
@ _ 1382 ms (1381)
@ _ 1536 ms (1576)
@ _ 1689 ms (986)
@ _ 1843 ms (564)
@ _ 1996 ms (410)
@ _ 2149 ms (679)
@ _ 2303 ms (409)
@ _ 2456 ms (220)
@ _ 2610 ms (179)
@ _ 2763 ms (133)
@ _ 2916 ms (42)
@ _ 3070 ms (53)
Messages - Latency Min/Ave/Max = 2/250/3070 ms
node.js
100 rooms, 5 rooms per client, 900 clients
---
Messages - Success/Expected = 440234/449428
Messages - Elapsed/Rate = 12254 ms / 35924 messages/s
Messages - Latency Distribution Curve (X axis: Frequency, Y axis: Latency):
@ _ 123 ms (1901)
@ _ 239 ms (9046)
@ _ 356 ms (22316)
@ _ 472 ms (33240)
@ _ 589 ms (36656)
@ _ 705 ms (37025)
@ _ 822 ms (37323)
@ _ 938 ms (37489)
@ _ 1055 ms (37680)
@ _ 1171 ms (37415)
@ _ 1288 ms (37516)
@ _ 1404 ms (34069)
@ _ 1521 ms (29466)
@ _ 1637 ms (24187)
@ _ 1753 ms (15184)
@ _ 1870 ms (7240)
@ _ 1986 ms (1828)
@ _ 2103 ms (460)
@ _ 2219 ms (127)
@ _ 2336 ms (66)
Messages - Latency Min/Ave/Max = 7/961/2336 ms
As we can see, node.js just didn’t have the same low latency as Jetty, which is a pretty major problem for pub/sub.