Performance

Rails API ?!$%#

by Guilherme Pereira

Problems

  • Rails can’t scale ?

What Success is?

Why it's slow?

  • Request Log Analyzer
  • Ruby-prof
  • New Relic (paid)

Simulation Tools ...

  • Siege

Rails API

# config/application.rb
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
# require "sprockets/railtie"
require "rails/test_unit/railtie"
  • Don't require rails/all

DB Common Problems

  • Ton of queries
decibel=# explain select * from customer where state='TX';
QUERY PLAN
----------------------------------------------------------------------------------
Index Scan using customer__state on customer (cost=0.00..5.96 rows=1 width=287)
Index Cond: (state = 'TX'::bpchar)
(2 rows)
  • Missing Indexes

DB Extras

  • Use DB extensions

HStore good example

 

1.7 million rows => 90 thousand rows !

  • Query Tracer

https://gist.github.com/guiferrpereira/83cb91a0e3f343af6a44

Cache

  • Rails Caching
  • Types
  • Expiring

Benchmark => https://github.com/guiferrpereira/blog

Frameworks && Languages

  • Sinatra is faster?
  • Go
  • ...

?

Request Log Analyzer

Ruby Prof

New Relic

deck

By guiferrpereira

deck

  • 396
Loading comments...

More from guiferrpereira