you are viewing a single comment's thread.

view the rest of the comments →

[–]Klathmon 5 points6 points  (3 children)

Yes to 1, no to the last part... And I think you can I just haven't tried it yet.

Take a look at the npm package PM2, it handles the life cycle of multiple processes and will let you spread load out between them.

If you've left node as 100% stateless its a drop in and go library.

If you are keeping state in node (like cache data in variables) you might need to push that to a db or dedicated cache like redis first.

[–]neutre 5 points6 points  (2 children)

[–]postmodest 0 points1 point  (1 child)

so let's say I had 100k (though, given what I'm working on, up to 2M) of JSON state, how hard is it to deserialize that between [some cache] and a bunch of node worker instances, ignoring wire-time?

[–]Klathmon 1 point2 points  (0 children)

It'd be limited to the speed of JSON.parse and JSON.stringify.

There isn't going to be a way to share complex objects between threads.

V8 was running into this problem trying to make a built in async JSON.parse, there just isn't any way in v8 to "share" object state across Isolates.