Threads vs Processes
This cluster debates the advantages and disadvantages of using OS threads versus multiple processes for handling concurrency in servers and applications, particularly regarding scalability, memory usage, performance, and suitability for I/O-bound workloads.
Activity Over Time
Top Contributors
Keywords
Sample Comments
Did you try to spawn lots of threads? OS threads scale better than you'd think.
Don't you find performance suffers? AIUI this approach means you can only handle as many concurrent requests as you have processes, and the OS scheduler has less information to work with than if you were using threads.
You don't need CPU threads for threads that don't need CPU...
You don't need more execution units than for green threads. Typically in these zillion thread use cases, threads wake up for IO, queue activity, etc and are not spinning doing CPU bound computation, so not a hard problem for the OS thread scheduler.
You are better with processes per core, with no threads.
48 independent threads and 48 processes can be very different on some operating systems.A process is more heavyweight.You will - amongst other things - increase the charge in terms of handles. For example, 48 processes maintaining the same network connections is a waste of resources.I'm afraid you might hit a wall with your single threaded approach.This is definitely not the road we have chosen (but we wish the best of luck nonetheless! :) ).
Use multiple processes, and then your code works across multiple machines too (and better across NUMA machines). Threads are simply a bad idea.
multiple processes use a lot more memory than threads
You don't need million threads to be really fast. You need enough threads for your load. If you need to handle 1000 requests per second with each request taking 10 ms in average, you need 100 threads. It's absolutely adequate number of threads for OS to manage. If you would write this code with async style, you won't achieve anything, because bottleneck would be with database or another service or disk I/O. Million threads is very rare case.
Really? What about running multiple nodejs process using clustering? Dude handling multiple processing requests depends solely on the CPU core count NOT on the number of threads you create.The benefits of single process with single thread are way too many compared to single process many threads model.