list
list copied to clipboard
scaling NodeJS
e.g. start with bad program does things like fs.*Sync calls then provide simulated traffic and test using benchmark… hint at various performance techniques e.g. always async, in-memory caching, leveldb, horizontal scaling with cluster and modularising app across multiple processes.
suggested in nodeschool/discussions#181
Does anyone have a suggested outline for the lesson?
Hey,
what about creating a single http
server in every problem which our solution would test in terms of performance (number of concurrent requests) and if the number is higher than the required by the problem, the solution would pass?
It would be also nice to expose some other benchmark results like averageResponseTime
or numberOfTimedoutRequests
just to show the students how different techniques can affect relatively simple CRUD server performance.
Introduction - Horizontal/Vertical scaling - what it is, cluster
module - short overview
First problem - Preparations, clustering a single http server we gonna use in next problems
Second problem - A get
endpoint with a sync filesystem call
Third problem - All sync methods converted to async ones
Fourth problem - Eliminating filesystem call by keeping first lookup results in-memory
Fifth problem - Keeping in-memory cache persistent during restarts (e.g. leveldb)
To make the results and differences more visible
, we can consider passing a special blocking readFile
method that contains either a timeout
or a sleep
inside, just to make it a bit slower.
Some potentially useful modules:
- https://github.com/ErikDubbelboer/node-sleep (for sync call)