I''m using Apache''s HTTP server, and finally got it configured to the point where my pages will load, but they take an average of 15 to 20 seconds to load. I''ve tried to search all areas of Ruby on Rails and googled my questions but wasn''t able to find a solution. WEBrick flies like the wind, but I plan to move this app onto a hosted website that uses Apache. I''m following along with "Rails in 4 Days", so I''m not using a large database, and everything is local. The Apache version I''m using is 2.0.53 for windows, Ruby 1.8.3, and the latest Rails/gems installation/update. Could someone provide a concise set of instructions for configuring the server, or point me to something with these instructions? I''ve found several articles and the "video" in Rails Academy, but nothing seems to help. I''m certain I have whacked my config so badly that the requests are going to Mars before they come back. Thanks for your help, Brian
Brian- I''m gonna assume (safely, I believe) that you''re running using CGI under Apache. In those conditions, it''s unlikely that any amount of tuning will do much to speed up your rails application. In my experience it, unfortunately, seems that RoR requires so many outside files, that it just doesn''t run very fast in a standard CGI environment, because of all the time it takes to load and parse all those require''d libraries. If you can, try setting up RoR to run with either mod_ruby or FastCGI. Out of curiousity (list-wise), has anybody figured out anyway to tune the CGI to be slightly faster, or is there just nothing to be done? Cheers, Ben On Sat, 26 Mar 2005 09:08:54 -0700, Best Family <briander43-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> I''m using Apache''s HTTP server, and finally got it configured to the > point where my pages will load, but they take an average of 15 to 20 > seconds to load. I''ve tried to search all areas of Ruby on Rails and > googled my questions but wasn''t able to find a solution. WEBrick flies > like the wind, but I plan to move this app onto a hosted website that > uses Apache. > > I''m following along with "Rails in 4 Days", so I''m not using a large > database, and everything is local. > > The Apache version I''m using is 2.0.53 for windows, Ruby 1.8.3, and the > latest Rails/gems installation/update. > > Could someone provide a concise set of instructions for configuring the > server, or point me to something with these instructions? I''ve found > several articles and the "video" in Rails Academy, but nothing seems to > help. I''m certain I have whacked my config so badly that the requests > are going to Mars before they come back. > > Thanks for your help, > Brian > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Speeding up CGI is a uphill battle. CGI is just not a technology which is up to modern web applications requirements. Here is what happens for each cgi request: * Staring ruby binary * Compiling half the ruby standard library + all of rails * Generates all the active record code dynamically from your database schema * Execute your code * Terminates With fastcgi the only thing which is done for each request is the code execution phase. On Sat, 26 Mar 2005 09:15:32 -0700, Ben Schumacher <benschumacher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Brian- > > I''m gonna assume (safely, I believe) that you''re running using CGI > under Apache. In those conditions, it''s unlikely that any amount of > tuning will do much to speed up your rails application. In my > experience it, unfortunately, seems that RoR requires so many outside > files, that it just doesn''t run very fast in a standard CGI > environment, because of all the time it takes to load and parse all > those require''d libraries. If you can, try setting up RoR to run with > either mod_ruby or FastCGI. > > Out of curiousity (list-wise), has anybody figured out anyway to tune > the CGI to be slightly faster, or is there just nothing to be done? > > Cheers, > > Ben > > > On Sat, 26 Mar 2005 09:08:54 -0700, Best Family <briander43-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote: > > I''m using Apache''s HTTP server, and finally got it configured to the > > point where my pages will load, but they take an average of 15 to 20 > > seconds to load. I''ve tried to search all areas of Ruby on Rails and > > googled my questions but wasn''t able to find a solution. WEBrick flies > > like the wind, but I plan to move this app onto a hosted website that > > uses Apache. > > > > I''m following along with "Rails in 4 Days", so I''m not using a large > > database, and everything is local. > > > > The Apache version I''m using is 2.0.53 for windows, Ruby 1.8.3, and the > > latest Rails/gems installation/update. > > > > Could someone provide a concise set of instructions for configuring the > > server, or point me to something with these instructions? I''ve found > > several articles and the "video" in Rails Academy, but nothing seems to > > help. I''m certain I have whacked my config so badly that the requests > > are going to Mars before they come back. > > > > Thanks for your help, > > Brian > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
I tried setting up FastCGI and mod_ruby - what I couldn''t determine is if this is an either one or the other case, or if I can set up both. I couldn''t tell the difference between mod_ruby or FastCGI, primarily because I''m not sure if I''ve got them configured correctly. In any case, I wouldn''t think it would take that long to load a web page. I also can''t imagine CGI lasting this long with page loads as long as this. Does someone have the steps required to setup FastCGI and/or mod_ruby? As I mentioned previously, I''ve found various items on the web site but nothing conclusive, or up to using the current versions of ruby, rails and apache. I forgot to mention that I also tried the Ruby for Apache One-Click installer but that doesn''t seem to help.
On Sat, 26 Mar 2005 11:34:17 -0700, Best Family <briander43-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> I tried setting up FastCGI and mod_ruby - what I couldn''t determine is > if this is an either one or the other case, or if I can set up both.You can only use one. Trying to use both would be like trying to install two different engines into an automobile and trying to make it go.> I couldn''t tell the difference between mod_ruby or FastCGI, primarily > because I''m not sure if I''ve got them configured correctly. In anyI don''t think one really has any advantage over the other, they both do the same thing, just in slightly different ways. The only difference I''ve noticed is that mod_ruby is an apache-only thing, while FastCGI works in alternate web servers. So since I''m not using apache, fastcgi was my only option, and it''s quite fast.> case, I wouldn''t think it would take that long to load a web page. I > also can''t imagine CGI lasting this long with page loads as long as this.It''s not CGI''s fault. CGI is a perfectly acceptable technology (I should know, I was running a blosxom (perl) blog in regular CGI before switching to rails and the speed of perl in CGI is comparable to the speed of rails in FastCGI.> Does someone have the steps required to setup FastCGI and/or mod_ruby?http://www.modruby.net/en/doc/?InstallGuide -- Urban Artography http://artography.ath.cx
Brian- It seems likely that you were probably still using standard CGI when tryting to get FastCGI/mod_ruby working. The most important change you need to make to get either FastCGI or mod_ruby working is updating the .htaccess file in the public directory. By default this file will map all your Rails-requests through dispatch.cgi (with the line RewriteRule ^(.*)$ dispatch.cgi), so to make it work with mod_ruby, you''d change it to dispatch.rb and to make it work with FastCGI you''d change it to dispatch.fcgi. Hopefully that''ll get you closer. Just FYI- If you switch to FastCGI and it''s executing dispatch.fcgi correctly, you ought to see messages to that effect in your error_log for Apache. If you get actual error messages (about not connecting, shutting down, etc), post those to this list and I''m sure somebody can help you figure it out. Cheers, Ben On Sat, 26 Mar 2005 11:34:17 -0700, Best Family <briander43-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> I tried setting up FastCGI and mod_ruby - what I couldn''t determine is > if this is an either one or the other case, or if I can set up both. > > I couldn''t tell the difference between mod_ruby or FastCGI, primarily > because I''m not sure if I''ve got them configured correctly. In any > case, I wouldn''t think it would take that long to load a web page. I > also can''t imagine CGI lasting this long with page loads as long as this. > > Does someone have the steps required to setup FastCGI and/or mod_ruby? > As I mentioned previously, I''ve found various items on the web site but > nothing conclusive, or up to using the current versions of ruby, rails > and apache. > > I forgot to mention that I also tried the Ruby for Apache One-Click > installer but that doesn''t seem to help. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Sat, 2005-03-26 at 11:48 -0700, Rob Park wrote:> On Sat, 26 Mar 2005 11:34:17 -0700, Best Family <briander43-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote: > > I tried setting up FastCGI and mod_ruby - what I couldn''t determine is > > if this is an either one or the other case, or if I can set up both. > > You can only use one. Trying to use both would be like trying to > install two different engines into an automobile and trying to make it > go.There are a few cars out there that have more than one engine. Granted they are special engineered, one off machines. Watch tractor pulls some time to see many multi engine machines. There are still some 5 or more engine machines out there. For Rails, you can only use one or the other at any specific time.> > I couldn''t tell the difference between mod_ruby or FastCGI, primarily > > because I''m not sure if I''ve got them configured correctly. In any > > I don''t think one really has any advantage over the other, they both > do the same thing, just in slightly different ways. The only > difference I''ve noticed is that mod_ruby is an apache-only thing, > while FastCGI works in alternate web servers. So since I''m not using > apache, fastcgi was my only option, and it''s quite fast.FastCGI can run multiple rails applications under the same apache or other webserver where as mod_ruby can only load up 1 rails app.> > case, I wouldn''t think it would take that long to load a web page. I > > also can''t imagine CGI lasting this long with page loads as long as this. > > It''s not CGI''s fault. CGI is a perfectly acceptable technology (I > should know, I was running a blosxom (perl) blog in regular CGI before > switching to rails and the speed of perl in CGI is comparable to the > speed of rails in FastCGI.But to be fair, you probably were not loading nearly the amount of source files into the interpreter under blosxom as you do under rails. While you might not notice it via seat of the pants timing, it looks like perl could be faster at loading and running. :~$ time ruby -e ''puts("Hello world \n")'' Hello world real 0m0.007s user 0m0.004s sys 0m0.002s :~$ time perl -e ''print("Hello world\n");'' Hello world real 0m0.002s user 0m0.002s sys 0m0.001s> > Does someone have the steps required to setup FastCGI and/or mod_ruby? > > http://www.modruby.net/en/doc/?InstallGuide >-- Steven Critchfield <critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org>
Are you running a production environment or development? It makes a big difference. On 27/03/2005, at 4:08 AM, Best Family wrote:> I''m using Apache''s HTTP server, and finally got it configured to the > point where my pages will load, but they take an average of 15 to 20 > seconds to load. I''ve tried to search all areas of Ruby on Rails and > googled my questions but wasn''t able to find a solution. WEBrick > flies like the wind, but I plan to move this app onto a hosted website > that uses Apache. > > I''m following along with "Rails in 4 Days", so I''m not using a large > database, and everything is local. > > The Apache version I''m using is 2.0.53 for windows, Ruby 1.8.3, and > the latest Rails/gems installation/update. > > Could someone provide a concise set of instructions for configuring > the server, or point me to something with these instructions? I''ve > found several articles and the "video" in Rails Academy, but nothing > seems to help. I''m certain I have whacked my config so badly that the > requests are going to Mars before they come back. > > Thanks for your help, > Brian > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Ok, first off, could someone please tell this ignorant fool how to reply to these messages? :-[ Thanks for all the help so far - but I''m still having a problem getting FastCGI to work. Apache''s error.log shows: "[Sun Mar 27 07:47:47 2005] [notice] Apache/2.0.53 (Win32) mod_fastcgi/2.4.2 configured -- resuming normal operations [Sun Mar 27 07:47:47 2005] [notice] Server built: Feb 10 2005 06:11:34 [Sun Mar 27 07:47:47 2005] [notice] Parent: Created child process 2444 [Sun Mar 27 07:47:48 2005] [notice] Child 2444: Child process is running [Sun Mar 27 07:47:48 2005] [notice] Child 2444: Acquired the start mutex. [Sun Mar 27 07:47:48 2005] [notice] FastCGI: process manager initialized [Sun Mar 27 07:47:48 2005] [notice] Child 2444: Starting 250 worker threads." I assume from this that FastCGI is up and running. When I try to go to: "http://todo/categories/list", the following is displayed: #!c:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" require ''dispatcher'' require ''fcgi'' log_file_path = "#{RAILS_ROOT}/log/fastcgi.crash.log" FCGI.each_cgi do |cgi| begin Dispatcher.dispatch(cgi) rescue Object => e error_message = "[#{Time.now}] Dispatcher failed to catch: #{e} (#{e.class})\n #{e.backtrace.join("\n ")}\n" begin Logger.new(log_file_path).fatal(error_message) rescue Object => log_error STDERR << "Couldn''t write to #{log_file_path} (#{log_error} [#{log_error.class}])\n" << error_message end end end I think this is telling me it can''t write an error message to an apparently undefined log file. I haven''t messed with any log file definitions so I''m not sure where to go with this. One other thing that puzzles me is the "#!c:/ruby/bin/ruby" line. I changed this to be "#!c:/ruby/bin/rubyw.exe" in the dispatch.cgi file. Thanks again for all your help. Brian>Message: 3 >Date: Sat, 26 Mar 2005 11:48:52 -0700 >From: Rob Park <rbpark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >Subject: Re: [Rails] Web page load time is exceedingly long >To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >Message-ID: <6b8a2f8b05032610487e9501d0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> >Content-Type: text/plain; charset=ISO-8859-1 > >On Sat, 26 Mar 2005 11:34:17 -0700, Best Family <briander43-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote: > > >>I tried setting up FastCGI and mod_ruby - what I couldn''t determine is >>if this is an either one or the other case, or if I can set up both. >> >> > >You can only use one. Trying to use both would be like trying to >install two different engines into an automobile and trying to make it >go. > > > >>I couldn''t tell the difference between mod_ruby or FastCGI, primarily >>because I''m not sure if I''ve got them configured correctly. In any >> >> > >I don''t think one really has any advantage over the other, they both >do the same thing, just in slightly different ways. The only >difference I''ve noticed is that mod_ruby is an apache-only thing, >while FastCGI works in alternate web servers. So since I''m not using >apache, fastcgi was my only option, and it''s quite fast. > > > >>case, I wouldn''t think it would take that long to load a web page. I >>also can''t imagine CGI lasting this long with page loads as long as this. >> >> > >It''s not CGI''s fault. CGI is a perfectly acceptable technology (I >should know, I was running a blosxom (perl) blog in regular CGI before >switching to rails and the speed of perl in CGI is comparable to the >speed of rails in FastCGI. > > > >>Does someone have the steps required to setup FastCGI and/or mod_ruby? >> >> > >http://www.modruby.net/en/doc/?InstallGuide > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Sun, 27 Mar 2005 08:09:14 -0700, Best Family <briander43-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> Apache''s error.log shows: > "[Sun Mar 27 07:47:47 2005] [notice] Apache/2.0.53 (Win32) > mod_fastcgi/2.4.2 configured -- resuming normal operations > [Sun Mar 27 07:47:47 2005] [notice] Server built: Feb 10 2005 06:11:34 > [Sun Mar 27 07:47:47 2005] [notice] Parent: Created child process 2444 > [Sun Mar 27 07:47:48 2005] [notice] Child 2444: Child process is running > [Sun Mar 27 07:47:48 2005] [notice] Child 2444: Acquired the start mutex. > [Sun Mar 27 07:47:48 2005] [notice] FastCGI: process manager initialized > [Sun Mar 27 07:47:48 2005] [notice] Child 2444: Starting 250 worker > threads." > > I assume from this that FastCGI is up and running.That''s what it looks like.> When I try to go to: "http://todo/categories/list", the following is > displayed: > #!c:/ruby/bin/ruby[snip]> I think this is > telling me it can''t write an error message to an apparently undefined log > file.No, it is not telling you anything. It is the source of the dispatch.fcgi file. Your apache is misconfigured because instead of running the script, it is displaying the contents.> I haven''t messed with any log file definitions so I''m not sure where > to go with this. One other thing that puzzles me is the "#!c:/ruby/bin/ruby" > line. I changed this to be "#!c:/ruby/bin/rubyw.exe" in the dispatch.cgi > file. Thanks again for all your help. BrianYou edited the wrong file. -- Urban Artography http://artography.ath.cx
On Sun, 27 Mar 2005 23:53:54 +1200, Henry Maddocks <henryj-wUU9E3n5/m4qAMOr+u8IRA@public.gmane.org> wrote:> Are you running a production environment or development? It makes a big > difference.The way I do my development, I have RAILS_ENV set to "development" in environment.rb, but then I set it to "production" in dispatch.fcgi. I develop locally running in webrick, which sees the environment as "development", and then I upload it to my server and restart lighttpd, which gets the environment as "production" from the dispatch.fcgi file. It''s not like I"m uploading, testing, and restarting the server every 5 minutes. It''s just that I''m running the server status module in lighttpd, which shows various stats about the webserver (uptime, bandwidth used, etc), and those stats get reset when I restart. Every couple days I notice a bug that needs to be fixed, so my lighttpd uptime is never more than a few days unfortunately. -- Urban Artography http://artography.ath.cx