Grokking Concurrency in Go
Vote

0% completed

​

Bounded Parallelism with Semaphores

One possible output:

most fetches at once: 50 total: 100ms

The program starts one goroutine per URL and records the largest number of calls to fetch that were in progress at the same moment. All 50 ran at once. The whole job took one fetch time. The loop that updates peak is the compare-and-swap loop from Compare and Swap: it raises the running maximum without a lock.

Fifty at once is fine for a fake fetch. Against a real service that accepts ten requests at a time, it is forty requests too many

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content