Successfully reported this slideshow.
Our presentation on Israel Rails Conference 2012. Vitaly talking about rails performance, how to measure, what to improve and just as much important - what not to improve
Rails Performance When, What and How Vitaly Kushner @vkushner
Vitaly Kushnerprogramming since middle 80s professionally since early 90s Rails since 2005 founded Astrails in 2008
slowfor whatever reason
performance• raw speed• throughput• scalability• end-user
No timeto dive into details
When to optimize? and when not to.
what to do with 1M users
Celebrate! you’ve made it.
why startups fail?
NOT because ofperformance problems
1 million users
ﬁrst 1000 users!
have scalability problem?
GREAT!because it means you grow fast
Scalability Plan• understand the limits• know your next step
performance does it matter?
YES!performance is very important
Is 1% a lot?yes, if you are Google.
Why not to optimize anyway?
time and budget usually limited
MeasureYou can not improve what you do not measure.
Tools• Yahoo Yslow http://developer.yahoo.com/yslow/• Google PageSpeed https://developers.google.com/speed/pagespeed• NewRelic - http://newrelic.com• httperf & ab• Blitz.io
limit number of records from the database
Instantiation Breakdown: Total: 14 |User: 4 | Experience: 3 | Location: 3 |Interest: 3 | Admin: 1
limit number of queries prevent 1+N queries problem
N+1 Query detectedExperience => [:interest]Add to your finder: :include => [:interest]
deﬁne indexes can be done later
limit number of http requests consolidate assets assets pipeline makes it easy
css at the topjs at the bottom improves perceived page speed
low level hacks• replace :include with :join• explicit :select
Maintainability usually better then speed
low hanging fruits• compress and http cache assets• CDN libraries• image sprites• bundle images into CSS• CDN for all static assets
Caching much later
real performance problem?
Thank you!Slides and video will be published at http://astrails.com/blog Vitaly Kushner @vkushner