Scaling Rails Applications in the Cloud
100 new users in < 2 hours
The hashtag for this talk is: #SX09-573
The Inevitable Mass Adoption of Our Product
A Typical Case Study
32 Public Beta
8 Techcrunch50 Me, Josh, and a few other people
Friends & Family
4
Private Beta
The Inexorable March of Time
I’m Mike Subelsky @subelsky / @otherinbox
What is Cloud Computing?
Solving problems across a flexible grid of nodes
...which you consume as a utility
The nodes are elastic
The nodes are loosely coupled Tasking System
Computing Instance
Computing Instance
Computing Instance
Permanent Storage
Computing Instance
The nodes are distributed
The nodes are ephemeral
The nodes are disposable
What are the benefits?
Lower cost Greater efficiency Greater flexibility
You want flexibility
Heady, Viral, Asymptomtotic Growth of Userbase
My Cloud Grows With Me!
32 Public Beta
8 Techcrunch50 Me, Josh, and a few other people
Friends & Family
4 The Blink of an Eye
Private Beta
What are the costs?
Some loss of control Potential for lock-in Greater complexity
You chose a language that sublimates complexity
aws-S3 RightAWS Ruby/EventMachine
Ruby Shines Here Hpricot memcache-client ActiveSupport
Capistrano Chef Rubber PoolParty Scalr Roll Your Own
What do you need to get started?
Tasking System
Computing Instance
Computing Instance
Computing Instance
Computing Instance
Permanent Storage
Bonus: Non-RDBMS
Our Sky SMTP
Sync
Staging Staging Staging Staging Staging Staging
Processing
Master DB
Staging Staging Staging Staging Staging Experiment
Workers
Web
Web Cloud Mongrels & Memcached
JSON
HTML
Apache
Atom
HAProxy
Mongrels & Memcached
Mongrels & Memcached
Message Bodies
Master DB
Mailbox Export Requests, Domain Registration
SQS
S3
Staging & Experiments
Sync Cloud
Autoscaling
SMTP Cloud o
t e am n ile rse F a S3 P
Ta s
kin
g
Fi
Mb
ox
bo x
w
M
Ra
MailReceiver le
MailSender
Fil
Ra w
Postfix
SQS
e
S3
MailParser
Master DB
Loose Coupling Is How I Sleep At Night US-EAST-1C
to
me a n ile rse F a S3 P
kin
g
MailParser
Master DB
MailParser
Master DB
Fi
ox
bo
x
Mb
M
Ra w
MailReceiver
le
MailSender
Fil
w
Postfix
Ta s
SQS
Ra
e S3
US-EAST-1B to
e am n e e Fil ars 3 P S
Ta s
kin
g
ox
bo x
Mb
M
Ra w
MailReceiver
Fi le
MailSender
Fil
Ra w
Postfix
SQS
e S3
Loose Coupling Is How I Sleep At Night US-EAST-1C
to
e am n e e Fil ars 3 P S
kin
g
MailParser
Master DB
Fi
ox
bo
x
Mb
M
Ra w
MailReceiver
le
MailSender
Fil
w
Postfix
Ta s
SQS
Ra
e S3
X XX US-EAST-1B
o
et m na ile rse F 3 Pa
SQS
Ta s
kin
g
S
ox
bo x
Mb
M
Ra w
MailReceiver
Fi le
MailSender
Fil
Ra w
Postfix
e
S3
MailParser
Master DB
Loose Coupling Is How I Sleep At Night US-EAST-1C
to
e am n e e Fil ars 3 P S
kin
g
MailParser
Fi
ox
bo
x
Mb
M
Ra w
MailReceiver
le
MailSender
Fil
w
Postfix
Ta s
SQS
Ra
e S3
US-EAST-1B o
et m na ile rse F 3 Pa
SQS
Ta s
kin
g
S
ox
bo x
Mb
M
Ra w
MailReceiver
Fi le
MailSender
Fil
Ra w
Postfix
e S3
MailParser
X X Master DB
Master DB
Loose Coupling Is How I Sleep At Night US-EAST-1C
to
e am n e e Fil ars 3 P S
g
MailReceiver
MailParser
Master DB
Fi
bo
M
Fil
Ra
e S3
US-EAST-1B o
et m na ile rse F 3 Pa
SQS
Ta s
kin
g
S
MailReceiver
Fi le
MailSender
M
ox
bo x
Mb
Fil
Ra w
Ra w
Master DB
x
Mb
ox
Postfix
MailParser
le
MailSender
Ra w
X X kin
w
Postfix
Ta s
SQS
e S3
Loose Coupling Is How I Sleep At Night MailSender
X X
MailReceiver
MailParser
Master DB
MailParser
Master DB
ox
bo
x
Mb
g
M
Ra w
kin
Fil
w
Postfix
Ta s
SQS
le
to
e am n e e Fil ars 3 P S
Fi
US-EAST-1C
Ra
e
S3
MailSender
Ra w
Mb
ox
kin
g
MailReceiver
Fi le
Postfix
Ta s
bo x
S
SQS
M
o
et m na ile rse F 3 Pa
Fil
Ra w
US-EAST-1B
e
S3
Loose Coupling Is How I Sleep At Night
What It Looks Like
Processing Cloud MessageParser h
us p s
ck a allb e c m ord lena c Re 3 fi e S ctiv
A
Message Created
MessageParsing Queue MessageClassfier Queue AnyFeatureWeWant Queue
Tasks MessageClassifier
AnyFeatureWorker
Workers • • • •
MessageExporter DailyUpdateSender RegistrationWorker BackupWorker
The Database Is a Single Point of Failure
How We Cope EBS Volume
Master DB
Hourly Snapshots
Weekly Dumps
Expensive Queries Memcached
A Dark But Illustrative Tale with QuickTime
Manual Stuff mkdir /vol mount /vol /dev/sdj sudo god start mysqld
Manual Stuff change database.yml by hand (yuck) queue mail to redeliver
(Wasted) Troubleshooting: 15 mins
Provisioning new database: 15 mins
If there was a next time...
(standard programmer optimism applies) < 10 minutes
Replication? Sharding?
Key-Value? Columns?
Logging gem
Splunk
Logging Good ol’ fashion tail
Hoptoad Dash
Zenoss
Slow query log
Monitoring RightScale Alertra
New Relic
Questions?
[email protected] @subelsky @otherinbox
Join our team Upgrade your job
Open Positions
• • • • •
• • •
Smart, fun people Startup environment Cutting edge tech Competitive pay Stock options
Ruby on Rails Developer Ruby on Rails Intern Product Manager
We pay $1,000 for successful referrals!
rate.sxsw.com
Thank you!