Scaling Rails for $5.50 per day - October 2014 ATLRUG Presentation

18
SCALING RAILS FOR $7 $5.50 A DAY Andy Slocum Atlanta Ruby User Group

description

Scaling Rails - October 2014 ATLRUG (Atlanta Ruby Users Group) Presentation - by Andy Slocum @ Thoughtworks

Transcript of Scaling Rails for $5.50 per day - October 2014 ATLRUG Presentation

Page 1: 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

Page 2: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

About Organizing Project Background Scaling Concerns Architecture Problems Successes Lessons Learned Recent Steps

Page 3: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

ONLINE ORGANIZING

Email lists rule everything

1000 emails 100 reads 10 visits 1 participant

Page 4: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

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

Page 5: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation
Page 6: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation
Page 7: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

SCALING CONCERNS

Page 8: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

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

Page 9: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

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

Page 10: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

ACTUAL PERFORMANCE

25k visitors / 70k page views 25% of traffic in 3 hours (checking time & location) Average visit: 1 minute

Page 11: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

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

Page 12: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

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

Page 13: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation
Page 14: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

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

Page 15: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

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

Page 16: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation
Page 17: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

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)

Page 18: Scaling Rails for $5.50 per day  - October 2014 ATLRUG Presentation

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