221 views
For what types of requests do goroutines provide an advantage over OS threads, and for what types are OS threads equally effective?
Asked at
AI answer
Goroutines are especially advantageous when you need many concurrent tasks that spend much of their time waiting—for example, handling network requests, calling services, or performing other I/O. They are lightweight, and Go’s runtime multiplexes them over a smaller pool of OS threads. OS threads are equally effective for CPU-bound work when you need actual parallelism, and may be appropriate when interfacing with APIs that require a dedicated thread or when work blocks outside Go’s scheduler. The best choice depends on workload and runtime behavior; goroutines still execute on OS threads.
Also asked at Virtuozzo
- How do you find a file and search for a substring within it using Linux command line?
- What happens from the moment you type a URL in a browser to receiving the response? Explain the full process as deeply as possible.
- What is DHCP and how does a device obtain its IP address and DNS server configuration?
- How does the Go runtime process a million I/O-bound requests (e.g., in a proxying/API gateway service)?
- How do you troubleshoot a running service on a Linux production server? How do you find your process and understand what's happening?