I''m working on my first little rails-application. It''s a rewrite of a gallery-script i once made (in PHP): http://notdotnet.net However - my rails-version is waaay to slow :( http://r.notdotnet.net/ I don''t do any heavy image-processing, I don''t have any killer-algorithms with a time complexity on O(n^n), and I don''t use any major hacks. The only "stupid" thing i really do is an "ORDER BY RAND()" on a table with 8000 rows, which is quite heavy, but it shouldn''t take *that* long, and i do the same in PHP which works fine. I then signed up for a new (free) webhost and installed my application there to see if my host was the problem. It performs a bit better on the free one, but is still really slow :/ http://94383.hostmyapplications.com/ Since it don''t mind sharing the source code (nothing brilliant - just a noobs first project =) you can get it here (no db-config file)): http://94383.hostmyapplications.com/rails_slow.tar.gz (and if you like - the database: http://94383.hostmyapplications.com/mysql.zip). Do you have *any* idea why i get such bad performance? thanks in advance. -- Posted via http://www.ruby-forum.com/.
On 8/6/06, Anders <vebihl@gmail.com> wrote:> I''m working on my first little rails-application. It''s a rewrite of a > gallery-script i once made (in PHP): http://notdotnet.net > > However - my rails-version is waaay to slow :( > http://r.notdotnet.net/ > > I don''t do any heavy image-processing, I don''t have any > killer-algorithms with a time complexity on O(n^n), and I don''t use any > major hacks. > The only "stupid" thing i really do is an "ORDER BY RAND()" on a table > with 8000 rows, which is quite heavy, but it shouldn''t take *that* long, > and i do the same in PHP which works fine. > > I then signed up for a new (free) webhost and installed my application > there to see if my host was the problem. It performs a bit better on the > free one, but is still really slow :/ > http://94383.hostmyapplications.com/ > > Since it don''t mind sharing the source code (nothing brilliant - just a > noobs first project =) you can get it here (no db-config file)): > http://94383.hostmyapplications.com/rails_slow.tar.gz (and if you like - > the database: http://94383.hostmyapplications.com/mysql.zip). > > Do you have *any* idea why i get such bad performance?Are you in production mode? Joe
On Sun, 2006-08-06 at 23:53 +0200, Anders wrote: ...> The only "stupid" thing i really do is an "ORDER BY RAND()" on a table > with 8000 rows, which is quite heavy, but it shouldn''t take *that* long, > and i do the same in PHP which works fine.Is your database schema the same as in PHP version? I believe ORDER BY RAND() looks at all your data in each row; the bigger the amount of data the more to look at. So if you added more columns, like descriptions, etc., it would be slower. I guess paging with LIMIT is not an option as you may get repeats, right? Ed
* Anders (vebihl@gmail.com) [060806 16:57]:> Do you have *any* idea why i get such bad performance?Typical performance killers: * running under webrick or via plain CGI instead of fastcgi, and/or with lighttpd, with mongrel, etc. * running in development mode instead of production mode Rick -- http://www.rickbradley.com MUPRN: 418 | to some problem. In random email haiku | fact, many people think it does: | Part of the problem.
Gmail User wrote:> On Sun, 2006-08-06 at 23:53 +0200, Anders wrote: > ... > >> The only "stupid" thing i really do is an "ORDER BY RAND()" on a table >> with 8000 rows, which is quite heavy, but it shouldn''t take *that* long, >> and i do the same in PHP which works fine. > > Is your database schema the same as in PHP version? I believe ORDER BY > RAND() looks at all your data in each row; the bigger the amount of data > the more to look at. So if you added more columns, like descriptions, > etc., it would be slower. I guess paging with LIMIT is not an option as > you may get repeats, right? > > EdAlmost - but not quite the same schema. However - the rails-version is smaller since i made a proper database design here. Also - I only do ORDER BY RAND() on the front page. When you go into a category it dosn''t sort by random anymore (but by the numbers of views). And no - I''m not in production mode. Do that really help that much? I tried tweeking "development.rb" with caching and such - but that didn''t really help. -- Posted via http://www.ruby-forum.com/.
Hi Anders, may be you should tell something about the content you are linking to. Someone might be offended! Cheers, Jan On 8/6/06, Anders <vebihl@gmail.com> wrote:> > I''m working on my first little rails-application. It''s a rewrite of a > gallery-script i once made (in PHP): http://notdotnet.net > > However - my rails-version is waaay to slow :( > http://r.notdotnet.net/ > > I don''t do any heavy image-processing, I don''t have any > killer-algorithms with a time complexity on O(n^n), and I don''t use any > major hacks. > The only "stupid" thing i really do is an "ORDER BY RAND()" on a table > with 8000 rows, which is quite heavy, but it shouldn''t take *that* long, > and i do the same in PHP which works fine. > > I then signed up for a new (free) webhost and installed my application > there to see if my host was the problem. It performs a bit better on the > free one, but is still really slow :/ > http://94383.hostmyapplications.com/ > > Since it don''t mind sharing the source code (nothing brilliant - just a > noobs first project =) you can get it here (no db-config file)): > http://94383.hostmyapplications.com/rails_slow.tar.gz (and if you like - > the database: http://94383.hostmyapplications.com/mysql.zip). > > Do you have *any* idea why i get such bad performance? > > thanks in advance. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060806/52f433ad/attachment.html
> * running under webrick or via plain CGI instead of fastcgi, and/or > with lighttpd, with mongrel, etc.It''s not runing under webrick, and since i forund mod_fastcgi under loaded modules in a phpinfo()-file I assume (can I do that) that fastcgi also is available for rails> > * running in development mode instead of production modeOkey - that might be the problem. How do I ten go into production mode? I don''t have SSH-access, and uncommenting "ENV[''RAILS_ENV''] ||= ''production''" just kills my application with an error500 :( -- Posted via http://www.ruby-forum.com/.
Jan Prill wrote:> Hi Anders, > > may be you should tell something about the content you are linking to. > Someone might be offended! > > Cheers, > Janargghh - I''m really sorry. Actually the script should only show worksafe images on the front page (like notdotnet.net), but since i havn''t "marked" the images yet, that feature dosn''t work. I didn''t think about that! if it''s not to late :P there may be some not-worksafe images on r.notdotnet.net and http://94383.hostmyapplications.com/ -- Posted via http://www.ruby-forum.com/.
On 8/6/06, Anders <vebihl@gmail.com> wrote:> It''s not runing under webrick, and since i forund mod_fastcgi under > loaded modules in a phpinfo()-file I assume (can I do that) that fastcgi > also is available for railsYou need to make sure that public/.htaccess makes connection to dispatch.fcgi instead of dispatch.cgi.> > > > * running in development mode instead of production mode > > Okey - that might be the problem. How do I ten go into production mode? > I don''t have SSH-access, and uncommenting "ENV[''RAILS_ENV''] ||> ''production''" just kills my application with an error500 :(That sounds like a rights issue. Make sure that /log/* and /tmp* are writeable. You can test this by simply making all these chmod 777 -- -------------- Jon Gretar Borgthorsson http://www.jongretar.net/
> You need to make sure that public/.htaccess makes connection to > dispatch.fcgi instead of dispatch.cgi.hmm - when i do that my application just stops responding :/ no error, no log, nothing. as said before - this page (same server) say''s that mod_fastcgi is installed: http://phpinfo.levelup.dk/folder/index.php any ideas? -- Posted via http://www.ruby-forum.com/.
On Aug 6, 2006, at 3:34 PM, Anders wrote:>> * running under webrick or via plain CGI instead of fastcgi, and/or >> with lighttpd, with mongrel, etc. > > It''s not runing under webrick, and since i forund mod_fastcgi under > loaded modules in a phpinfo()-file I assume (can I do that) that > fastcgi > also is available for rails >No that definitely does not mean that your rails app will just work with fcgi. It means more then likely you are running in cgi mode which is really slow because it has to load the entire framework into memory from disk on each requests. Also there is a huge difference between development and production mode. So you need to switch to production mode and verify your server config to make sure you are using fcgi instead of cgi. -Ezra>> >> * running in development mode instead of production mode > > Okey - that might be the problem. How do I ten go into production > mode? > I don''t have SSH-access, and uncommenting "ENV[''RAILS_ENV''] ||> ''production''" just kills my application with an error500 :( > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Instead of saying "slow," it would be helpful if you benchmarked the site, running in production mode on a server, not desktop machine. Most people use ab or httperf to find out how many requests/sec their site can serve. An average rails site in production mode with no caching enabled may serve as few as 20 r/s or as many as 120 r/s. If you begin to enable any of the caching features, your pages served increase dramatically. If you just did this rewrite, isn''t it a bit early to be worrying about performance? It sounds like you should research your deployment options. Many have been using lighttpd/fastcgi to serve dynamic content, but more and more, people are using Mongrel clusters. Note: Just because your phpinfo() says that mod_fcgi is installed does *not* mean you''ve set up rails to work with it. On Sunday, August 06, 2006, at 11:53 PM, Anders wrote:>I''m working on my first little rails-application. It''s a rewrite of a >gallery-script i once made (in PHP): http://notdotnet.net > >However - my rails-version is waaay to slow :( >http://r.notdotnet.net/ > >I don''t do any heavy image-processing, I don''t have any >killer-algorithms with a time complexity on O(n^n), and I don''t use any >major hacks. >The only "stupid" thing i really do is an "ORDER BY RAND()" on a table >with 8000 rows, which is quite heavy, but it shouldn''t take *that* long, >and i do the same in PHP which works fine. > >I then signed up for a new (free) webhost and installed my application >there to see if my host was the problem. It performs a bit better on the >free one, but is still really slow :/ >http://94383.hostmyapplications.com/ > >Since it don''t mind sharing the source code (nothing brilliant - just a >noobs first project =) you can get it here (no db-config file)): >http://94383.hostmyapplications.com/rails_slow.tar.gz (and if you like - >the database: http://94383.hostmyapplications.com/mysql.zip). > >Do you have *any* idea why i get such bad performance? > >thanks in advance. > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails-- Posted with http://DevLists.com. Sign up and save your mailbox.
> No that definitely does not mean that your rails app will just work > with fcgi.Right> It means more then likely you are running in cgi mode > which is really slow because it has to load the entire framework into > memory from disk on each requests. Also there is a huge difference > between development and production mode.Yes - I learned that now. Right now I''m running in production mode, and the speed is much better. However - I''m almostsure that I''m *not* running in fcgi mode. What I''m trying to figure out now is: 1) Can i setmy application up in fcgi mode (without talking to the support and get them to change something on the server). 2) If I can - how do i do it? As I said i changed "RewriteRule ^(.*)$ dispatch.cgi [QSA,L]" to "RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]" in my .htaccess-file. But that just resulted in that the server didn''t response, no errors - no logs. thanks in advance -- Posted via http://www.ruby-forum.com/.
Anders wrote:>> No that definitely does not mean that your rails app will just work >> with fcgi. >> > > Right > > >> It means more then likely you are running in cgi mode >> which is really slow because it has to load the entire framework into >> memory from disk on each requests. Also there is a huge difference >> between development and production mode. >> > > Yes - I learned that now. Right now I''m running in production mode, and > the speed is much better. > > However - I''m almostsure that I''m *not* running in fcgi mode. What I''m > trying to figure out now is: > > 1) Can i setmy application up in fcgi mode (without talking to the > support and get them to change something on the server). > > 2) If I can - how do i do it? > > As I said i changed "RewriteRule ^(.*)$ dispatch.cgi [QSA,L]" to > "RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]" in my .htaccess-file. But > that just resulted in that the server didn''t response, no errors - no > logs. > > thanks in advance > >It sounds like you need the appropriate apache config bits. Check out http://wiki.rubyonrails.com/rails/pages/FastCGI and http://wiki.rubyonrails.com/rails/pages/Debian+mod_fastcgi+Notes Here is my .htaccess snippet: ------------------------------------------------- AddHandler fcgid-script .fcgi AddHandler cgi-script .cgi Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] ErrorDocument 500 /500.html ------------------------------------------------- Here, is my httpd.conf snippet., it might work in .htaccess (replace the path with myrailsapp to reflect your setup): ------------------------------------------------- # configuration file for fast_cgi # needed for ruby on rails LoadModule fcgid_module modules/mod_fcgid.so <IfModule mod_fcgid.c> DefaultInitEnv RAILS_ENV production AddHandler fcgid-script .fcgi SocketPath /var/log/httpd/fcgidsock/ IdleTimeout 3600 ProcessLifeTime 7200 MaxProcessCount 8 DefaultMaxClassProcessCount 2 IPCConnectTimeout 8 IPCCommTimeout 60 DefaultInitEnv RAILS_ENV production <Directory /var/www/myrailsapp/current/public/> Options ExecCGI +FollowSymLinks AllowOverride All order allow,deny allow from all </Directory> </IfModule> -------------------------------------------------
steve ross wrote:> If you just did this rewrite, isn''t it a bit early to be worrying about > performance? It sounds like you should research your deployment options. > Many have been using lighttpd/fastcgi to serve dynamic content, but more > and more, people are using Mongrel clusters. >Running Mongrel with Apache? I''m frighteningly new to Rails (with about 6 months of Ruby) and have some really simple questions about Rails based on some past experiences I''ve had with other (perl) frameworks. First, how do you manage static pages? In another world I would just use Template under perl and build static HTML. Under perls HTML::Mason I would set the cache and have no refresh (or weekly). Is this essentially the approach you have under Rails -- cache for days?
On 8/8/06, Tom Allison <tallison@tacocat.net> wrote:> > steve ross wrote: > > > If you just did this rewrite, isn''t it a bit early to be worrying about > > performance? It sounds like you should research your deployment options. > > Many have been using lighttpd/fastcgi to serve dynamic content, but more > > and more, people are using Mongrel clusters. > > > > Running Mongrel with Apache? > > I''m frighteningly new to Rails (with about 6 months of Ruby) and have > some really simple questions about Rails based on some past experiences > I''ve had with other (perl) frameworks. > > First, how do you manage static pages? In another world I would just > use Template under perl and build static HTML. Under perls HTML::Mason > I would set the cache and have no refresh (or weekly). > Is this essentially the approach you have under Rails -- cache for days? > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >You can cache pages if you like. You can''t controller actions on that page tho. IMHO the caching options are quite flexible. At least, they''re flexible enough for me at the moment. http://api.rubyonrails.org/classes/ActionController/Caching.html Basically if rails finds a request with a document that exists under the public folder (or subfolder) it will serve it (or maybe the webserver does?). Otherwise it will look in routes and act accordingly. At least this is my understanding of it. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060808/a5f26fd4/attachment.html
You can use mod_proxy to forward given ports to your mongrels. You can use mongrel_cluster to start multiple mongrels at a time. Mongrel can serve static content, although I''m not sure what the efficiency of that is. Maybe Zed can weigh in on a good configuration. Tom Allison wrote:> > Running Mongrel with Apache? > > I''m frighteningly new to Rails (with about 6 months of Ruby) and have > some really simple questions about Rails based on some past experiences > I''ve had with other (perl) frameworks. > > First, how do you manage static pages? In another world I would just > use Template under perl and build static HTML. Under perls HTML::Mason > I would set the cache and have no refresh (or weekly). > Is this essentially the approach you have under Rails -- cache for days? >-- View this message in context: http://www.nabble.com/Rails-*that*-slow--tf2060663.html#a5710388 Sent from the RubyOnRails Users forum at Nabble.com.
I wasn''t planning on starting a cluster of application servers. I was just wondering what might be effective for splitting static and dynamic pages apart. But you mentioned mod_proxy as one way of getting speed which would be quite effective. I supposed lighttpd does not do this? On 8/8/2006, "s.ross" <cwdinfo@gmail.com> wrote:> >You can use mod_proxy to forward given ports to your mongrels. You can use >mongrel_cluster to start multiple mongrels at a time. Mongrel can serve >static content, although I''m not sure what the efficiency of that is. Maybe >Zed can weigh in on a good configuration. > > >Tom Allison wrote: >> >> Running Mongrel with Apache? >> >> I''m frighteningly new to Rails (with about 6 months of Ruby) and have >> some really simple questions about Rails based on some past experiences >> I''ve had with other (perl) frameworks. >> >> First, how do you manage static pages? In another world I would just >> use Template under perl and build static HTML. Under perls HTML::Mason >> I would set the cache and have no refresh (or weekly). >> Is this essentially the approach you have under Rails -- cache for days? >> >-- >View this message in context: http://www.nabble.com/Rails-*that*-slow--tf2060663.html#a5710388 >Sent from the RubyOnRails Users forum at Nabble.com. > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails >
Look at: http://blog.lighttpd.net/articles/2006/07/18/mod_proxy_core-commited-to-svn lighttpd does proxying as well. -- View this message in context: http://www.nabble.com/Rails-*that*-slow--tf2060663.html#a5714867 Sent from the RubyOnRails Users forum at Nabble.com.
> I wasn''t planning on starting a cluster of application servers. > I was just wondering what might be effective for splitting static and > dynamic pages apart. > > But you mentioned mod_proxy as one way of getting speed which would be > quite effective. I supposed lighttpd does not do this?I haven''t tried it, but I think in 1.5.0 it does... http://blog.lighttpd.net/articles/2006/07/15/the-new-mod_proxy_core> > On 8/8/2006, "s.ross" <cwdinfo@gmail.com> wrote: > >> >> You can use mod_proxy to forward given ports to your mongrels. You can use >> mongrel_cluster to start multiple mongrels at a time. Mongrel can serve >> static content, although I''m not sure what the efficiency of that is. Maybe >> Zed can weigh in on a good configuration. >> >> >> Tom Allison wrote: >>> >>> Running Mongrel with Apache? >>> >>> I''m frighteningly new to Rails (with about 6 months of Ruby) and have >>> some really simple questions about Rails based on some past experiences >>> I''ve had with other (perl) frameworks. >>> >>> First, how do you manage static pages? In another world I would just >>> use Template under perl and build static HTML. Under perls HTML::Mason >>> I would set the cache and have no refresh (or weekly). >>> Is this essentially the approach you have under Rails -- cache for days? >>> >> -- >> View this message in context: http://www.nabble.com/Rails-*that*-slow--tf2060663.html#a5710388 >> Sent from the RubyOnRails Users forum at Nabble.com. >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >