Scaling Rails for $5.50 per day - October 2014 ATLRUG Presentation
description
Transcript of Scaling Rails for $5.50 per day - October 2014 ATLRUG Presentation
SCALING RAILS FOR $7 $5.50 A DAY
Andy Slocum
A t l a n t a R u b y U s e r G r o u p
About Organizing Project Background Scaling Concerns Architecture Problems Successes Lessons Learned Recent Steps
ONLINE ORGANIZING
Email lists rule everything
1000 emails 100 reads 10 visits 1 participant
PROJECT BACKGROUND
One week campaign 2 full-time organizers 4 developers 1 analyst 1 domain expert 3 months development time Few days of UX expert’s time
SCALING CONCERNS
ARCHITECTURE
Ruby 2 Rails 4 MongoDB Amazon CloudFront Heroku Geocoder + free zip code data Memcache (25Mb) Mailgun github -> snap-ci -> heroku NewRelic + google analytics Omniauth Gatling
Rails (puma)
Amazon Cloudfront
Mongo
Memcache
Mailgun
Snap-ci +
Github
PERFORMANCE TUNING & PREDICTION
prod error rate mean response 95% response 99% response rps
1: 2xdyno 100 users 0% 931 2570 7980 38
500 users 11% 4515 30120 31660 57
5: 2xdyno 150 users 0% 1197 3230 5110 55
500 users 9% 5236 30150 30600 54
5: 2xdyno 500 users cold 1% 7605 32890 60000 44
geo_near caching 500 users hot 0% 2181 9990 25740 72
ACTUAL PERFORMANCE
25k visitors / 70k page views 25% of traffic in 3 hours (checking time & location) Average visit: 1 minute
PROBLEMS
Mongo support in Rails 4 Cache invalidation Unused functionality Google maps API free tier Organizations wanted data we weren’t set up to provide Organizers needed to take notes on users / events Mobile
SUCCESSES
News coverage ~50 rallies organized + ~70 rallies advertised International reach Handled the load Using Geocoder with free zip data Adapt quickly to new problems Clean UX
COSTS
Monthly: Github - $7.00 Heroku - $124.74 (2 dynos, mongo)
CDN Traffic: AWS - $8.93 (50 GB data + 4M requests) (7+125)/30 + 9/7 ~= $5.50
LESSONS LEARNED
Mobile is a first-class concern (30% of traffic) Validate external resources before deployment (mailgun) Prepare to share / export data Ask more questions of your expert users Don’t gold plate your performance tuning Focus on optimizing & polishing the first 2 pages
GOING FARTHER
OpenStreetMap NewRelic monitoring + Heroku memory limit (512MB) workers Integer(ENV['PUMA_WORKERS'] || 3) threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16)
THANKS TO
Mike G. Susan H. Kyle de B. Tim M. Zack E. Louis K.
QUESTIONS?
cwilk Rosemary K. P. Turley Svetlana I. Robin D.
[email protected] / @andyflip