SlideShare a Scribd company logo
1 of 23
Download to read offline
Lessons Learned
    while building
or...




How To Run Your Big
App on One Server
                AndAHalf
Menno van der Sman
    Developer at Wakoopa
       since May 2007
Wakoopa is about
   software
PC           Mac




     Linux
200
 GB
Does it scale?
Scaling the front is easy
Scaling the back is
      harder
Limits spawn creativity
Servers
         at Railsmachine


16GB RAM              5GB RAM
 8 Cores               4 Cores

 dedicated              shared
  staging              archiving
production
 database
or...




Keeping Your Database
        Happy
Queuing
processing multiple items at a time


      efficient cache update


   DelayedJob for anything else
Smart queries
    UPDATE developers SET active_seconds = active_seconds + ...


INSERT INTO hourly_usage (...) VALUES (...) ON DUPLICATE KEY UPDATE
  active_seconds = active_seconds + ..., idle_seconds = idle_seconds + ...



                     Allows for concurrency
Aim for a Small Rowsize

    choose a correct datatype
      pick the right indexes

sometimes `id` shouldn’t be the PK
composite_primary_keys

  Allows efficient PK
      class HourlyUsage < ActiveRecord::Base
        set_primary_keys :user_id, :software_id, :used_at

        ...
      end




        Original implementation by Dr Nic
            Maintained by Darrin Holst
http://github.com/drnic/composite_primary_keys
Archive old data
                that’s not frequently used



  SELECT ... FROM hourly_usage WHERE used_at < '...' INTO OUTFILE '/path/to/file'

LOAD DATA LOCAL INFILE '/path/to/file' REPLACE INTO TABLE hourly_usage_storage




                        avoids long locks
Alternative solution
                Partitioning
     CREATE TABLE hourly_usage_storage ( ... )
     PARTITION BY RANGE (software_id) (
        PARTITION p0 VALUES LESS THAN (...),
        PARTITION p1 VALUES LESS THAN (...),
        PARTITION p2 VALUES LESS THAN (...),
        PARTITION p3 VALUES LESS THAN (...),
        ....
        PARTITION pn VALUES LESS THAN MAXVALUE
     );


  Makes ‘WHERE software_id = ...’ very fast


          Didn’t work for us
Other Techologies
       Rails 2.3
       Apache
      Passenger
      REE 1.8.7
      MySQL 5.0
     Memcached
        Sphinx
     Amazon EC2
Our REE settings
#!/bin/sh
RUBY_HEAP_MIN_SLOTS=500000
RUBY_HEAP_SLOTS_INCREMENT=250000
RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
RUBY_GC_MALLOC_LIMIT=50000000
exec "/opt/ruby-enterprise/bin/ruby" "$@"
Questions?
 or suggestions?
Ams.rb Oktober

More Related Content

What's hot

Setting Up Amazon EC2 server
Setting Up Amazon EC2 serverSetting Up Amazon EC2 server
Setting Up Amazon EC2 server
Tahsin Hasan
 

What's hot (20)

DevOps with Ansible
DevOps with AnsibleDevOps with Ansible
DevOps with Ansible
 
Webinar AWS für Unternehmen Teil 3: Disaster Recovery
Webinar AWS für Unternehmen Teil 3: Disaster RecoveryWebinar AWS für Unternehmen Teil 3: Disaster Recovery
Webinar AWS für Unternehmen Teil 3: Disaster Recovery
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Scalr Demo
Scalr DemoScalr Demo
Scalr Demo
 
Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
 
Deep Dive: Amazon Redshift (March 2017)
Deep Dive: Amazon Redshift (March 2017)Deep Dive: Amazon Redshift (March 2017)
Deep Dive: Amazon Redshift (March 2017)
 
Advance discussion on Ansible - Rahul Inti
Advance discussion on Ansible - Rahul IntiAdvance discussion on Ansible - Rahul Inti
Advance discussion on Ansible - Rahul Inti
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil Davawala
 
DynamoDB for PHP sessions
DynamoDB for PHP sessionsDynamoDB for PHP sessions
DynamoDB for PHP sessions
 
Ansible Hands On
Ansible Hands OnAnsible Hands On
Ansible Hands On
 
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
 
AWS case study: real estate portal
AWS case study: real estate portalAWS case study: real estate portal
AWS case study: real estate portal
 
Terraform + ansible talk
Terraform + ansible talkTerraform + ansible talk
Terraform + ansible talk
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011
 
