Fast Rails API

Here are the slides from my internal talk, which I recently gave for my colleagues.

They are showing the history of optimizing Rails API, starting from AR connections pool and ending by using Fragment caching. Also there is list of tools for profiling applications (stackprof, etc.). All techniques are quite famous.


What we’ve tried

  1. Connection pool
  2. Rails-api
  3. Do not load rails/all
  4. Establish DB connection after fork/new thread was created
  5. Unicorn worker killer
  6. Postgresql tuning
  7. Rails 4
  8. Ruby 2.1.0
  9. Fragment caching
  10. Active Model Serializers
  11. Oj
  12. Do not instantiate AR objects
  13. Try OOBGC - Out-of-Band GC
  14. Try different web server (e.g. Puma)

If we missed something, please share your ideas in comments.

Profiling tools

  1. Stackprof
  2. Rack Mini Profiler
  3. Bullet
  4. Request log analyzer
  5. NewRelic

On the penultimate slide is the title slide of the presentation of Max Lapshin, which briefly tells that to solve certain problems (such as when you need to keep a large number of clients) more appropriate solution might be using another technologies/languages (Erlang in particular).

UPD. Ideas from comments

  1. Try Conditional Get


comments powered by Disqus