By default, all requests coming from localhost will be run as CGI. This is great for development since the entire application will be reloaded every time, so any change is instant. It’s unusable for production, though, as each CGI request needs to establish a new interpreter and initialize all of Rails, which is pretty slow.
So you have three choices for production environments:
Have a look in config/httpd.conf to see how Rails route the different requests coming in to the different environments.
If you’re building a web-app that has some heavy-duty pages, or in general gets a good hammering, check out mod_cache for Apache. It has file-based and memory-based caching with configurable timeouts. Naturally caching should be used with caution, and beware of caching personalized content.
Q: What about using rails’ own ? — ScottMaclure
A: Rails’ caching is fast and stable, and unlike mod_cache, can be applied granularly, allowing personalized content on the same page as cached content. Rails’ caching can also be used with servers other than Apache, including WEBrick and Lighttpd. mod_cache and Rails’ caching are complementary technologies, and can be used in tandem.
Q: What about deploying a Rails application in an encrypted/obfuscated/bytecode/etc. format? Must the source code always be available?
A: There is nothing saying that you can’t deploy rails apps in an obfuscated manner (the Rails licence is MIT after all). However, I am unaware (September 2005) of automatic ruby/rails obfuscator or the ability to deploy compiled ruby bytecode. Besides what have you got to hide – your code can’t be that ugly ;) A2: Intellectual Property.
Q: What about WEBrick? Is it good for production?
A: WEBrick is not seen as being ideal for general production use. That being said, depending on the scale of your use, WEBrick may be an ideal solution. The thread webrick in production use? from ruby-talk might be of interest.
Q: Won’t install fastcgi or mod_ruby, calling the former too resource-intensive and the latter insecure. Rails seems pretty slow without any help. Is there anything else I/they can do for speed?
A: Yes. Change your provider – RailsWebHosts.
Q: What about Lighttpd? I hear of better performance using this with Rails – any chance of a HowTo? on setting it up with rails?
A: See the wikilink in the question
Q: How about some performance/tuning tips for a Rails installation?
A: OpenQuestion
Not An Answer: WRT improving the performance of your own code you can benchmark different methods to find the quickest and you can profile your code to find out where it’s spending its time.
Q: How about Mongrel?