infra-as-code
infra-as-codeinfra-as-code
infra-as-code
 
How to Upgrade Your Database Plan on Heroku and Rails Setup?
How to Upgrade Your Database Plan on Heroku and Rails Setup?How to Upgrade Your Database Plan on Heroku and Rails Setup?
How to Upgrade Your Database Plan on Heroku and Rails Setup?
 
Programatically getting stock data with R
Programatically getting stock data with RProgramatically getting stock data with R
Programatically getting stock data with R
 
Setting Up Amazon EC2 server
Setting Up Amazon EC2 serverSetting Up Amazon EC2 server
Setting Up Amazon EC2 server
 

Viewers also liked

El Viol.Loncel Magic2
El Viol.Loncel Magic2El Viol.Loncel Magic2
El Viol.Loncel Magic2
a8002231
 
Motörhead
MotörheadMotörhead
Motörhead
EirikVR
 
Nuevos Escenarios: tecnología, cultura y subjetividad
Nuevos Escenarios: tecnología, cultura y subjetividadNuevos Escenarios: tecnología, cultura y subjetividad
Nuevos Escenarios: tecnología, cultura y subjetividad
DaliaGut
 
Talle rtic s
Talle rtic sTalle rtic s
Talle rtic s
Anel Sosa
 

Viewers also liked (18)

Introduction to Rails
Introduction to RailsIntroduction to Rails
Introduction to Rails
 
Wakoopa Recommendation Engine on AWS
Wakoopa Recommendation Engine on AWSWakoopa Recommendation Engine on AWS
Wakoopa Recommendation Engine on AWS
 
El Viol.Loncel Magic2
El Viol.Loncel Magic2El Viol.Loncel Magic2
El Viol.Loncel Magic2
 
育英國中校園資訊環境簡介
育英國中校園資訊環境簡介育英國中校園資訊環境簡介
育英國中校園資訊環境簡介
 
A Kirkbride visual CV 2013
A Kirkbride visual CV 2013A Kirkbride visual CV 2013
A Kirkbride visual CV 2013
 
7 phases of pain
7 phases of pain7 phases of pain
7 phases of pain
 
Motörhead
MotörheadMotörhead
Motörhead
 
When Change Fails
When Change FailsWhen Change Fails
When Change Fails
 
Jaja
JajaJaja
Jaja
 
Juan
JuanJuan
Juan
 
部落格
部落格部落格
部落格
 
Nuevos Escenarios: tecnología, cultura y subjetividad
Nuevos Escenarios: tecnología, cultura y subjetividadNuevos Escenarios: tecnología, cultura y subjetividad
Nuevos Escenarios: tecnología, cultura y subjetividad
 
Presentación1
Presentación1Presentación1
Presentación1
 
Talle rtic s
Talle rtic sTalle rtic s
Talle rtic s
 
Talle rtic s
Talle rtic sTalle rtic s
Talle rtic s
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media Plan
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 

Similar to Ams.rb Oktober

Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 

Similar to Ams.rb Oktober (20)

Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 
How to deploy & optimize eZ Publish
How to deploy & optimize eZ PublishHow to deploy & optimize eZ Publish
How to deploy & optimize eZ Publish
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
 
Puppet for Sys Admins
Puppet for Sys AdminsPuppet for Sys Admins
Puppet for Sys Admins
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
 
Zend Server Data Caching
Zend Server Data CachingZend Server Data Caching
Zend Server Data Caching
 
Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!
 
Extending DevOps to Big Data Applications with Kubernetes
Extending DevOps to Big Data Applications with KubernetesExtending DevOps to Big Data Applications with Kubernetes
Extending DevOps to Big Data Applications with Kubernetes
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010
 
IaC and Immutable Infrastructure with Terraform, Сергей Марченко
IaC and Immutable Infrastructure with Terraform, Сергей МарченкоIaC and Immutable Infrastructure with Terraform, Сергей Марченко
IaC and Immutable Infrastructure with Terraform, Сергей Марченко
 
Java ee7 with apache spark for the world's largest credit card core systems, ...
Java ee7 with apache spark for the world's largest credit card core systems, ...Java ee7 with apache spark for the world's largest credit card core systems, ...
Java ee7 with apache spark for the world's largest credit card core systems, ...
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
How to deploy & optimize eZ Publish (2014)
How to deploy & optimize eZ Publish (2014)How to deploy & optimize eZ Publish (2014)
How to deploy & optimize eZ Publish (2014)
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvars
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Ams.rb Oktober