|
|
|
Ask HN: Event loop vs. Threads
|
|
27 points
by villagefool
5132 days ago
|
|
Hello,
At my work place we have a lot of legacy C++ code that uses threads to parallelize things. We are considering to switch to Node.js and searching for sources comparing the Event loop model vs. a threads based one from perspectives such as the following: efficiency, ease of maintenance, etc. Would be thankful for any references to good constructive material. EDIT: more details about the application - it is a trading app that communicates with multiple sources at high rates to gather information and send commands, but it also does quite alot of number crunching. |
|
They have incoming work, I/O for incoming and outgoing work is done multi threaded while work on events is single threaded.
The architecture is quite clever as more than one event processor can work on the data structure and event processors can have dependencies on each other. Independent processors can race past each other.
It was written for trading and might be portable to C++, but if you consider switching to JS it might also be ok for you to switch to Java. Their framework is called Disruptor and open source
http://code.google.com/p/disruptor/
"LMAX aims to be the fastest trading platform in the world. Clearly, in order to achieve this we needed to do something special to achieve very low-latency and high-throughput with our Java platform. Performance testing showed that using queues to pass data between stages of the system was introducing latency, so we focused on optimising this area."