SpringFlowers AutumnMoon
2009-Apr-22 16:35 UTC
why does number of hits per second go from 1800 to 20?
i had the following code to ball-park the number of possible hits per second my macbook can support: <% t = Time.now %> <h1>Hello#index</h1> <p>Find me in app/views/hello/index.rhtml</p> <pre> <% for i in 1..100 do %> <%= Time.now %> <%= h @ha %> <%= sanitize @ha %> <%= u @ha %> <%= @ha.to_json %> <%= strip_tags @ha %> <%= Time.now - t %> <%= 1 / (Time.now - t) %> <% end %> so the last number is how many page server this page can support in 1 second if it stops right there. that number is initially about 1800, and then at the end of the loop, it is just 20. this program is not so CPU intensive, it seems... i wonder how come it drops from 1800 to 20 that quickly? thanks. -- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-Apr-22 17:26 UTC
Re: why does number of hits per second go from 1800 to 20?
On Apr 22, 5:35 pm, SpringFlowers AutumnMoon <rails-mailing- l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> so the last number is how many page server this page can support in 1 > second if it stops right there. > > that number is initially about 1800, and then at the end of the loop, it > is just 20. > > this program is not so CPU intensive, it seems... i wonder how come it > drops from 1800 to 20 that quickly? thanks.after the 1st iteration through the loop you have used (aparently) 1/1800 of a second. having done 100 iterations, you''ve used 1/20th of a second ie aprox 1/1800 * 100. How is it a surprise that doing something 100 times takes roughly 100 times as long as doing it once. This "benchmark" is also only testing erb - it is not testing any of the actioncontroller, routing etc... (you might find ab enough for your needs( Fred> -- > Posted viahttp://www.ruby-forum.com/.
SpringFlowers AutumnMoon
2009-Apr-22 17:49 UTC
Re: why does number of hits per second go from 1800 to 20?
Frederick Cheung wrote:> after the 1st iteration through the loop you have used (aparently) > 1/1800 of a second. > having done 100 iterations, you''ve used 1/20th of a second ie aprox > 1/1800 * 100. How is it a surprise that doing something 100 times > takes roughly 100 times as long as doing it once. > > This "benchmark" is also only testing erb - it is not testing any of > the actioncontroller, routing etc... (you might find ab enough for > your needs( > > Fredhm, i think i am looking for more fixed cost... such as running the loop 1 time, the machine can serve 1800 pages per second and running the loop 100 times, the machine can serve 200 pages per second. so you are saying that fixed cost is minimal and it is largely just the execution time? fixed cost involves forking a process, for example... but is it true that there is no newly created process when a page is served? thanks. -- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-Apr-22 17:53 UTC
Re: why does number of hits per second go from 1800 to 20?
On Apr 22, 6:49 pm, SpringFlowers AutumnMoon <rails-mailing- l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > after the 1st iteration through the loop you have used (aparently) > > 1/1800 of a second. > > having done 100 iterations, you''ve used 1/20th of a second ie aprox > > 1/1800 * 100. How is it a surprise that doing something 100 times > > takes roughly 100 times as long as doing it once. > > > This "benchmark" is also only testing erb - it is not testing any of > > the actioncontroller, routing etc... (you might find ab enough for > > your needs( > > > Fred > > hm, i think i am looking for more fixed cost... such as running the loop > 1 time, the machine can serve 1800 pages per second and running the loop > 100 times, the machine can serve 200 pages per second. so you are > saying that fixed cost is minimal and it is largely just the execution > time? fixed cost involves forking a process, for example... but is it > true that there is no newly created process when a page is served? > thanks. >there is no process created. I''m not saying that there is no fixed cost, I''m saying that your test doesn''t cover a large portion of the fixed cost Fred> -- > Posted viahttp://www.ruby-forum.com/.
Ilan Berci
2009-Apr-22 19:31 UTC
Re: why does number of hits per second go from 1800 to 20?
Change this:> <% t = Time.now %> > <h1>Hello#index</h1> > <p>Find me in app/views/hello/index.rhtml</p> > > <pre> > <% for i in 1..100 do %> > <%= Time.now %> > <%= h @ha %> > <%= sanitize @ha %> > <%= u @ha %> > <%= @ha.to_json %> > <%= strip_tags @ha %> > > <%= Time.now - t %> > > <%= 1 / (Time.now - t) %> > <% end %> >to this: <% for i in 1..100 do %> <% t = Time.now %> <%= h @ha %> <%= sanitize @ha %> <%= u @ha %> <%= @ha.to_json %> <%= strip_tags @ha %>> <%= 1 / (Time.now - t) %> <% end %> your test is still flawed as the above poster mentioned.. but this will correct the behavior you were previously seeing.. ilan -- Posted via http://www.ruby-forum.com/.
SpringFlowers AutumnMoon
2009-Apr-22 20:39 UTC
Re: why does number of hits per second go from 1800 to 20?
Ilan Berci wrote:> Change this: >> <% t = Time.now %> >> <h1>Hello#index</h1> >> <p>Find me in app/views/hello/index.rhtml</p> >> >> <pre> >> <% for i in 1..100 do %> >> <%= Time.now %> >> <%= h @ha %> >> <%= sanitize @ha %> >> <%= u @ha %> >> <%= @ha.to_json %> >> <%= strip_tags @ha %> >> >> <%= Time.now - t %> >> >> <%= 1 / (Time.now - t) %> >> <% end %> >> > to this: > <% for i in 1..100 do %> > <% t = Time.now %> > <%= h @ha %> > <%= sanitize @ha %> > <%= u @ha %> > <%= @ha.to_json %> > <%= strip_tags @ha %>> > <%= 1 / (Time.now - t) %> > <% end %> > > your test is still flawed as the above poster mentioned.. but this will > correct the behavior you were previously seeing.. > > ilanhow is my test flawed? I wasn''t looking to see if each iteration takes different duration. I was really try to run a simple loop and see how many hits the server can take per second. be careful when you say people''s code is flawed, as it insults people. maybe you don''t know about it. -- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-Apr-22 20:48 UTC
Re: why does number of hits per second go from 1800 to 20?
On 22 Apr 2009, at 21:39, SpringFlowers AutumnMoon wrote:> > how is my test flawed?Exactly as I explained previously: you are benchmarking how long it takes to render an erb template, but there''s a lot of other bits of overhead that will go into your overall requests/second. Fred> I wasn''t looking to see if each iteration takes > different duration. I was really try to run a simple loop and see how > many hits the server can take per second. be careful when you say > people''s code is flawed, as it insults people. maybe you don''t know > about it. > > -- > Posted via http://www.ruby-forum.com/. > > >
SpringFlowers AutumnMoon
2009-Apr-22 21:09 UTC
Re: why does number of hits per second go from 1800 to 20?
Frederick Cheung wrote:> On 22 Apr 2009, at 21:39, SpringFlowers AutumnMoon wrote: > >> >> how is my test flawed? > > Exactly as I explained previously: you are benchmarking how long it > takes to render an erb template, but there''s a lot of other bits of > overhead that will go into your overall requests/second. > > Fredand that''s why i said it is just a ball park figure (just for the templating part). for example, if my webpages are dynamic and with very little processing, then maybe it can serve 1800 pages per second? (i got to try when i get home). also, maybe i can remove any code at all and just put some static content there and see how long it takes to serve that content. -- Posted via http://www.ruby-forum.com/.
Why don''t you just use wget in a loop to time the entire rails application? Something like this will hit your server with 1000 requests and tell you how long it took. $ time for (( cnt = 0 ; cnt < 1000 ; cnt++ )) ; do /usr/bin/wget -nd - q -O /dev/null http://localhost:3000/whateverpage ; done Just remember to run in Production mode if you want any sort of realism. Brendon. On Apr 22, 2:09 pm, SpringFlowers AutumnMoon <rails-mailing- l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > On 22 Apr 2009, at 21:39, SpringFlowers AutumnMoon wrote: > > >> how is my test flawed? > > > Exactly as I explained previously: you are benchmarking how long it > > takes to render an erb template, but there''s a lot of other bits of > > overhead that will go into your overall requests/second. > > > Fred > > and that''s why i said it is just a ball park figure (just for the > templating part). for example, if my webpages are dynamic and with very > little processing, then maybe it can serve 1800 pages per second? (i > got to try when i get home). also, maybe i can remove any code at all > and just put some static content there and see how long it takes to > serve that content. > > -- > Posted viahttp://www.ruby-forum.com/.
pharrington
2009-Apr-23 02:19 UTC
Re: why does number of hits per second go from 1800 to 20?
Well, the simpler way to do the above would be what Frederick mentioned and use ab: ab -n 1000 -c 20 http://local:3000/page/to/benchmark You also get the bonus of getting a rough idea of how well your app handles concurrent requests before choking. On Apr 22, 9:19 pm, Brendon <bren...-gi94QSVkwfGt/hvpvFFPbQ@public.gmane.org> wrote:> Why don''t you just use wget in a loop to time the entire rails > application? Something like this will hit your server with 1000 > requests and tell you how long it took. > > $ time for (( cnt = 0 ; cnt < 1000 ; cnt++ )) ; do /usr/bin/wget -nd - > q -O /dev/nullhttp://localhost:3000/whateverpage; done > > Just remember to run in Production mode if you want any sort of > realism. > > Brendon. > > On Apr 22, 2:09 pm, SpringFlowers AutumnMoon <rails-mailing- > > l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > Frederick Cheung wrote: > > > On 22 Apr 2009, at 21:39, SpringFlowers AutumnMoon wrote: > > > >> how is my test flawed? > > > > Exactly as I explained previously: you are benchmarking how long it > > > takes to render an erb template, but there''s a lot of other bits of > > > overhead that will go into your overall requests/second. > > > > Fred > > > and that''s why i said it is just a ball park figure (just for the > > templating part). for example, if my webpages are dynamic and with very > > little processing, then maybe it can serve 1800 pages per second? (i > > got to try when i get home). also, maybe i can remove any code at all > > and just put some static content there and see how long it takes to > > serve that content. > > > -- > > Posted viahttp://www.ruby-forum.com/. > >
SpringFlowers AutumnMoon
2009-Apr-23 14:21 UTC
Re: why does number of hits per second go from 1800 to 20?
pharrington wrote:> Well, the simpler way to do the above would be what Frederick > mentioned and use ab: > > ab -n 1000 -c 20 http://local:3000/page/to/benchmark > > You also get the bonus of getting a rough idea of how well your app > handles concurrent requests before choking.great. that works best. i thought fred had a typo when he typed ''ab''... i couldn''t use local here used ab -n 1000 -c 20 http://127.0.0.1:3000/hello/help and it was great. thanks. -- Posted via http://www.ruby-forum.com/.
I didn''t suggest ab or a bunch of other tools since he may not have apache installed... but if he does, then that is better! On Apr 22, 7:19 pm, pharrington <xenogene...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Well, the simpler way to do the above would be what Frederick > mentioned and use ab: > > ab -n 1000 -c 20http://local:3000/page/to/benchmark > > You also get the bonus of getting a rough idea of how well your app > handles concurrent requests before choking. > > On Apr 22, 9:19 pm, Brendon <bren...-gi94QSVkwfGt/hvpvFFPbQ@public.gmane.org> wrote: > > > Why don''t you just use wget in a loop to time the entire rails > > application? Something like this will hit your server with 1000 > > requests and tell you how long it took. > > > $ time for (( cnt = 0 ; cnt < 1000 ; cnt++ )) ; do /usr/bin/wget -nd - > > q -O /dev/nullhttp://localhost:3000/whateverpage;done > > > Just remember to run in Production mode if you want any sort of > > realism. > > > Brendon. > > > On Apr 22, 2:09 pm, SpringFlowers AutumnMoon <rails-mailing- > > > l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > Frederick Cheung wrote: > > > > On 22 Apr 2009, at 21:39, SpringFlowers AutumnMoon wrote: > > > > >> how is my test flawed? > > > > > Exactly as I explained previously: you are benchmarking how long it > > > > takes to render an erb template, but there''s a lot of other bits of > > > > overhead that will go into your overall requests/second. > > > > > Fred > > > > and that''s why i said it is just a ball park figure (just for the > > > templating part). for example, if my webpages are dynamic and with very > > > little processing, then maybe it can serve 1800 pages per second? (i > > > got to try when i get home). also, maybe i can remove any code at all > > > and just put some static content there and see how long it takes to > > > serve that content. > > > > -- > > > Posted viahttp://www.ruby-forum.com/.
SpringFlowers AutumnMoon
2009-Apr-23 19:32 UTC
Re: why does number of hits per second go from 1800 to 20?
Brendon Whateley wrote:> I didn''t suggest ab or a bunch of other tools since he may not have > apache installed... but if he does, then that is better!actually, isn''t ab just to test how the server performed? i used it and it worked to test RoR on my macbook. thanks. -- Posted via http://www.ruby-forum.com/.
SpringFlowers AutumnMoon
2009-Apr-23 19:33 UTC
Re: why does number of hits per second go from 1800 to 20?
SpringFlowers AutumnMoon wrote:> Brendon Whateley wrote: >> I didn''t suggest ab or a bunch of other tools since he may not have >> apache installed... but if he does, then that is better! > > actually, isn''t ab just to test how the server performed? i used it and > it worked to test RoR on my macbook. thanks.(i mean it can be WEBrick or Mongrel and it doesn''t matter?) -- Posted via http://www.ruby-forum.com/.
Sure it can test any web server. I just meant that since it is part of the apache package not everybody would have it installed. On Apr 23, 12:33 pm, SpringFlowers AutumnMoon <rails-mailing- l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> SpringFlowers AutumnMoon wrote: > > Brendon Whateley wrote: > >> I didn''t suggest ab or a bunch of other tools since he may not have > >> apache installed... but if he does, then that is better! > > > actually, isn''t ab just to test how the server performed? i used it and > > it worked to test RoR on my macbook. thanks. > > (i mean it can be WEBrick or Mongrel and it doesn''t matter?)
SpringFlowers AutumnMoon
2009-Apr-23 22:27 UTC
Re: why does number of hits per second go from 1800 to 20?
Brendon Whateley wrote:> Sure it can test any web server. I just meant that since it is part > of the apache package not everybody would have it installed. > > On Apr 23, 12:33�pm, SpringFlowers AutumnMoon <rails-mailing-oh i see. thanks. fortunately the macbook with Leopard has it. i was thinking of whether to set up a Linux machine to run Rails... but until now there seems to be no reason to. -- Posted via http://www.ruby-forum.com/.