Timing Rack Middlewares with metaprogramming, recursive monkey-patching, and a sprinkle of statistics
Analysing performance of your Rails or Sinatra is easy enough with New Relic,
but figuring out whether the soft outer shell of your stack is under-performing
is more of a challenge. We’ve written
rack-timer to figure things
The most typical tool Ruby web stacks use to monitor runtime performance is New
Relic. It does a great job at spotting what happens inside transaction, which
database queries are slow, etc. It also reports on something called queue
time, as the infamous green slab at the bottom of its graphs.
queue time it not request queuing: it’s the delay between when a requests hits
your web frontend (Apache, NGinx) and the beginning of your action. Thus, it
includes three things:
time spent in your HTTP dispatcher (Passenger, Unicorn)
time spent in your Rack middlewares
time spent in before/after_filters (if using Rails).
We had a hunch that something awry was going on in the outer layers of our
stack, and neither New Relic nor any beautiful gem gave us any intel.