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

> When would millions of goroutines be useful if you can only run ~4 threads in parallel?

Concurrency.

Have you heard of the 10k problem?

Some people think the best way to handle tends of thousands of concurrent clients is to have each run in a lightweight thread (or goroutine, or whatever term for the same basic abstract concept.) This is as opposed to using an event-based system like Node.js does. Maybe they're right or maybe they're wrong, but that's where it's useful.



A bunch of threads on one core isn't that different from node handling the same number of events. Just moving some of the responsibility from the OS to a framework.


The most critical difference is that threads can yield anywhere. Events only yield in well-defined places. Sometimes that's useful, sometimes it isn't. For example a thread can yield in the middle of a native call to something like zlib. If zlib doesn't know about your event framework (and it doesn't) then it can't yield.




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

Search: