While the agility of rails has never been questioned, its performance is often a hot issue.
DTrace is a very useful dynamic framework for analyzing application behavior provided by the Twitter team in the near future. In addition, Evan Weaver has developed a new tool, the Rails plug-in bleakhouse, to handle memory problems. One of the advantages of a dynamic language like Ruby is the ability of the introspect to check the state of your application inside the application, but you should pay more attention when using ObjectSpace (Ruby is garbage-collected object heap probes). Admittedly, Bleakhouse used ObjectSpace to take a snapshot of the rails application in the original version, but Evan Weaver found that ObjectSpace was not quantized: using objectspace would change its state.
Currently, Bleakhouse uses a leak-free C language implementation that uses the heap directly, with the advantage of drawing graphs (swap memory, real memory and combined memory) directly from the actual memory usage and run faster than before.
It can generate a reference chart by controller, action, and class.
Bleakhouse need to use gruff (so also use Rmagick). Because it is implemented in C, it also needs a patched Ruby binary to monitor the application. Once the plugin is installed and the environment is set to the product environment (Production), you can track your application. Finally, you can generate these graphs by running rake.
Figure 1
Figure 2
Figure 3
Bleakhouse reminded Charles Nutter about the fifth suggestion to make Ruby better: Throw objectspace aside, especially when people eventually have to be monitored by patching the VM:
Because of the limitations of Ruby's garbage collection mechanism and threading subsystem, ObjectSpace is harmful to Ruby and should be discarded.
Java has a lot of efficient heap analysis tools, and you might think, where are the Rprobe and Rprofiler for Ruby? I think that as time goes on, new VMs are introduced, and more companies are involved, and such tools will end up in front of people ...