Upload
astrails
View
909
Download
0
Tags:
Embed Size (px)
Citation preview
Rails PerformanceWhen, What and How
Vitaly Kushner@vkushner
Vitaly Kushnerprogramming since middle 80sprofessionally since early 90s
Rails since 2005founded Astrails in 2008
performance
slowfor whatever reason
performance
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 of performance problems
1 million users
first 1000 users!
have scalability problem?
GREAT!because it means you grow fast
later
Scalability Plan
•understand the limits
•know your next step
performancedoes it matter?
YES!performance is very important
Is 1% a lot?yes, if you are Google.
Why not to optimize anyway?
time and budgetusually limited
MeasureYou can not improve what you do not measure.
Tools• Yahoo Yslow
http://developer.yahoo.com/yslow/
• Google PageSpeedhttps://developers.google.com/speed/pagespeed
• NewRelic - http://newrelic.com
• httperf & ab
• Blitz.io
limit number of recordsfrom the database
Instantiation Breakdown: Total: 14 | User: 4 | Experience: 3 | Location: 3 | Interest: 3 | Admin: 1
limit number of queriesprevent 1+N queries problem
bullethttps://github.com/flyerhzm/bullet
N+1 Query detectedExperience => [:interest]Add to your finder: :include => [:interest]
define indexescan be done later
query_reviewerhttps://github.com/nesquena/query_reviewer
limit number of http requestsconsolidate 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
not recommened
Maintainabilityusually better then speed
low hanging fruits
•compress and http cache assets
•CDN libraries
•image sprites
•bundle images into CSS
•CDN for all static assets
Cachingmuch later
real performance problem?
next time...
Thank you!Slides and video will be published at
http://astrails.com/blog
Vitaly Kushner@vkushner