in reply to TCP socket and fork
Why do you think that 20 threads could get HTTP contents faster over a single socket than over 20 distinct sockets? Only one thread at a time could read and write the socket due to the way HTTP works, so 19 threads would have to wait for the first thread to finish. After that, 18 threads have to work for the second thread. And so on, until the last thread finished. You don't need threads for that, a simple for loop is even faster, because it does not have the threads overhead.
You can accelerate HTTP by using the keepalive feature, but for that, you need an agent that you don't destroy after a single request, like you to when you call the simple get() function.
Update: Is this related to IO::Socket, Multiple GET.?
Alexander
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: TCP socket and fork
by adismaug (Acolyte) on Jul 04, 2009 at 11:29 UTC | |
by afoken (Chancellor) on Jul 04, 2009 at 12:04 UTC | |
by adismaug (Acolyte) on Jul 04, 2009 at 12:26 UTC | |
by afoken (Chancellor) on Jul 04, 2009 at 16:58 UTC |