I have found my rails app has got a so slow rendering speed,no matter it works under development or production enviroment,no matter it works under windows or linux,no matter it is started by webrick or apache+mongrel,here is the log: Rendering users/topusers [4;35;1mProfile Columns (0.016000) SHOW FIELDS FROM profiles [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE (users.id = 1) LIMIT 1 [4;35;1mUser Load (0.000000) SELECT * FROM users WHERE (users.id = 2) LIMIT 1 [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE (users.id = 6) LIMIT 1 [4;35;1mUser Load (0.016000) SELECT * FROM users WHERE (users.id = 5) LIMIT 1 [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE (users.id = 3) LIMIT 1 [4;35;1mUser Load (0.000000) SELECT * FROM users WHERE (users.id = 4) LIMIT 1 Completed in 0.89000 (1 reqs/sec) | Rendering: 0.67100 (75%) | DB: 0.03200 (3%) | 200 OK [http://127.0.0.1/] I can see that this rendering will take 0.89 second to finish,and DB occupies only 3% of the time.Here is the rhtml: <% @profiles.each do |profile| %> <a href="/users/view/<%= profile.user.id %>" > <% unless profile.image.nil? %> <img src=<% url_for_image_column profile, "image", :size => "24x24", :name => "medium" %> height=16 width=16 /img> <% else %> <%= user_thumb("default") %> <% end %> </a> <%= link_to_remote " "+h("#{profile.user.login}")+ " ", { :url => { :controller => ''users'', :action => ''view'', :id => "#{profile.user.id}" }, { :href => url_for( :controller => ''users'', :action => ''view'', :id => "#{profile.user.id}" )} %> <% end %> And here is the action: def topusers @profiles = Profile.find(:all, :order => ''updated_at DESC'', :limit => 10) render :layout => false end It is very simple,but the rendering time is so long. Although i have notices such article that route may effect the rendering time, it seems to improve very little to the performance. From many persons'' experience,they are easy to reach a concurrency of 100 req/sec, i can only get 1 req/sec, a very large gap. Have i made some mistakes? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Please use action_profiler to benchmark your app. Rendering is slow and is a problem, but much of it can be alleviated by generating routes manually. Also search for Stefan Kaes'' optimizations. Vish On 10/8/06, Benson <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I have found my rails app has got a so slow rendering speed,no matter it > works under development or production enviroment,no matter it works > under windows or linux,no matter it is started by webrick or > apache+mongrel,here is the log: > > Rendering users/topusers > [4;35;1mProfile Columns (0.016000) SHOW FIELDS FROM > profiles > [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE > (users.id = 1) LIMIT 1 > [4;35;1mUser Load (0.000000) SELECT * FROM users WHERE > (users.id = 2) LIMIT 1 > [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE > (users.id = 6) LIMIT 1 > [4;35;1mUser Load (0.016000) SELECT * FROM users WHERE > (users.id = 5) LIMIT 1 > [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE > (users.id = 3) LIMIT 1 > [4;35;1mUser Load (0.000000) SELECT * FROM users WHERE > (users.id = 4) LIMIT 1 > Completed in 0.89000 (1 reqs/sec) | Rendering: 0.67100 (75%) | DB: > 0.03200 (3%) | 200 OK [http://127.0.0.1/] > > I can see that this rendering will take 0.89 second to finish,and DB > occupies only 3% of the time.Here is the rhtml: > <% @profiles.each do |profile| %> > <a href="/users/view/<%= profile.user.id %>" > > <% unless profile.image.nil? %> > <img src=<%> url_for_image_column profile, "image", :size => "24x24", :name > => "medium" %> height=16 width=16 /img> > <% else %> > <%= user_thumb("default") %> > <% end %> > </a> > > <%= link_to_remote " "+h("#{profile.user.login}")+ " ", > { :url => { :controller => ''users'', :action => ''view'', :id => > "#{profile.user.id}" }, > { :href => url_for( :controller => ''users'', :action => ''view'', > :id => "#{profile.user.id}" )} %> > <% end %> > > > And here is the action: > > def topusers > @profiles = Profile.find(:all, :order => ''updated_at DESC'', :limit > => 10) > render :layout => false > end > > > It is very simple,but the rendering time is so long. Although i have > notices such article that route may effect the rendering time, it seems > to improve very little to the performance. From many persons'' > experience,they are easy to reach a concurrency of 100 req/sec, i can > only get 1 req/sec, a very large gap. Have i made some mistakes? > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
The above log is based on the adoption of Stefan Kaes'' optimizations. Vishnu Gopal wrote:> Please use action_profiler to benchmark your app. Rendering is slow and > is a > problem, but much of it can be alleviated by generating routes manually. > Also search for Stefan Kaes'' optimizations. > > Vish-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Oct 7, 2006, at 7:16 PM, Benson wrote:> > I have found my rails app has got a so slow rendering speed,no > matter it > works under development or production enviroment,no matter it works > under windows or linux,no matter it is started by webrick or > apache+mongrel,here is the log: > > Rendering users/topusers > [4;35;1mProfile Columns (0.016000) SHOW FIELDS FROM > profiles > [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE > (users.id = 1) LIMIT 1 > [4;35;1mUser Load (0.000000) SELECT * FROM users WHERE > (users.id = 2) LIMIT 1 > [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE > (users.id = 6) LIMIT 1 > [4;35;1mUser Load (0.016000) SELECT * FROM users WHERE > (users.id = 5) LIMIT 1 > [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE > (users.id = 3) LIMIT 1 > [4;35;1mUser Load (0.000000) SELECT * FROM users WHERE > (users.id = 4) LIMIT 1 > Completed in 0.89000 (1 reqs/sec) | Rendering: 0.67100 (75%) | DB: > 0.03200 (3%) | 200 OK [http://127.0.0.1/] > > I can see that this rendering will take 0.89 second to finish,and DB > occupies only 3% of the time.Here is the rhtml: > <% @profiles.each do |profile| %> > <a href="/users/view/<%= profile.user.id %>" > > <% unless profile.image.nil? %> > <img src=<%> url_for_image_column profile, "image", :size => > "24x24", :name > => "medium" %> height=16 width=16 /img> > <% else %> > <%= user_thumb("default") %> > <% end %> > </a> > > <%= link_to_remote " "+h("#{profile.user.login}")+ " ", > { :url => { :controller => ''users'', :action => ''view'', :id => > "#{profile.user.id}" }, > { :href => url_for( :controller => ''users'', :action => > ''view'', > :id => "#{profile.user.id}" )} %> > <% end %> > > > And here is the action: > > def topusers > @profiles = Profile.find(:all, :order => ''updated_at DESC'', :limit > => 10) > render :layout => false > end > > > It is very simple,but the rendering time is so long. Although i have > notices such article that route may effect the rendering time, it > seems > to improve very little to the performance. From many persons'' > experience,they are easy to reach a concurrency of 100 req/sec, i can > only get 1 req/sec, a very large gap. Have i made some mistakes?Are those calls to user_thumb and the other image operations doing resizing on the fly? That could account for low performance. Other then that I don''t see anything that should be taking so much time. Can you do a benchmark of an action that just does a render :text => ''hello!'' to get a baseline perf measurement? -Ezra --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
> > Are those calls to user_thumb and the other image operations doing > resizing on the fly? That could account for low performance. Other > then that I don''t see anything that should be taking so much time. > Can you do a benchmark of an action that just does a render :text => > ''hello!'' to get a baseline perf measurement? > > -EzraUser_thumb is a very simple helper method: def user_thumb (id) "<img src=\"/images/default_user_thumb.gif\" width=30 height=30/>" end Here are some more measurement: 1 I remove the code of user_thumb,and the rhtml refers to: <% @profiles.each do |profile| %> <%= link_to_remote " "+h("#{profile.user.login}")+ " ", { :url => { :controller => ''users'', :action => ''view'', :id => "#{profile.user.id}" }, { :href => url_for( :controller => ''users'', :action => ''view'', :id => "#{profile.user.id}" )} %> <% end %> Then the log is: Completed in 1.64100 (0 reqs/sec) | Rendering: 1.31200 (79%) | DB: 0.03200 (1%) | 200 OK [http://127.0.0.1/] 2 I use render :text => "hello" The log is: Completed in 0.34400 (2 reqs/sec) | Rendering: 0.00000 (0%) | DB: 0.00000 (0%) | 200 OK [http://127.0.0.1/] 3 I change the action "topusers" to : def topusers render :text => ''hello'' end The log is: Completed in 0.17200 (5 reqs/sec) | Rendering: 0.00000 (0%) | DB: 0.00000 (0%) | 200 OK [http://127.0.0.1/] These following test is done under windows, but it does not improve much under linux. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Could the calls to profile.user, profile.image be generating lots of database queries? (in which case consider eager loading). Often stuff like that doesn''t really show up as database time, because the individual queries themselves are so fast. But as others have said why not stop guessing and use something like action_profiler? Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Oct 8, 2006, at 12:58 AM, Benson wrote:> >> >> Are those calls to user_thumb and the other image operations doing >> resizing on the fly? That could account for low performance. Other >> then that I don''t see anything that should be taking so much time. >> Can you do a benchmark of an action that just does a render :text => >> ''hello!'' to get a baseline perf measurement? >> >> -Ezra > User_thumb is a very simple helper method: > def user_thumb (id) > "<img src=\"/images/default_user_thumb.gif\" width=30 height=30/>" > end > > Here are some more measurement: > 1 I remove the code of user_thumb,and the rhtml refers to: > <% @profiles.each do |profile| %> > <%= link_to_remote " "+h("#{profile.user.login}")+ " ", > { :url => { :controller => ''users'', :action => ''view'', :id => > "#{profile.user.id}" }, > { :href => url_for( :controller => ''users'', :action => > ''view'', > :id => "#{profile.user.id}" )} %> > <% end %> > > Then the log is: > Completed in 1.64100 (0 reqs/sec) | Rendering: 1.31200 (79%) | DB: > 0.03200 (1%) | 200 OK [http://127.0.0.1/] > > 2 I use render :text => "hello" > The log is: > Completed in 0.34400 (2 reqs/sec) | Rendering: 0.00000 (0%) | DB: > 0.00000 (0%) | 200 OK [http://127.0.0.1/] > > 3 I change the action "topusers" to : > def topusers > render :text => ''hello'' > end > The log is: > Completed in 0.17200 (5 reqs/sec) | Rendering: 0.00000 (0%) | DB: > 0.00000 (0%) | 200 OK [http://127.0.0.1/] > > > These following test is done under windows, but it does not improve > much > under linux.I wouls say you have some other issue at this point. If a simple action ith render :text => ''foo'' is that slow then no other rails actions can be faster. render :text is the minimum action rails can serve while exercising the full stack. So you need to figure out why your setup is so slow. I don''t know about on windows but on linux or osx a render :text action should get much closer to 100req/sec when it doesnt access the db. -Ezra --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Benson wrote:> Rendering users/topusers > [4;35;1mProfile Columns (0.016000) SHOW FIELDS FROM > profiles > [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE > (users.id = 1) LIMIT 1 > [4;35;1mUser Load (0.000000) SELECT * FROM users WHERE > (users.id = 2) LIMIT 1 > [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE > (users.id = 6) LIMIT 1 > [4;35;1mUser Load (0.016000) SELECT * FROM users WHERE > (users.id = 5) LIMIT 1 > [4;36;1mUser Load (0.000000) [0;1mSELECT * FROM users WHERE > (users.id = 3) LIMIT 1 > [4;35;1mUser Load (0.000000) SELECT * FROM users WHERE > (users.id = 4) LIMIT 1 > Completed in 0.89000 (1 reqs/sec) | Rendering: 0.67100 (75%) | DB: > 0.03200 (3%) | 200 OK [http://127.0.0.1/]Seeing that, an :include for find is needed. Joe -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---