Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Scaling Spree's API
Search
Ryan Bigg
February 27, 2014
Programming
0
170
Scaling Spree's API
Ryan Bigg
February 27, 2014
Tweet
Share
More Decks by Ryan Bigg
See All by Ryan Bigg
Hiring Juniors - RubyConf Indonesia 2019 Closing Keynote
radar
1
350
Web Directions - Code Leaders - Hiring Juniors
radar
0
480
The Future of Rails - Take 2
radar
0
93
The Future of Rails
radar
1
100
Exploding Rails
radar
9
1.8k
Hiring Juniors
radar
2
400
The Perfect Coding Test
radar
0
110
Your First Developer Job
radar
1
100
Hiring Juniors
radar
2
260
Other Decks in Programming
See All in Programming
Swiftコードバトル必勝法
toshi0383
0
170
Method Swizzlingを行うライブラリにおけるマルチモジュール設計
yoshikma
0
120
Rechartsで楽にゴリゴリにカスタマイズする!
10tera
1
170
Shinjuku.rb#95:心の技術書紹介
free_world21
1
110
Prompt Cachingは本当に効果的なのか検証してみた.pdf
ttnyt8701
0
530
GraphQLの魅力を引き出すAndroidクライアント実装
morux2
3
660
Crafting Cross-Platform Adventures: Building a Game Engine with Kotlin Multiplatform
dwursteisen
0
120
Scala アプリケーションのビルドを改善してデプロイ時間を 1/4 にした話 | How I improved the build of my Scala application and reduced deployment time by 4x
nomadblacky
1
180
Securify_エンジニア採用資料
3shake
0
100
rbs-inlineを導入してYARDからRBSに移行する
euglena1215
1
290
エンジニア1年目で複雑なコードの改善に取り組んだ話
mtnmr
3
2k
Lessons by WebAssembly app in production on CDN Edge Computing Service
tetsuharuohzeki
0
210
Featured
See All Featured
Six Lessons from altMBA
skipperchong
26
3.4k
Debugging Ruby Performance
tmm1
72
12k
How to name files
jennybc
75
98k
Making the Leap to Tech Lead
cromwellryan
128
8.8k
GraphQLの誤解/rethinking-graphql
sonatard
65
9.8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
Pencils Down: Stop Designing & Start Developing
hursman
119
11k
Become a Pro
speakerdeck
PRO
22
4.9k
Designing for Performance
lara
604
68k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
354
29k
The Straight Up "How To Draw Better" Workshop
denniskardys
230
130k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
29
2.6k
Transcript
Scaling Spree
None
Rendered spree/api/products/index.v1.rabl ! in 1760.2ms
! cache @product api/app/views/spree/api/products/show.v1.rabl
Rendered spree/api/products/index.v1.rabl ! in 79.7ms 22x faster!
None
DO: 2GB Droplet (SFO) Apache Bench (ab) Benchmarker
DO: 2GB Droplet (NYC) Spree: master stock nginx + puma
Test Server
requests=1000, concurrency=50! ! Requests per second: 11.38
requests=10000,! concurrency=500! ! Requests per second: N/A! Load average: 26.14!
DO: 4GB droplet! ! Requests per second: N/A! Total of
33 requests completed!
nginx sez:! ”512 worker_connections not enough"
! *Google for "nginx worker_connections"* ! ! events {! worker_connections
19000;! }! ! worker_rlimit_nofile 20000;
! requests=1000, concurrency=500! ! Requests per second: 39.84 3.5x faster!!
Percentage of the requests served within a certain time (ms)!
50% 6379! …! 75% 10297! …! 100% 25090 (longest request)
Percentage of the requests served within a certain time (ms)!
50% 6379! …! 75% 10297! …! 100% 25090 (longest request)
1 [|||||||||||||||||||||||||||||||||||||100.0%] 2 [|||||||||||||||||||||||||||||||||||||100.0%]
DO: 32GB droplet, 12 cores!
39 req/s x 6?! 2 cores => 12 cores! ~10x
faster?!
! requests=1000, concurrency=500! ! Requests per second: 58.84 [#/sec] (mean)
5.2x faster!!
! expires_in 3.minutes api/app/controllers/spree/products_controller.rb
None
! requests=1000, concurrency=500! ! Requests per second: 529.19 [#/sec] (mean)
48x faster!!
None
! requests=1000, concurrency=500! ! Requests per second: ! 1705.49 155x
faster!!
! requests=10000, concurrency=1000! ! Requests per second: ! 1859 169x
faster!!
CACHE EXPIRY?! !1
None
Purge everything Purge by key Purge by URL
Purging by key headers[‘Surrogate-Key’] = “product_id=1” headers[‘Surrogate-Key’] =! “product_id=1 taxon_id=1
taxon_id=2”! !
Purging URLs /api/products! ! /products/ruby-on-rails-tote