scaling ruby for enterprise applications
DESCRIPTION
Ruby is a fantastic and fun language to program in, but is it ready for prime time? I will present ideas, tips, and tactics for scaling ruby applications to handle massive throughput based on real world examples. Enterprise architecture shouldn't fear ruby, they should embrace it.TRANSCRIPT
![Page 1: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/1.jpg)
Scaling Ruby for Scaling Ruby for Enterprise ApplicationsEnterprise ApplicationsMinneBar 2013MinneBar 2013
![Page 2: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/2.jpg)
by Joel by Joel Jensen and Jensen and John John MaloneMalone
![Page 3: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/3.jpg)
ProfilingProfiling
DatabasesDatabases
QueuesQueues
ToolsTools
TestingTesting
Legacy CodeLegacy Code
MentalityMentality
State on the WireState on the Wire
Server ScalingServer Scaling
Lessons LearnedLessons Learned
Throughput IncreaseThroughput Increase
Vertical ScalingVertical Scaling
How we got there...How we got there...
![Page 4: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/4.jpg)
Best Buy Epic AppBest Buy Epic App
![Page 5: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/5.jpg)
TopologyTopology
![Page 6: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/6.jpg)
ProfilingProfilingNew Relic is our weapon of choice.New Relic is our weapon of choice.
![Page 7: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/7.jpg)
Stuff we usedStuff we used
Thread profilingThread profiling
Monitoring DaemonsMonitoring Daemons
Custom Custom instrumentationinstrumentation
Developer ModeDeveloper Mode
Deployment eventsDeployment events
Slow query logSlow query log
![Page 8: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/8.jpg)
Developer ModeDeveloper Mode
![Page 9: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/9.jpg)
Developer ModeDeveloper ModeQuery profilingQuery profiling
![Page 10: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/10.jpg)
MongoDBMongoDB
+Drivers of our language of choice+Drivers of our language of choice
+Speed+Speed
+Flexibility+Flexibility
+Partition Tolerance+Partition Tolerance
+Availability+Availability
-Consistency-Consistency
DatabasesDatabases
![Page 11: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/11.jpg)
MysqlMysql
+Drivers for our language+Drivers for our language
-Flexibility-Flexibility
+Consistency+Consistency
DatabasesDatabases
![Page 12: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/12.jpg)
CAP theoremCAP theorem
![Page 13: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/13.jpg)
QueuesQueues
![Page 14: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/14.jpg)
0MQ0MQ+Speed (fastest you +Speed (fastest you can get)can get)
+Very simple +Very simple design, great for design, great for complex systemscomplex systems
+Drivers in all major +Drivers in all major languageslanguages
-Hard to use-Hard to use
-Poor drivers-Poor drivers
-No UI-No UI
![Page 15: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/15.jpg)
RabbitMQRabbitMQ
+Speed+Speed
+Great web based +Great web based UIUI
Drivers in all major Drivers in all major languageslanguages
![Page 16: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/16.jpg)
ToolsTools
ChefChef
Automated, Automated, scripted server scripted server provisioningprovisioning
Crucial for Crucial for modern systemsmodern systems
![Page 17: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/17.jpg)
TestingTesting
Integration test is the MOST important for usIntegration test is the MOST important for us
Automate huge batchesAutomate huge batches
Automate your metricsAutomate your metrics
Test with real dataTest with real data
Rspec and CucumberRspec and Cucumber
![Page 18: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/18.jpg)
Legacy Legacy CodeCode
![Page 19: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/19.jpg)
MentalityMentality
![Page 20: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/20.jpg)
Hack the PlanetHack the Planet
Be a hacker (ala Be a hacker (ala hackers and painters)hackers and painters)
You are allowed to failYou are allowed to fail
DRYDRY
Abstraction Abstraction everywhereeverywhere
TestsTests
No burnoutsNo burnouts
![Page 21: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/21.jpg)
Component ArchitectureComponent ArchitectureBefore State on the WireBefore State on the Wire
![Page 22: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/22.jpg)
State on the WireState on the Wire
Beat the ClockBeat the Clock
Component => Input data, work on it, save it, Component => Input data, work on it, save it, enqueueenqueue
Atomic Units of WorkAtomic Units of Work
Design of latency, serialize the messageDesign of latency, serialize the message
Minimize database writesMinimize database writes
Daemons gemDaemons gem
![Page 23: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/23.jpg)
Component ArchitectureComponent ArchitectureAfter State on the WireAfter State on the Wire
![Page 24: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/24.jpg)
State on the Wire State on the Wire ImprovementsImprovements
60% increase in throughput60% increase in throughput
90% decrease in database I/O90% decrease in database I/O
85% decrease in database size85% decrease in database size
![Page 25: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/25.jpg)
Vertical ScalingVertical Scalingec2instances.infoec2instances.info
![Page 26: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/26.jpg)
Throwing hardware at Throwing hardware at the problemthe problem
Needed solid profilingNeeded solid profiling
Realized we were running our CPU hotRealized we were running our CPU hot
Moved the Epic subsystem onto a High CPU Moved the Epic subsystem onto a High CPU instanceinstance
Moved Bouncer subsystem onto a High Moved Bouncer subsystem onto a High Memory instanceMemory instance
![Page 27: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/27.jpg)
Vertical Scaling Vertical Scaling ContinuedContinued
8 cores were now put into play8 cores were now put into play
200% increase in throughput200% increase in throughput
Daemons began autoscalingDaemons began autoscaling
Leave a core for your OSLeave a core for your OS
![Page 28: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/28.jpg)
Horizontal ScalingHorizontal Scaling
Componentized architecture allows us to throw Componentized architecture allows us to throw more machines at the problemmore machines at the problem
Future state - autoscaling based upon queue Future state - autoscaling based upon queue lengthlength
Chef stands machines up and down based on Chef stands machines up and down based on CloudWatch queue length monitoringCloudWatch queue length monitoring
![Page 29: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/29.jpg)
Lessons LearnedLessons Learned
You can’t improve what You can’t improve what you can’t measureyou can’t measure
Install good monitoring Install good monitoring and alertingand alerting
Don’t ask for Don’t ask for permissionpermission
Say no to premature Say no to premature optimizationoptimization
1 million operations a 1 million operations a day means 12 ops per day means 12 ops per secondsecond
![Page 30: Scaling Ruby for Enterprise Applications](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480a5a6b4af9f203d8b45d8/html5/thumbnails/30.jpg)
Thank YouThank YouAaron GaalswykAaron Gaalswyk
Anjali RamanAnjali Raman
Arun BatchuArun Batchu
Arvind NaikArvind Naik
Carl MuellerCarl Mueller
Chad SearsChad Sears
Geoff LoryGeoff Lory
Jayaraj SomasekharanJayaraj Somasekharan
John MurphyJohn Murphy
Josh FribergJosh Friberg
Kevin MathenyKevin Matheny
Laurie HeavierLaurie Heavier
Logan PoelhmanLogan Poelhman
Lynette LinamanLynette Linaman
Mike HelferMike Helfer
Mohit PadalkarMohit Padalkar
Niyaz AhamedNiyaz Ahamed
Shelley BerubeShelley Berube
Trent OgrenTrent Ogren
Yury GavrikYury Gavrik