Csaba Okrona
2007-Dec-03 03:03 UTC
[Eventmachine-talk] Simple web server performance tester
Hi All, I have a simple(?) problem: I''m writing a custom webserver performance tester for our image server. Plain threads seem to be too slow for measurement, so I decided to try eventmachine. What I''d like to achieve is: -have a bunch of urls preloaded in an array -download a fixed number (n) of images "concurrently" , if it''s ready, go for the next n-fold block My question is: how can I check if my concurrent downloads are finished and I can start the new block? Since eventmachine is single-threaded, sleep blocks all. Could you help me with this one? My current "beta" code looks like this: def geturl host,port,req http = EventMachine::Protocols::HttpClient.request(:host => host, :port => port, :request => req) http.callback { |response| puts "#{req} done " + Time.now.to_s $running.delete req } end EventMachine.run { 100.times do #total/concurrency 10.times do #concurrency begin addr = $urls.pop $running << addr scan_addr "my.host.domain",81,addr rescue => e puts e.message puts e.backtrace.join("\n") end end end } Thank you in advance, Ochronus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071203/cf3014b5/attachment-0001.html
Francis Cianfrocca
2007-Dec-03 06:16 UTC
[Eventmachine-talk] Simple web server performance tester
On Dec 3, 2007 6:03 AM, Csaba Okrona <ochronus at gmail.com> wrote:> Hi All, > > I have a simple(?) problem: I''m writing a custom webserver performance > tester for our image server. > Plain threads seem to be too slow for measurement, so I decided to try > eventmachine. > > What I''d like to achieve is: > -have a bunch of urls preloaded in an array > -download a fixed number (n) of images "concurrently" , if it''s ready, go > for the next n-fold block > > My question is: how can I check if my concurrent downloads are finished > and I can start the new block? > Since eventmachine is single-threaded, sleep blocks all. > > Could you help me with this one? > > My current "beta" code looks like this: > > def geturl host,port,req > http = EventMachine::Protocols:: HttpClient.request(:host => host, > :port => port, :request => req) > http.callback { |response| > puts "#{req} done " + Time.now.to_s > $running.delete req > } > end > > EventMachine.run { > 100.times do #total/concurrency > 10.times do #concurrency > begin > addr = $urls.pop > $running << addr > scan_addr "my.host.domain",81,addr > rescue => e > puts e.message > puts e.backtrace.join("\n") > end > end > end > } > >Since your code is clearly incomplete, it''s hard to tell what you''re trying to do, but I''ll take a guess. You''re going to simultaneously kick off a large number of HTTP client requests, and you want to be notified when they all complete. Right? This is a pattern I''ve always wanted to automate with an additional library function, but I haven''t decided how. (Suggestions, anyone?) In the meantime, you can increment a global counter every time you call EM::Protocols::HttpClient#request, and decrement it in your callback and your errback blocks. When it goes to zero, you''re done. Did I guess correctly? I recommend you run this on Linux and use epoll, by the way. That way you''re not constrained by Ruby''s 1024-descriptor limit. Also, you will want to use IP addresses rather than hostnames when specifying your HTTP servers, because Ruby''s built-in DNS resolver is a brutal performance hog. There are several evented DNS-resolvers for EM, but one problem at a time. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071203/6765c0e6/attachment.html
Csaba Okrona
2007-Dec-03 11:30 UTC
[Eventmachine-talk] Simple web server performance tester
Hi, First, thank you for the reply! You''re right: I''m going to start a "large" number (say 100) HTTP requests, then wait for them all to complete, then re-launch the "flood". What I''m trying to achieve is a simple webserver benchmark utility, like "ab", the apache benchmark. The difference (and the reason why I''m doing this) is that I need to test different urls, not just one static, and "ab" is not capable of this. We have some websites with quite heavy traffic, and I''m benchmarking our image server, which is lighttpd. I want a real-life benchmark, so apache benchmark with a single (and thus after a few reuqests highly cached) url, so I''m GET-ing random images from our server. For this pure ruby threads seem to be to slow (the image server and the benchmarking server are on a gigabit LAN, and the pictures are small, so requests complete very fast) to keep up with the pace. I''m hoping that eventmachine can cope with the situation. Since your code is clearly incomplete, it''s hard to tell what you''re trying> to do, but I''ll take a guess. > > You''re going to simultaneously kick off a large number of HTTP client > requests, and you want to be notified when they all complete. Right? > > This is a pattern I''ve always wanted to automate with an additional > library function, but I haven''t decided how. (Suggestions, anyone?) > > In the meantime, you can increment a global counter every time you call > EM::Protocols::HttpClient#request, and decrement it in your callback and > your errback blocks. When it goes to zero, you''re done. Did I guess > correctly? > > I recommend you run this on Linux and use epoll, by the way. That way > you''re not constrained by Ruby''s 1024-descriptor limit. Also, you will want > to use IP addresses rather than hostnames when specifying your HTTP servers, > because Ruby''s built-in DNS resolver is a brutal performance hog. There are > several evented DNS-resolvers for EM, but one problem at a time. > > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071203/b3ef793b/attachment.html
Francis Cianfrocca
2007-Dec-03 11:35 UTC
[Eventmachine-talk] Simple web server performance tester
On Dec 3, 2007 2:30 PM, Csaba Okrona <ochronus at gmail.com> wrote:> Hi, > > First, thank you for the reply! > > You''re right: I''m going to start a "large" number (say 100) HTTP requests, > then wait for them all to complete, then > re-launch the "flood". >Does the idea of keeping an external count of the pending HTTP requests and counting them down as they complete solve your problem? As long as you avoid Ruby''s DNS, EM is well-suited for this task. If you use epoll, you should have no trouble running tens of thousands of requests at once. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071203/e32f14c6/attachment.html
Michael S. Fischer
2007-Dec-03 11:40 UTC
[Eventmachine-talk] Simple web server performance tester
If you need something more powerful than ab that''s off the shelf, check out httperf: http://www.hpl.hp.com/research/linux/httperf/ Best regards, --Michael On Dec 3, 2007 11:30 AM, Csaba Okrona <ochronus at gmail.com> wrote:> Hi, > > First, thank you for the reply! > > You''re right: I''m going to start a "large" number (say 100) HTTP requests, > then wait for them all to complete, then > re-launch the "flood". > > What I''m trying to achieve is a simple webserver benchmark utility, like > "ab", the apache benchmark. The difference > (and the reason why I''m doing this) is that I need to test different urls, > not just one static, and "ab" is not capable of this. > We have some websites with quite heavy traffic, and I''m benchmarking our > image server, which is lighttpd. I want a real-life > benchmark, so apache benchmark with a single (and thus after a few > reuqests highly cached) url, so I''m GET-ing random > images from our server. For this pure ruby threads seem to be to slow (the > image server and the benchmarking server are > on a gigabit LAN, and the pictures are small, so requests complete very > fast) to keep up with the pace. I''m hoping that > eventmachine can cope with the situation. > > > > > Since your code is clearly incomplete, it''s hard to tell what you''re > > trying to do, but I''ll take a guess. > > > > You''re going to simultaneously kick off a large number of HTTP client > > requests, and you want to be notified when they all complete. Right? > > > > This is a pattern I''ve always wanted to automate with an additional > > library function, but I haven''t decided how. (Suggestions, anyone?) > > > > In the meantime, you can increment a global counter every time you call > > EM::Protocols::HttpClient#request, and decrement it in your callback and > > your errback blocks. When it goes to zero, you''re done. Did I guess > > correctly? > > > > I recommend you run this on Linux and use epoll, by the way. That way > > you''re not constrained by Ruby''s 1024-descriptor limit. Also, you will want > > to use IP addresses rather than hostnames when specifying your HTTP servers, > > because Ruby''s built-in DNS resolver is a brutal performance hog. There are > > several evented DNS-resolvers for EM, but one problem at a time. > > > > _______________________________________________ > > Eventmachine-talk mailing list > > Eventmachine-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/eventmachine-talk > > > > > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071203/dd602ee3/attachment.html
Michael S. Fischer
2007-Dec-03 11:41 UTC
[Eventmachine-talk] Simple web server performance tester
On Dec 3, 2007 11:35 AM, Francis Cianfrocca <garbagecat10 at gmail.com> wrote:> On Dec 3, 2007 2:30 PM, Csaba Okrona <ochronus at gmail.com> wrote: > > > Hi, > > > > First, thank you for the reply! > > > > You''re right: I''m going to start a "large" number (say 100) HTTP > > requests, then wait for them all to complete, then > > re-launch the "flood". > > > > > Does the idea of keeping an external count of the pending HTTP requests > and counting them down as they complete solve your problem? > > As long as you avoid Ruby''s DNS, EM is well-suited for this task. If you > use epoll, you should have no trouble running tens of thousands of requests > at once. >Subject to the constraints of your network interface... :-) Best regards, --Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071203/f59437df/attachment-0001.html
Francis Cianfrocca
2007-Dec-03 11:45 UTC
[Eventmachine-talk] Simple web server performance tester
On Dec 3, 2007 2:40 PM, Michael S. Fischer <michael at dynamine.net> wrote:> If you need something more powerful than ab that''s off the shelf, check > out httperf: http://www.hpl.hp.com/research/linux/httperf/ > >I like httperf and I use it, but can it handle the requirement of multiple different URLs to be tested simultaneously? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071203/02bee243/attachment.html
Tony Arcieri
2007-Dec-03 11:50 UTC
[Eventmachine-talk] Simple web server performance tester
On Dec 3, 2007 7:16 AM, Francis Cianfrocca <garbagecat10 at gmail.com> wrote:> > You''re going to simultaneously kick off a large number of HTTP client > requests, and you want to be notified when they all complete. Right? > > This is a pattern I''ve always wanted to automate with an additional > library function, but I haven''t decided how. (Suggestions, anyone?) >I''ve written something similar to this (concurrent HTTP fetcher). It ended up being pretty nasty the way I implemented it. It''d really be nice to do it once abstractly and have it be reusable. Among other things it needs to support adding URLs to the list of outstanding objects within the response handler (e.g. for 301/302 responses) -- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071203/64d30b33/attachment.html
Michael S. Fischer
2007-Dec-03 12:42 UTC
[Eventmachine-talk] Simple web server performance tester
On Dec 3, 2007 11:45 AM, Francis Cianfrocca <garbagecat10 at gmail.com> wrote:> On Dec 3, 2007 2:40 PM, Michael S. Fischer <michael at dynamine.net> wrote: > > > If you need something more powerful than ab that''s off the shelf, check > > out httperf: http://www.hpl.hp.com/research/linux/httperf/ > > > > > > I like httperf and I use it, but can it handle the requirement of multiple > different URLs to be tested simultaneously? >Sure; see the --wlog argument. --Micahel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071203/3eb21dae/attachment.html