SlideShare a Scribd company logo
Real Life Rails Scaling
Agenda

• Scale your App	

• Scale your Team	

• Scale yourself
Nikon D5100
http://d5100.nikon-asia.com
Homepage
Features
Competition
Numbers
irb(main):001:0> Submission.count	

=> 179430	

irb(main):002:0> User.count	

=> 206546	

# du -sh public/system/	

24GB 	 public/system/
Tune your App
Infrastructure

• Use GIT & get a tool your team can use	

• GIT commit eMails	

• Google Docs for shared documents	

• Try to ban eMail (impossible...)
Monitoring

• Consider monitoring software	

• Find slow requests, slow queries etc	

• We used new relic RPM on a trial:	

    !


•
Deployment
• Staging system on the same server	

• Auto deploy to Staging on commit	

 • Useful when in 2+-part team	

• One command to deploy (cap deploy) to
  production	

• Full Root access == full fun
Server setup

• Database on a second server	

 • Direct link via private network	

• Shared storage via NFS possible, better if
  hosted via secondary nodes (asset host)	

• More RAM == more happy
HTML best practices
• Less code == better code	

 • Compact HTML markup	

• Compact CSS & JS	

• Short class names	

• Think: Every 1KB matters	

• Include JS per page only, not global
HTML tuning

• http://validator.w3.org/	

• http://developer.yahoo.com/yslow/	

• Rails 3.1: Asset pipeline for compression
Rails request tuning
• Think: Return to user as soon as possible	

• Think: Every request can block another	

• Don’t: Process images immediately	

• Don’t: Recalculate lists / caches in a request	

• Do: Use background jobs	

• Do: Set flags for further actions
Background processing

• Beanstalk is heavy for tons of requests, but
  great for real time	

• Consider cronjob for background tasks	

 • whenever gem
(Image-) File uploads

• Uploading images will take a while	

• Store image immediately & return	

• Create thumbnails later & in background	

• We used carrierwave & conditional
  versions
(Image-) File uploads
• Conditional versions are kick ass!
(Image-) File uploads
• One directory can only keep 32768 files...	

• Sharding: distribute files into subdirectories
                      Carrierwave rocks!
                      public/system/uploads/
 1/pic.jpg        2/pic.jpg   3/pic.jpg   4/pic.jpg    5/pic.jpg




                      public/system/uploads/
         2011-11-23                       2011-11-24

 1/pic.jpg        2/pic.jpg   3/pic.jpg   4/pic.jpg    5/pic.jpg
Facebook integration

• Before: fb_graph gem to read user photos	

• Problem: 1000 requests per minute &
  facebook blocks the access -> site down	

• Solved: fb connect JavaScript
Big data sets

• Identify key data	

• Fragment cache each

  item	

• Use JS for post-

  processing
Big data sets

Only select what is really needed	

Submission.accepted_submissions.select(latest_cols).where
(:is_photo_of_the_week => false).order(sort)	


