Elegant simulation of concurrency. Do you remember Swing event dispatch thread and
invokeLater() method? Event loop is the same.
It is crucial to understand events handling order:
- emitted event
- IO callbacks
- deferred execution blocks
Event driven concurrency
Process is a first class citizen. The easiest (and cheapest) way to achieve concurrency with horizontal scalability.
I enhanced drawing board presented in the book. It was great fun together with my 2 years old son :–) Scalable server side implementation is presented below, I could not even imagine Java version.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Keep in mind that SSE is unidirectional from server to clients and requires funny 2KB padding. I didn’t know that before.
Scaling on single node
Spawning, forking child processes is easy, communication between parent and children processes is easy as well. Cluster module simplifies web application implementation for multi-core processors and it is very easy to understand and control.
Keep shared state in horizontally scalable store, e.g: session data in Redis or RabbitMq for events.
Command line tool for load/stress testing. Using JMeter or Gatling is not always the only way to perform simple test.
UDP / Multicast
Good to know the world behind HTTP/REST/SOAP … There is a lot of important layers between application and wire, do you remember OSI?
I have to practice using S3 or DynamoDB eventually.
OMG – I used to debug application using console 10 years ago or so ;–)
Express, Socket.io, Path
Implementing web application using Node.js only is feasible but with Express it is much easier.
Be aware that there are thousands of web frameworks for Node.js on the market. Much more that for Java 10 years ago ;–) It seems that frameworks built around WebSocket and Single Page App should be the leaders.