Junior — Middle
Are there any limitations on the number of goroutines running simultaneously in an application?
sobes.tech AI
Answer from AI
Go does not have a strict limit on the number of goroutines running simultaneously, but there are practical constraints related to system resources (memory, CPU).
Goroutines are very lightweight compared to OS threads — their stack starts at a few kilobytes and can grow dynamically. This allows launching tens or hundreds of thousands of goroutines.
However, with too many goroutines:
- Memory consumption increases
- The goroutine scheduler load rises
- Performance may decrease due to context switching
Therefore, it is important to control the number of goroutines and use limiting mechanisms (e.g., worker pools) if a very large number of parallel tasks is expected.