Hi All, I''ve been running into quite a few people who''ve claimed that they have Apache (or lighttpd) serving static files, but then they paste in error messages from Mongrel that shows not only Mongrel not serving the files, but Rails is serving them. Everyone using apache should run this very simple test: 1) Setup your apache so that it point at one backend. 2) Start your application with: mongrel_rails start -e production -B 3) Hit a a few static files of different types that should be served by apache. If you see messages like this: 127.0.0.1 - [Mon, 11 Sep 2006 22:09:31 GMT] "GET /index.html HTTP/1.1" 127.0.0.1 - [Mon, 11 Sep 2006 22:09:32 GMT] "GET /javascripts/prototype.js HTTP/1.1" 127.0.0.1 - [Mon, 11 Sep 2006 22:09:33 GMT] "GET /javascripts/effects.js HTTP/1.1" 127.0.0.1 - [Mon, 11 Sep 2006 22:09:34 GMT] "GET /images/rails.png HTTP/1.1" In the console where Mongrel is running then your Apache setup isn''t working and you''re getting nowhere near the performance you could be getting. If this is the case, please send me your mode_rewrite rules and any proxy directives **off list** and tell me where you got them. Thanks! -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
Matt Pelletier
2006-Sep-11 23:16 UTC
[Mongrel] Recommendation: Is Apache Really Serving Files?
On Sep 11, 2006, at 6:15 PM, Zed Shaw wrote:> Hi All, > > I''ve been running into quite a few people who''ve claimed that they > have > Apache (or lighttpd) serving static files, but then they paste in > error > messages from Mongrel that shows not only Mongrel not serving the > files, > but Rails is serving them. > > Everyone using apache should run this very simple test: > > 1) Setup your apache so that it point at one backend. > 2) Start your application with: mongrel_rails start -e production -B > 3) Hit a a few static files of different types that should be > served by > apache. > > If you see messages like this: > > 127.0.0.1 - [Mon, 11 Sep 2006 22:09:31 GMT] "GET /index.html HTTP/1.1" > 127.0.0.1 - [Mon, 11 Sep 2006 22:09:32 GMT] > "GET /javascripts/prototype.js HTTP/1.1" > 127.0.0.1 - [Mon, 11 Sep 2006 22:09:33 GMT] "GET /javascripts/ > effects.js > HTTP/1.1" > 127.0.0.1 - [Mon, 11 Sep 2006 22:09:34 GMT] "GET /images/rails.png > HTTP/1.1" > > In the console where Mongrel is running then your Apache setup isn''t > working and you''re getting nowhere near the performance you could be > getting.I also like running $curl -I (that''s a capital I as in India) (Hello Apache) $ curl -I http://somedomain.com/static/file/url/ HTTP/1.1 200 OK Date: Mon, 11 Sep 2006 23:13:05 GMT Server: Apache/2.2.3 (Unix) Last-Modified: Sun, 10 Sep 2006 18:21:52 GMT ETag: "21ac8f5-9d0a-83f57000" Accept-Ranges: bytes Content-Length: 40202 Vary: Accept-Encoding Connection: close Content-Type: text/html (Hello Mongrel) $ curl -I http://somedomain.com/go_to/rails/ HTTP/1.1 200 OK Date: Mon, 11 Sep 2006 23:13:10 GMT Server: Mongrel 0.3.13.4 Status: 200 OK Cache-Control: no-cache Content-Type: text/html; charset=utf-8 Vary: Accept-Encoding Connection: close> > If this is the case, please send me your mode_rewrite rules and any > proxy directives **off list** and tell me where you got them. > > Thanks! > > > -- > Zed A. Shaw > http://www.zedshaw.com/ > http://mongrel.rubyforge.org/ > http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help. > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >==================Matt Pelletier EastMedia t. 212-921-8413 x3# m. 917-902-2525 f. 212-239-4114 w. www.eastmedia.com
Charles Brian Quinn
2006-Sep-11 23:26 UTC
[Mongrel] Recommendation: Is Apache Really Serving Files?
So here''s another fun way to do it: jump on your app server: # ps auxww | grep mongrel find the processes, I''m running 5: root 13949 0.7 3.0 54188 30936 ? Sl 19:09 0:03 /usr/local/bin/ruby /usr/local/bin/mongrel_rails start -d -e production -p 8001 -a 127.0.0.1 -l /var/www/apps/xxxxx/current/log/mongrel.log -P /var/www/apps/xxxxx/current/log/mongrel.8001.pid -c /var/www/apps/xxxxx/current root 13954 0.8 3.5 60028 36464 ? Sl 19:09 0:03 /usr/local/bin/ruby /usr/local/bin/mongrel_rails start -d -e production -p 8002 -a 127.0.0.1 -l /var/www/apps/xxxxx/current/log/mongrel.log -P /var/www/apps/xxxxx/current/log/mongrel.8002.pid -c /var/www/apps/xxxxx/current root 13959 0.4 2.8 52612 29088 ? Sl 19:09 0:02 /usr/local/bin/ruby /usr/local/bin/mongrel_rails start -d -e production -p 8003 -a 127.0.0.1 -l /var/www/apps/xxxxx/current/log/mongrel.log -P /var/www/apps/xxxxx/current/log/mongrel.8003.pid -c /var/www/apps/xxxxx/current root 13963 0.7 4.2 68448 43768 ? Sl 19:09 0:03 /usr/local/bin/ruby /usr/local/bin/mongrel_rails start -d -e production -p 8004 -a 127.0.0.1 -l /var/www/apps/xxxxx/current/log/mongrel.log -P /var/www/apps/xxxxx/current/log/mongrel.8004.pid -c /var/www/apps/xxxxx/current root 13998 1.4 2.5 48740 25916 ? Sl 19:12 0:03 /usr/local/bin/ruby /usr/local/bin/mongrel_rails start -d -e production -p 8000 -a 127.0.0.1 -l /var/www/apps/xxxxx/current/log/mongrel.log -P /var/www/apps/xxxxx/current/log/mongrel.8000.pid -c /var/www/apps/xxxxx/current root 14043 0.0 0.0 4240 632 pts/0 R+ 19:16 0:00 grep mongrel now kill one (your users will love this if you''re live). copy that line first # kill -9 13998 and restart it erasing the -d (daemonize option) and adding -B # /usr/local/bin/ruby /usr/local/bin/mongrel_rails start -e production -p 8000 -a 127.0.0.1 -l /var/www/apps/xxxxx/current/log/mongrel.log -P /var/www/apps/xxxxx/current/log/mongrel.8000.pid -c /var/www/apps/xxxxx/current -B ** Starting Mongrel listening at 127.0.0.1:8000 It should start up, now on the command line, and you should see dynamic requests only: xx.xx.xx.xx - [Mon, 11 Sep 2006 23:17:05 GMT] "GET /messages?group=988 HTTP/1.1" xx.xx.xx.xx - [Mon, 11 Sep 2006 23:17:14 GMT] "GET /messages/list HTTP/1.1" xx.xx.xx.xx - [Mon, 11 Sep 2006 23:17:41 GMT] "GET /articles/show/172 HTTP/1.1" xx.xx.xx.xx, xx.xx.xx.xx - [Mon, 11 Sep 2006 23:19:56 GMT] "GET /articles/show/150 HTTP/1.1" If you are just running run mongrel_rails instance and proxy passing, I think we already established that apache is just forwarding on everything to mongrel, so that''s fine for testing (and fine if you just want apache to be a big ole request forwarding server), but you''ll need some apache kung-fu (adding Coda''s mod_rewrite rules) for not passing on static content to dirs. You''ll have to steal it from the advanced setup (until I can rewrite it and test those rules with the proxy pass settings): http://mongrel.rubyforge.org/docs/apache.html hope this helps, -- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.com