Holy Crap, My Rails Site is Slow

Eh... not really how it works. First, the amount of client requests
only maps to the amount of Apache processes running when using the
prefork MPM. However, with the exception of fairly nasty
virtualization environments (like Virtuozzo), threaded MPMs give you
much more efficient resource usage. And even *then*, MPM selection and
configuration is a topic worthy of volumes of discussion on its own.

Also, linux is *fantastic* at being deceptive about process memory
usage. The %MEM column in top is fairly worthless when judging how
much memory Apache is really using... as is pretty much every
"default" tool. passenger-memory-stats is pretty good at this though!

And even *then* configuring memory limits is **highly** dependent on
your production environment's configuration. If you only have one
machine, than probably no one component (webserver, DB, mail, etc)
should be allowed to use over half your available memory. Things do
get when when you add multiple servers to the mix though

And even **then** all this server configuration milarky is the last
(chronological, not emphatically) thing you as the Rails developer
should be be worrying about. The first step to *any* optimization is
finding where the major bottlenecks in your app are. Newrelic is
indeed a great tool for that. Once you've found the major general
areas to work on, you'll need to break out the actual profiler (ruby-
prof is pretty good, unless you're using Ruby 1.9 :frowning: ) and actually
get dirty. This is where it is *vital* to have thorough test coverage,
else who knows what you'll mysteriously break when optimizing your
code. (and assuming your code is well structured and understandable to
begin with, don't be afraid of making it ugly to speed things up at
this point... thats why you write tests and "elegant" code in the
beginning).

Gah sooo much more to talk about here though, I guess someone else
will contribute more to this thread. At this point I guess I'll just
plug Enterprise Rails. Seemingly rushed execution aside, it is THE
absolute best Rails-geared book that currently exists in regards to
application structure and performance.

Good stuff. I have been following the scaling rails series and must
say, very very important for Rails developers.

The part about calculating the MaxClients for Apache --> It would be
great if inexperienced people like me could learn from someone who
would be gracious enough to explain how it can be done. When I went
through that part in the configuration file, it was rather obvious
there was some optimization to be done there but had no idea how to
arrive at the golden numbers. Anyone who could provide a good thorough
run down on how to optimize Apache?

Thanks again for starting this thread.