Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why would you need hundreds of worker threads? If you're using an event-loop in each process (which you probably want if only to minimize context-switching overhead, and is how Unicorn does it), then you need only one process per physical core in the machine. Anything else will just sit in the runqueue and cause context switches.

There is definitely annoying memory overhead with multiprocess (vs. multithreaded) architectures, but it's on the order of 2x-8x, not 100x. And that's 2x-8x the code size of the application, not data size - you only need duplicate interpreter objects, anything at the app or framework level (like templates or data files) can be stored in read-only shared memory or just COW'd with no writes. (It's technically not even every interpreter object - a number of function objects are completely static data that will never have additional references made, and so COW means they'll be shared perpetually between processes.)



> If you're using an event-loop in each process (which you probably want if only to minimize context-switching overhead, and is how Unicorn does it)

Unicorn is a pre-forking multiprocess server so I don't know why it would be using an event loop.

Why threads over processes? Because memory isn't cheap when you don't own it yourself.


> Why would you need hundreds of worker threads?

Shrug why not? You get a different (easier?) programming model where you can use blocking IO rather than an event loop.

> on the order of 2x-8x, not 100x

Yeah, but that 2x might be the difference between one virtual machine flavor and the next price up.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: