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.

📉 Falling 0.3x Programming Languages
3,776
Comments
20
Years Active
5
Top Authors
#9903
Topic ID

Activity Over Time

2007
7
2008
45
2009
101
2010
126
2011
145
2012
148
2013
193
2014
147
2015
198
2016
265
2017
264
2018
221
2019
229
2020
283
2021
313
2022
243
2023
433
2024
227
2025
183
2026
5

Keywords

RAM CPU IMHO IHMO OLTP nodejs.org node.js example.com IPC VM threads thread processes cpu io bound cores memory threaded async

Sample Comments

pcwalton May 16, 2018 View on HN

Did you try to spawn lots of threads? OS threads scale better than you'd think.

lmm Dec 6, 2013 View on HN

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.

lultimouomo Apr 13, 2018 View on HN

You don't need CPU threads for threads that don't need CPU...

fulafel Sep 23, 2023 View on HN

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.

pjmlp Nov 3, 2020 View on HN

You are better with processes per core, with no threads.

shin_lao Sep 23, 2010 View on HN

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! :) ).

rwmj Jun 14, 2019 View on HN

Use multiple processes, and then your code works across multiple machines too (and better across NUMA machines). Threads are simply a bad idea.

VWWHFSfQ Oct 17, 2021 View on HN

multiple processes use a lot more memory than threads

vbezhenar Oct 23, 2018 View on HN

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.

ankurdhama Dec 3, 2015 View on HN

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.