Scaling Spree
View Slide
Rendered spree/api/products/index.v1.rabl !in 1760.2ms
!cache @productapi/app/views/spree/api/products/show.v1.rabl
Rendered spree/api/products/index.v1.rabl !in 79.7ms22x faster!
DO: 2GB Droplet (SFO)Apache Bench (ab)Benchmarker
DO: 2GB Droplet (NYC)Spree: masterstock nginx + pumaTest 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.843.5x faster!!
Percentage of the requests served within acertain time (ms)!50% 6379!…!75% 10297!…!100% 25090 (longest request)
Percentage of the requests served within a certaintime (ms)!50% 6379!…!75% 10297!…!100% 25090 (longest request)
1 [|||||||||||||||||||||||||||||||||||||100.0%]2 [|||||||||||||||||||||||||||||||||||||100.0%]
DO: 32GBdroplet, 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.minutesapi/app/controllers/spree/products_controller.rb
!requests=1000, concurrency=500!!Requests per second: 529.19 [#/sec](mean)48x faster!!
!requests=1000, concurrency=500!!Requests per second: !1705.49155x faster!!
!requests=10000, concurrency=1000!!Requests per second: !1859169x faster!!
CACHEEXPIRY?!!1
Purge everythingPurge by keyPurge by URL
Purging by keyheaders[‘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