12/28
Part 4 of 6 · A pool and a coordinatorLearn and do
A thread for every link has no bound
Why not start one thread per link and skip the pool?
a thread per link
40 in flight
a pool of 4
4 in flight, 36 queued
A thread per URL looks like the same thing without the bookkeeping, and on the test site it's even faster. But the number of threads has no bound, and the number of URLs isn't up to you.
Size the pool from the rate you want
Fetches in flight equal the rate you want times how long each fetch takes. That's Little's law, . Here is the number in flight, (lambda) is the rate in pages a second, and is the seconds each fetch takes.
Each fetch takes 0.2 s, and you want 20 pages a second. How many fetches must be in flight?
Pick an answer above to see the rest