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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Ryan Bigg
February 27, 2014
Programming
190
0
Share
Scaling Spree's API
Ryan Bigg
February 27, 2014
More Decks by Ryan Bigg
See All by Ryan Bigg
Hiring Juniors - RubyConf Indonesia 2019 Closing Keynote
radar
1
450
Web Directions - Code Leaders - Hiring Juniors
radar
0
680
The Future of Rails - Take 2
radar
0
140
The Future of Rails
radar
1
140
Exploding Rails
radar
9
1.9k
Hiring Juniors
radar
2
470
The Perfect Coding Test
radar
0
140
Your First Developer Job
radar
1
120
Hiring Juniors
radar
2
290
Other Decks in Programming
See All in Programming
AI時代の脳疲弊と向き合う ~言語学としてのPHP~
sakuraikotone
1
1.9k
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
770
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
390
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
570
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
0
120
Codex CLI でつくる、Issue から merge までの開発フロー
amata1219
0
350
Radical Imagining - LIFT 2025-2027 Policy Agenda
lift1998
0
260
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
580
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
250
의존성 주입과 모듈화
fornewid
0
130
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
9
5.6k
安いハードウェアでVulkan
fadis
1
960
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Balancing Empowerment & Direction
lara
6
1k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Fireside Chat
paigeccino
42
3.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
Docker and Python
trallard
47
3.8k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
720
Typedesign – Prime Four
hannesfritz
42
3k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
We Are The Robots
honzajavorek
0
210
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
520
Agile that works and the tools we love
rasmusluckow
331
21k
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