44
Rails Performance When, What and How Vitaly Kushner @vkushner

Performance - When, What and How

Embed Size (px)

Citation preview

Page 1: Performance - When, What and How

Rails PerformanceWhen, What and How

Vitaly Kushner@vkushner

Page 2: Performance - When, What and How

Vitaly Kushnerprogramming since middle 80sprofessionally since early 90s

Rails since 2005founded Astrails in 2008

Page 3: Performance - When, What and How

http://astrails.com/blog

Page 4: Performance - When, What and How

performance

Page 5: Performance - When, What and How

slowfor whatever reason

Page 6: Performance - When, What and How

performance

Page 7: Performance - When, What and How

performance

•raw speed

•throughput

•scalability

•end-user

Page 8: Performance - When, What and How

No timeto dive into details

Page 9: Performance - When, What and How

When to optimize?and when not to.

Page 10: Performance - When, What and How

what to do with 1M users

Page 11: Performance - When, What and How

Celebrate!you’ve made it.

Page 12: Performance - When, What and How

why startups fail?

Page 13: Performance - When, What and How

NOT because of performance problems

Page 14: Performance - When, What and How

1 million users

Page 15: Performance - When, What and How

first 1000 users!

Page 16: Performance - When, What and How

have scalability problem?

Page 17: Performance - When, What and How

GREAT!because it means you grow fast

Page 18: Performance - When, What and How

later

Page 19: Performance - When, What and How

Scalability Plan

•understand the limits

•know your next step

Page 20: Performance - When, What and How

performancedoes it matter?

Page 21: Performance - When, What and How

YES!performance is very important

Page 22: Performance - When, What and How

Is 1% a lot?yes, if you are Google.

Page 23: Performance - When, What and How

Why not to optimize anyway?

Page 24: Performance - When, What and How

time and budgetusually limited

Page 25: Performance - When, What and How

MeasureYou can not improve what you do not measure.

Page 26: Performance - When, What and How

Tools• Yahoo Yslow

http://developer.yahoo.com/yslow/

• Google PageSpeedhttps://developers.google.com/speed/pagespeed

• NewRelic - http://newrelic.com

• httperf & ab

• Blitz.io

Page 27: Performance - When, What and How

limit number of recordsfrom the database

Page 28: Performance - When, What and How

oinkhttps://github.com/noahd1/oink

Page 29: Performance - When, What and How

Instantiation Breakdown: Total: 14 | User: 4 | Experience: 3 | Location: 3 | Interest: 3 | Admin: 1

Page 30: Performance - When, What and How

limit number of queriesprevent 1+N queries problem

Page 31: Performance - When, What and How

bullethttps://github.com/flyerhzm/bullet

Page 32: Performance - When, What and How

N+1 Query detectedExperience => [:interest]Add to your finder: :include => [:interest]

Page 33: Performance - When, What and How

define indexescan be done later

Page 34: Performance - When, What and How

query_reviewerhttps://github.com/nesquena/query_reviewer

Page 35: Performance - When, What and How

limit number of http requestsconsolidate assets

assets pipeline makes it easy

Page 36: Performance - When, What and How

css at the topjs at the bottom

improves perceived page speed

Page 37: Performance - When, What and How

low level hacks

•replace :include with :join

•explicit :select

Page 38: Performance - When, What and How

not recommened

Page 39: Performance - When, What and How

Maintainabilityusually better then speed

Page 40: Performance - When, What and How

low hanging fruits

•compress and http cache assets

•CDN libraries

•image sprites

•bundle images into CSS

•CDN for all static assets

Page 41: Performance - When, What and How

Cachingmuch later

Page 42: Performance - When, What and How

real performance problem?

Page 43: Performance - When, What and How

next time...

Page 44: Performance - When, What and How

Thank you!Slides and video will be published at

http://astrails.com/blog

Vitaly Kushner@vkushner