javascript - How cpu intensive is too much for node.js (worried about blocking event loop) -
i writing node app various communities , within communities users able create , join rooms/lobbies. have written logic these lobbies node app though collection of lobby objects.
lobbies require maintenance once created. users can change various statuses within lobby , have calls using socket.io @ regular intervals(about every 2 seconds) each lobby keep track of user input "live".
none of tasks cpu intensive. biggest potential threat foresee load distributing algorithm not 1 of "live calls" , activated upon button press lobby creator (it never performed on more 10 things).
my concern arises in that, in production, if server starts close around 100-200 lobbies risking blocking event loop. concerns reasonable? potential quantity of these operations, although small, large enough warent offloading code separate executable or getting involved various franken-thread javascript libs?
tl;dr: node app has object regular small tasks run. should worry event-loop blocking if many of these objects made.
there no way know ahead of time whether describe "fill" event loop , take time 1 thread has or not. if want "know", have build simulation , measure while using commensurate hardware expect use in production.
with pretty performance questions, have measure, measure , measure again know or understand whether have problem and, if so, main source of problem.
for non-compute intensive things, cpu can handle lot of activity. if lot of users pounding transactions every 2 seconds though, end bottleneck somewhere causes issues. 200 users transaction every 2 seconds means 100 transactions/sec means if take more 10ms of cpu or of other serialized resource (like perhaps network card) per transaction, may have issues.
as offloading work process, wouldn't spend time worrying until you've measured whether have issue or not. if do, important understand main cause of issue is. may make more sense cluster node.js processes put multiple processes on same server break core logic multiple processes. depend upon main cause of issue (if have issue). or, may end needing multiple network cards. or else. it's far know before measuring , understanding.
Comments
Post a Comment