Performance for RoR Apps
(some tips)
About Me
clairettran
Performance Is Important
Yay!
● AirBnb, Netflix, Twitter*, Facebook, Zynga
* Used to have outages, but fixed their perform...
Example Stats for SMH
At Peak: 28K requests per minute
14th May: 4,000,000 hits to the site
Some Common Problems
● Memory leaks
● Long running API call(s)
● Slow synchronous processes
(e.g. Emails, PayPal)
● Slow d...
What I’ll Cover
● Monitoring
● Caching
● Scaling
● Database
Monitoring
How to know there is a performance problem?
+ Response time, rpm, memory usage, CPU usage, error
rates
Monitoring
What else can I do?
● Logs (e.g. file server, splunk, loggly, logstash)
● Memory Usage (e.g. unix top command)
...
Caching
How?
● Cache store (key-value store)
● Fragment caching (part of
the page)
● SQL caching (cache query
results)
Rem...
Caching
Before: No Caching
After: With Caching!
Problem: Page making long running/many external requests
Scaling
Load Balancer
www.mysite.com
Cache Cluster
Cache
Static
Files
(css, js,
images)
Virtual IP
Replication(Active-Pass...
Database
● Add an index
● Profiling
● Batch queries
● Eager fetching
● Denormalisation
● Sharding
Other Techniques
● Queuing/Background Jobs
● Caching
● Dedicated services
● Rails engines
● C-extensions (gems)
● Sprites
...
Further Reading
https://github.com/ianheggie/health_check
http://guides.rubyonrails.org/caching_with_rails.html
http://rai...
Questions
WomenWhoCodeSydney_PerformanceTipsRoR
Upcoming SlideShare
Loading in …5
×

WomenWhoCodeSydney_PerformanceTipsRoR

236 views
155 views

Published on

This was a lightning talk presented at Women Who Code Sydney May 2014.

A look into some techniques that can be applied to RoR apps (and most apps in general) on how to improve performance. We'll be looking into scaling, caching and other methods to grow from a single server database app to bigger apps :)

Published in: Engineering, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
236
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
2
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

WomenWhoCodeSydney_PerformanceTipsRoR

  1. 1. Performance for RoR Apps (some tips)
  2. 2. About Me clairettran
  3. 3. Performance Is Important Yay! ● AirBnb, Netflix, Twitter*, Facebook, Zynga * Used to have outages, but fixed their performance issues ● Jetstar ticket sales Oops! ● Myer Boxing Day 2013 ● Click Frenzy 2012
  4. 4. Example Stats for SMH At Peak: 28K requests per minute 14th May: 4,000,000 hits to the site
  5. 5. Some Common Problems ● Memory leaks ● Long running API call(s) ● Slow synchronous processes (e.g. Emails, PayPal) ● Slow database queries ● Network issues Note: not an exhaustive list
  6. 6. What I’ll Cover ● Monitoring ● Caching ● Scaling ● Database
  7. 7. Monitoring How to know there is a performance problem? + Response time, rpm, memory usage, CPU usage, error rates
  8. 8. Monitoring What else can I do? ● Logs (e.g. file server, splunk, loggly, logstash) ● Memory Usage (e.g. unix top command) ● Performance tests (e.g. Apache bench, JMeter, Neoloader) ● Health Checks (e.g. health_check gem, Nagios, Sitescope) ● More calls to the call centre
  9. 9. Caching How? ● Cache store (key-value store) ● Fragment caching (part of the page) ● SQL caching (cache query results) Removed in Rails4: Action Caching & Fragment Caching
  10. 10. Caching Before: No Caching After: With Caching! Problem: Page making long running/many external requests
  11. 11. Scaling Load Balancer www.mysite.com Cache Cluster Cache Static Files (css, js, images) Virtual IP Replication(Active-Passive)
  12. 12. Database ● Add an index ● Profiling ● Batch queries ● Eager fetching ● Denormalisation ● Sharding
  13. 13. Other Techniques ● Queuing/Background Jobs ● Caching ● Dedicated services ● Rails engines ● C-extensions (gems) ● Sprites ● Asset pipeline ● Cache control headers ● Gzip assets ● Less HTTP requests ● Dedicated Search Service ● Remove unused assets (are all those bootstrap files needed?) ● Static cluster ● AWS Auto-scaling ● Akamai (edge caching) ● YSlow ● Local Storage ● Smaller Responses ● Async JS ● Chrome DevTools ● JRuby
  14. 14. Further Reading https://github.com/ianheggie/health_check http://guides.rubyonrails.org/caching_with_rails.html http://railscasts.com/episodes/380-memcached-dalli https://developers.google.com/events/io/sessions/324511365 http://railscasts.com/episodes/366-sidekiq http://www.slideshare.net/derekmbrown/netflix-strategic-performance- analysis http://blog.jphpsf.com/2012/04/28/front-end-performance-case-study-github
  15. 15. Questions

×