latest_cols =
[:id, :user_id, :fb_count, :fb_count_en, :shard, :picture, :picture_is_landscape, :cr
eated_at, "TO_CHAR(submissions.updated_at, 'YYYYMMDDHH24MISS.US')
as updated_at"]
memcached


• Use it.
Tune your team
Communication

• Project plan	

• Communicate clear about bottlenecks	

 • Like eMail, server storage
GIT access to everyone


• Deploy to staging on each commit
Tune yourself
Your tools+
• Many good Rails blogs are blocked by GFW	

 • Get a non-free VPN	

• During an intense project, stuff comes up	

 • Create a delta file	

• Do testing and automate using a build
  server
Delta File
Podcasts

• Watch & apply:	

 • railscasts.com	

 • codeschool.com

More Related Content

PPTX
Polarbear recent windows 0day
PPTX
AWSを利用した開発者・データを扱う人向けの資料
PDF
DSpace UI prototype dsember
PDF
Scaling Django Apps using AWS Elastic Beanstalk
PDF
Breaking the Monolith - Microservice Extraction at SoundCloud
PPTX
Create or Modify Virtual system Patterns using IBM Cloud Orchestrator v2.5
PDF
ECS위에 Log Server 구축하기
PPTX
Sas 2015 event_driven
Polarbear recent windows 0day
AWSを利用した開発者・データを扱う人向けの資料
DSpace UI prototype dsember
Scaling Django Apps using AWS Elastic Beanstalk
Breaking the Monolith - Microservice Extraction at SoundCloud
Create or Modify Virtual system Patterns using IBM Cloud Orchestrator v2.5
ECS위에 Log Server 구축하기
Sas 2015 event_driven

What's hot (19)

PDF
Django in heavy load environment
PPT
DevOpsCon Cloud Workshop
PDF
Puppet and AWS: Getting the best of both worlds
PPTX
Debugging your Way through .NET with Visual Studio 2015
PDF
Git and Github - a 90 Minute interactive workshop
PPTX
Using Packer to Migrate XenServer Infrastructure to CloudStack
PPTX
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
PPTX
Scaling wix to over 70 m users
PPTX
MongoDB in the Clouds
PDF
10 minutes fun with Cloud API comparison
PPTX
Build public private cloud using openstack
PDF
Breaking the Monolith: Organizing Your Team to Embrace Microservices
PDF
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
PPTX
DevOps for Scala
PPTX
Integration-Monday-Terraform-Serverless
PDF
Five Years of EC2 Distilled
PPT
Stacktician - CloudStack Collab Conference 2014
PPTX
Practical advice on deployment and management of enterprise workloads
PDF
NSA - No thanks - Build your own cloud with OpenStack and Cloud Foundry | any...
Django in heavy load environment
DevOpsCon Cloud Workshop
Puppet and AWS: Getting the best of both worlds
Debugging your Way through .NET with Visual Studio 2015
Git and Github - a 90 Minute interactive workshop
Using Packer to Migrate XenServer Infrastructure to CloudStack
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
Scaling wix to over 70 m users
MongoDB in the Clouds
10 minutes fun with Cloud API comparison
Build public private cloud using openstack
Breaking the Monolith: Organizing Your Team to Embrace Microservices
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
DevOps for Scala
Integration-Monday-Terraform-Serverless
Five Years of EC2 Distilled
Stacktician - CloudStack Collab Conference 2014
Practical advice on deployment and management of enterprise workloads
NSA - No thanks - Build your own cloud with OpenStack and Cloud Foundry | any...
Ad

Similar to Rails scaling (20)

PDF
 Active Storage - Modern File Storage? 
PDF
GraphTour - Albelli: Running Neo4j on a large scale image platform
PPTX
Tuenti Release Workflow v1.1
KEY
DjangoCon 2010 Scaling Disqus
PPTX
Automated Data Synchronization: Data Loader, Data Mirror & Beyond
PPTX
Find a needle in Haystack: Facebook's storage system
PDF
Building Rich Internet Apps with Silverlight 2
KEY
Optimization of modern web applications
PDF
Using Riak for Events storage and analysis at Booking.com
PPTX
Providing Remote-yet-Restricted Access to Born-Digital Electronic Records (AE...
PPTX
BGOUG "Agile Data: revolutionizing database cloning'
PDF
John adams talk cloudy
PPTX
Four Practices to Fix Your Top .NET Performance Problems
KEY
Rails Performance Tricks and Treats
PPTX
Velocity NY 2013 - From Slow to Fast: Improving Performance on Intuit Website...
PDF
Chirp 2010: Scaling Twitter
PPT
performance.ppt
PPTX
Mobile and IBM Worklight Best Practices
PDF
Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011
PPTX
Tuenti Release Workflow
 Active Storage - Modern File Storage? 
GraphTour - Albelli: Running Neo4j on a large scale image platform
Tuenti Release Workflow v1.1
DjangoCon 2010 Scaling Disqus
Automated Data Synchronization: Data Loader, Data Mirror & Beyond
Find a needle in Haystack: Facebook's storage system
Building Rich Internet Apps with Silverlight 2
Optimization of modern web applications
Using Riak for Events storage and analysis at Booking.com
Providing Remote-yet-Restricted Access to Born-Digital Electronic Records (AE...
BGOUG "Agile Data: revolutionizing database cloning'
John adams talk cloudy
Four Practices to Fix Your Top .NET Performance Problems
Rails Performance Tricks and Treats
Velocity NY 2013 - From Slow to Fast: Improving Performance on Intuit Website...
Chirp 2010: Scaling Twitter
performance.ppt
Mobile and IBM Worklight Best Practices
Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011
Tuenti Release Workflow
Ad

Recently uploaded (20)

PPT
Geologic Time for studying geology for geologist
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PDF
August Patch Tuesday
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
Architecture types and enterprise applications.pdf
PDF
Five Habits of High-Impact Board Members
PDF
STKI Israel Market Study 2025 version august
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Modernising the Digital Integration Hub
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PPT
What is a Computer? Input Devices /output devices
PDF
1 - Historical Antecedents, Social Consideration.pdf
Geologic Time for studying geology for geologist
Taming the Chaos: How to Turn Unstructured Data into Decisions
Web Crawler for Trend Tracking Gen Z Insights.pptx
August Patch Tuesday
sustainability-14-14877-v2.pddhzftheheeeee
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
A contest of sentiment analysis: k-nearest neighbor versus neural network
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Architecture types and enterprise applications.pdf
Five Habits of High-Impact Board Members
STKI Israel Market Study 2025 version august
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Final SEM Unit 1 for mit wpu at pune .pptx
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Tartificialntelligence_presentation.pptx
Modernising the Digital Integration Hub
A novel scalable deep ensemble learning framework for big data classification...
O2C Customer Invoices to Receipt V15A.pptx
What is a Computer? Input Devices /output devices
1 - Historical Antecedents, Social Consideration.pdf

Rails scaling