SlideShare a Scribd company logo
Parity
Keeping development and
production environments in sync
for fun, profit, and sanity
Hi, I’m Geoff
I’m the CTO at Cortex
http://cortexintel.com
Developing in Ruby since 2008
Formerly operator of
Five Tool Development
What is parity?
Parity is consistency in the configuration of your
application’s environments (production, staging,
development, test, etc.)
Why is this important?
• When your tests pass, you should be confident that
your code works.
• When you have parity, you'll find many more bugs
and configuration idiosyncrasies in development,
before you get to a QA or (gasp) production phase.
Achieving parity
• Make the time gap small: a developer may write code
and have it deployed hours or even just minutes later.
• Make the personnel gap small: developers who wrote
code are closely involved in deploying it and watching
its behavior in production.
• Make the tools gap small: keep development and
production as similar as possible.
Source: http://12factor.net/dev-prod-parity
Setup for parity
• Use the same backing services and support
software in all environments
• At Cortex our bootstrap script (modified from
Thoughtbot’s suspenders-created script) installs
PostgreSQL, Redis, node.js, and Bower if those
packages are not already installed. It then sets up
pow, foreman, tunnelss, so we can serve the app at
http://cortex.dev and https://cortex.dev
Backing Services
• Database (Postgres, MySQL, Mongo, etc)
• Queues (Sidekiq, Resque, DelayedJob)
• Storage (local disk, AWS, CloudDrive, SkyDrive)
• Search (solr, Elasticsearch)
• Caching (Rails In-memory, Memcached)
The adapter fallacy:
ActiveRecord
• ActiveRecord promises portability, but most
applications will eventually implement behavior that
isn’t consistent across different databases in the
form of SQL literals or queries that return different
results
• Rails encourages the use of SQLite in development,
but there’s no reason not to use the database you’re
going to use in production
Tools for parity
• Foreman - process manager
• Setup script
• pow - app/DNS/proxy with nice “.dev” domain
names
• Tunnelss (fork of tunnels) - route SSL to another
port locally
• Parity - easy management of Heroku environments
Foreman
• Process manager that works well locally as a stand-
in for Heroku
• Runs web and background processes like Sidekiq,
DelayedJob, or Resque
• Easy to configure alongside pow
Parity gem and Heroku
• Name your app folder big-red-machine
• Name your Heroku remotes big-red-machine-
staging and big-red-machine-production
• Use parity aliases to execute commands easily on
Heroku
• migrate, rake, log, tail, log2viz, console, config, open
Moving data with parity
• production backup - takes a snapshot on production
• staging restore production - copies the latest
production backup to staging
• development restore production - copies the latest
production backup to local dev
Rails environment setup
• Make differences between your environments
explicit
• Move universal configuration to application.rb or
initializers
• Have environments inherit from a base environment
(staging and demo from production), then override
the few items that are different
Differences in development
For your own sanity, some items might be smart
candidates to break parity in your development
environment:
• Eager loading
• Asset compilation
• SSL
Windows?
• If you deploy to a POSIX system (Linux, BSD, etc.),
you should be doing development or at least your
testing in a similar environment
• Use Vagrant or other virtualization tools to run a
facsimile environment locally
Configure with ENV
Never store credentials or secrets in source control
Environment can be used for configuration beyond
credentials!
• S3 configuration
• CDN setup
• DB connection pool size
Local ENV
• Rails 4.1 introduced secrets.yml, a standard way to
store local credentials
• dotenv/dotenv-rails can load credentials from
Heroku configs (downloaded with heroku config:pull)
• Figaro performs similar functionality to Rails 4.1’s
secrets.yml (YAML format, one file for all
environments)
Careful what you mock
You should not need a network connection to run your
tests locally
In integration tests, don’t stub or mock gems that
interface with external services. Record a real
response with the vcr gem, then replay that on later
tests (make sure to strip out credentials after
recording!)
Fog and Amazon
• Use Fog to abstract Amazon S3 so that local
development and test machines don’t need the
network
• Allows common interface for local and external
storage
• In our CI environment, we make a real connection to
S3 to confirm that our local setup is not hiding a real
problem
Strategies for parity
• Use the same backing services everywhere!
• Manage packages with a package manager such as
Homebrew or apt-get
• Use the same application server in development as
production. If you’re using Unicorn in production,
don’t use WEBrick in development
OSX protip: brew services
Can’t remember how to turn on PostgreSQL? How to
restart Redis? Use brew services
• brew services list
• brew services start postgresql
• brew services restart redis
Strategies for parity
Avoid Rails.env.production? checks. Use tools like
custom_configuration
# config/environments/production.rb
BCX::Application.configure do
config.x.resque.jobs_inline = true
end
# config/initializers/resque.rb
if Rails.configuration.x.resque.jobs_inline
Resque.inline = true
end
Make it easy on testers
• My app serves locally at http://cortex.dev
• My laptop is on the IP address 10.0.1.37
• My tester can reach my machine at
http://cortex.10.0.1.37.xip.io
• When you’re not on the same subnet, use ngrok or
Finch
Strategies for deployment
• Keep your PRs as small as is reasonable
• Only merge to master code you’re ready to ship
• Deploy early and often (or… continuously!)
• Automate your deployment process
• Reduce the number of things you can forget
Make deployment easy
• You should be able to do most deploys with
ONE (1) command
• Reduce the number of things you can forget through
automation
• Don’t trust that you or your teammates will follow a
checklist every time
Protect yourself
Automating deployment means:
• You don’t forget to run migrations
• You don’t forget to update reference data
• You don’t forget to recompile or sync assets
• You don’t forget to restart the server
How we deploy
• Alias or script: push-to-staging, push-to-production,
push-to-demo
gp staging $(git symbolic-ref --short -q HEAD):master --force && staging migrate
• Always rebuild assets with bower
• Always run migrations
• Always apply production data updates
Heroku Buildpacks
• Tim Pope’s Ruby buildpack tracks with Heroku’s
buildpack, but always runs migrations without
requiring a second connection and app restart
• We use qnyp/heroku-buildpack-ruby-bower to
automatically build our assets from Bower whenever
we deploy, which helps avoid issues where we
forget to sync assets
Questions?
Further Reading
• Heroku's 12 Factor App site: http://12factor.net/
• parity gem: http://github.com/croaky/parity
• Foreman as process manager, Pow as DNS server:
http://robots.thoughtbot.com/foreman-as-process-
manager-pow-as-dns-server-and-http
• Beyond the default Rails environments:
http://signalvnoise.com/posts/3535-beyond-the-
default-rails-environments
Thanks!
I love talking about Ruby and Rails, so feel free to
reach out to me with questions!
email: geoff@cortexintel.com
Github: geoffharcourt
Twitter: @geoffharcourt

More Related Content

What's hot

Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Software, Inc.
 
Chef ignited a DevOps revolution – BK Box
Chef ignited a DevOps revolution – BK BoxChef ignited a DevOps revolution – BK Box
Chef ignited a DevOps revolution – BK Box
Chef Software, Inc.
 
Automated Infrastructure Testing
Automated Infrastructure TestingAutomated Infrastructure Testing
Automated Infrastructure Testing
Ranjib Dey
 
Puppet Camp Denver 2015: Nagios Management With Puppet
Puppet Camp Denver 2015: Nagios Management With PuppetPuppet Camp Denver 2015: Nagios Management With Puppet
Puppet Camp Denver 2015: Nagios Management With Puppet
Puppet
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Nathen Harvey
 
Understand Chef
Understand ChefUnderstand Chef
Understand Chef
devopsjourney
 
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web ScaleSaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltStack
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Software, Inc.
 
Automation in Cloud
Automation in CloudAutomation in Cloud
Automation in Cloud
Abhishek Amralkar
 
Chef: Smart infrastructure automation
Chef: Smart infrastructure automationChef: Smart infrastructure automation
Chef: Smart infrastructure automation
Johannes H. P. Skov Frandsen
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Josh Padnick
 
Introduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitIntroduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen Summit
Jennifer Davis
 
Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015
Jennifer Davis
 
Infrastructure Automation with Chef
Infrastructure Automation with ChefInfrastructure Automation with Chef
Infrastructure Automation with Chef
Jonathan Weiss
 
Infrastructure as code
Infrastructure as codeInfrastructure as code
Infrastructure as code
daisuke awaji
 
Infrastructure as Code with Chef
Infrastructure as Code with ChefInfrastructure as Code with Chef
Infrastructure as Code with Chef
Sarah Hynes Cheney
 
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Simplilearn
 
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with ChefOpscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Chef Software, Inc.
 
Test-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefTest-Driven Infrastructure with Chef
Test-Driven Infrastructure with Chef
Michael Lihs
 
Command box
Command boxCommand box

What's hot (20)

Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of Chef
 
Chef ignited a DevOps revolution – BK Box
Chef ignited a DevOps revolution – BK BoxChef ignited a DevOps revolution – BK Box
Chef ignited a DevOps revolution – BK Box
 
Automated Infrastructure Testing
Automated Infrastructure TestingAutomated Infrastructure Testing
Automated Infrastructure Testing
 
Puppet Camp Denver 2015: Nagios Management With Puppet
Puppet Camp Denver 2015: Nagios Management With PuppetPuppet Camp Denver 2015: Nagios Management With Puppet
Puppet Camp Denver 2015: Nagios Management With Puppet
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
 
Understand Chef
Understand ChefUnderstand Chef
Understand Chef
 
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web ScaleSaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
 
Automation in Cloud
Automation in CloudAutomation in Cloud
Automation in Cloud
 
Chef: Smart infrastructure automation
Chef: Smart infrastructure automationChef: Smart infrastructure automation
Chef: Smart infrastructure automation
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
 
Introduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitIntroduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen Summit
 
Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015
 
Infrastructure Automation with Chef
Infrastructure Automation with ChefInfrastructure Automation with Chef
Infrastructure Automation with Chef
 
Infrastructure as code
Infrastructure as codeInfrastructure as code
Infrastructure as code
 
Infrastructure as Code with Chef
Infrastructure as Code with ChefInfrastructure as Code with Chef
Infrastructure as Code with Chef
 
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
 
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with ChefOpscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with Chef
 
Test-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefTest-Driven Infrastructure with Chef
Test-Driven Infrastructure with Chef
 
Command box
Command boxCommand box
Command box
 

Similar to DCRUG: Achieving Development-Production Parity

Fluo CICD OpenStack Summit
Fluo CICD OpenStack SummitFluo CICD OpenStack Summit
Fluo CICD OpenStack Summit
Miguel Zuniga
 
Devops
DevopsDevops
Devops
JyothirmaiG4
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at Scale
Kris Buytaert
 
Infrastructure as Code
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code
Albert Suwandhi
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Michael Lihs
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
Pablo Godel
 
Smart Platform Infrastructure with AWS
Smart Platform Infrastructure with AWSSmart Platform Infrastructure with AWS
Smart Platform Infrastructure with AWS
James Huston
 
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios
 
Habitat Overview
Habitat OverviewHabitat Overview
Habitat Overview
Mandi Walls
 
Prescriptive System Security with InSpec
Prescriptive System Security with InSpecPrescriptive System Security with InSpec
Prescriptive System Security with InSpec
All Things Open
 
Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019
Mandi Walls
 
DevOps tools for winning agility
DevOps tools for winning agilityDevOps tools for winning agility
DevOps tools for winning agility
Kellyn Pot'Vin-Gorman
 
Top 10 dev ops tools (1)
Top 10 dev ops tools (1)Top 10 dev ops tools (1)
Top 10 dev ops tools (1)
yalini97
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOps
Eklove Mohan
 
ClearCase Escape Plan
ClearCase Escape PlanClearCase Escape Plan
ClearCase Escape Plan
Perforce
 
Deployment Strategies: Managing Code, Content, and Configurations
Deployment Strategies: Managing Code, Content, and ConfigurationsDeployment Strategies: Managing Code, Content, and Configurations
Deployment Strategies: Managing Code, Content, and Configurations
nyccamp
 
Moving Windows Applications to the Cloud
Moving Windows Applications to the CloudMoving Windows Applications to the Cloud
Moving Windows Applications to the Cloud
RightScale
 
How bigtop leveraged docker for build automation and one click hadoop provis...
How bigtop leveraged docker for build automation and  one click hadoop provis...How bigtop leveraged docker for build automation and  one click hadoop provis...
How bigtop leveraged docker for build automation and one click hadoop provis...
Evans Ye
 
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's WorkbenchAugust Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
Howard Greenberg
 
Enterprise PHP
Enterprise PHPEnterprise PHP
Enterprise PHP
Mohammad Emran Hasan
 

Similar to DCRUG: Achieving Development-Production Parity (20)

Fluo CICD OpenStack Summit
Fluo CICD OpenStack SummitFluo CICD OpenStack Summit
Fluo CICD OpenStack Summit
 
Devops
DevopsDevops
Devops
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at Scale
 
Infrastructure as Code
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
 
Smart Platform Infrastructure with AWS
Smart Platform Infrastructure with AWSSmart Platform Infrastructure with AWS
Smart Platform Infrastructure with AWS
 
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
 
Habitat Overview
Habitat OverviewHabitat Overview
Habitat Overview
 
Prescriptive System Security with InSpec
Prescriptive System Security with InSpecPrescriptive System Security with InSpec
Prescriptive System Security with InSpec
 
Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019
 
DevOps tools for winning agility
DevOps tools for winning agilityDevOps tools for winning agility
DevOps tools for winning agility
 
Top 10 dev ops tools (1)
Top 10 dev ops tools (1)Top 10 dev ops tools (1)
Top 10 dev ops tools (1)
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOps
 
ClearCase Escape Plan
ClearCase Escape PlanClearCase Escape Plan
ClearCase Escape Plan
 
Deployment Strategies: Managing Code, Content, and Configurations
Deployment Strategies: Managing Code, Content, and ConfigurationsDeployment Strategies: Managing Code, Content, and Configurations
Deployment Strategies: Managing Code, Content, and Configurations
 
Moving Windows Applications to the Cloud
Moving Windows Applications to the CloudMoving Windows Applications to the Cloud
Moving Windows Applications to the Cloud
 
How bigtop leveraged docker for build automation and one click hadoop provis...
How bigtop leveraged docker for build automation and  one click hadoop provis...How bigtop leveraged docker for build automation and  one click hadoop provis...
How bigtop leveraged docker for build automation and one click hadoop provis...
 
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's WorkbenchAugust Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
 
Enterprise PHP
Enterprise PHPEnterprise PHP
Enterprise PHP
 

Recently uploaded

Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 

Recently uploaded (20)

Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 

DCRUG: Achieving Development-Production Parity

  • 1. Parity Keeping development and production environments in sync for fun, profit, and sanity
  • 2. Hi, I’m Geoff I’m the CTO at Cortex http://cortexintel.com Developing in Ruby since 2008 Formerly operator of Five Tool Development
  • 3. What is parity? Parity is consistency in the configuration of your application’s environments (production, staging, development, test, etc.)
  • 4. Why is this important? • When your tests pass, you should be confident that your code works. • When you have parity, you'll find many more bugs and configuration idiosyncrasies in development, before you get to a QA or (gasp) production phase.
  • 5. Achieving parity • Make the time gap small: a developer may write code and have it deployed hours or even just minutes later. • Make the personnel gap small: developers who wrote code are closely involved in deploying it and watching its behavior in production. • Make the tools gap small: keep development and production as similar as possible. Source: http://12factor.net/dev-prod-parity
  • 6. Setup for parity • Use the same backing services and support software in all environments • At Cortex our bootstrap script (modified from Thoughtbot’s suspenders-created script) installs PostgreSQL, Redis, node.js, and Bower if those packages are not already installed. It then sets up pow, foreman, tunnelss, so we can serve the app at http://cortex.dev and https://cortex.dev
  • 7. Backing Services • Database (Postgres, MySQL, Mongo, etc) • Queues (Sidekiq, Resque, DelayedJob) • Storage (local disk, AWS, CloudDrive, SkyDrive) • Search (solr, Elasticsearch) • Caching (Rails In-memory, Memcached)
  • 8. The adapter fallacy: ActiveRecord • ActiveRecord promises portability, but most applications will eventually implement behavior that isn’t consistent across different databases in the form of SQL literals or queries that return different results • Rails encourages the use of SQLite in development, but there’s no reason not to use the database you’re going to use in production
  • 9. Tools for parity • Foreman - process manager • Setup script • pow - app/DNS/proxy with nice “.dev” domain names • Tunnelss (fork of tunnels) - route SSL to another port locally • Parity - easy management of Heroku environments
  • 10. Foreman • Process manager that works well locally as a stand- in for Heroku • Runs web and background processes like Sidekiq, DelayedJob, or Resque • Easy to configure alongside pow
  • 11. Parity gem and Heroku • Name your app folder big-red-machine • Name your Heroku remotes big-red-machine- staging and big-red-machine-production • Use parity aliases to execute commands easily on Heroku • migrate, rake, log, tail, log2viz, console, config, open
  • 12. Moving data with parity • production backup - takes a snapshot on production • staging restore production - copies the latest production backup to staging • development restore production - copies the latest production backup to local dev
  • 13. Rails environment setup • Make differences between your environments explicit • Move universal configuration to application.rb or initializers • Have environments inherit from a base environment (staging and demo from production), then override the few items that are different
  • 14. Differences in development For your own sanity, some items might be smart candidates to break parity in your development environment: • Eager loading • Asset compilation • SSL
  • 15. Windows? • If you deploy to a POSIX system (Linux, BSD, etc.), you should be doing development or at least your testing in a similar environment • Use Vagrant or other virtualization tools to run a facsimile environment locally
  • 16. Configure with ENV Never store credentials or secrets in source control Environment can be used for configuration beyond credentials! • S3 configuration • CDN setup • DB connection pool size
  • 17. Local ENV • Rails 4.1 introduced secrets.yml, a standard way to store local credentials • dotenv/dotenv-rails can load credentials from Heroku configs (downloaded with heroku config:pull) • Figaro performs similar functionality to Rails 4.1’s secrets.yml (YAML format, one file for all environments)
  • 18. Careful what you mock You should not need a network connection to run your tests locally In integration tests, don’t stub or mock gems that interface with external services. Record a real response with the vcr gem, then replay that on later tests (make sure to strip out credentials after recording!)
  • 19. Fog and Amazon • Use Fog to abstract Amazon S3 so that local development and test machines don’t need the network • Allows common interface for local and external storage • In our CI environment, we make a real connection to S3 to confirm that our local setup is not hiding a real problem
  • 20. Strategies for parity • Use the same backing services everywhere! • Manage packages with a package manager such as Homebrew or apt-get • Use the same application server in development as production. If you’re using Unicorn in production, don’t use WEBrick in development
  • 21. OSX protip: brew services Can’t remember how to turn on PostgreSQL? How to restart Redis? Use brew services • brew services list • brew services start postgresql • brew services restart redis
  • 22. Strategies for parity Avoid Rails.env.production? checks. Use tools like custom_configuration # config/environments/production.rb BCX::Application.configure do config.x.resque.jobs_inline = true end # config/initializers/resque.rb if Rails.configuration.x.resque.jobs_inline Resque.inline = true end
  • 23. Make it easy on testers • My app serves locally at http://cortex.dev • My laptop is on the IP address 10.0.1.37 • My tester can reach my machine at http://cortex.10.0.1.37.xip.io • When you’re not on the same subnet, use ngrok or Finch
  • 24. Strategies for deployment • Keep your PRs as small as is reasonable • Only merge to master code you’re ready to ship • Deploy early and often (or… continuously!) • Automate your deployment process • Reduce the number of things you can forget
  • 25. Make deployment easy • You should be able to do most deploys with ONE (1) command • Reduce the number of things you can forget through automation • Don’t trust that you or your teammates will follow a checklist every time
  • 26. Protect yourself Automating deployment means: • You don’t forget to run migrations • You don’t forget to update reference data • You don’t forget to recompile or sync assets • You don’t forget to restart the server
  • 27. How we deploy • Alias or script: push-to-staging, push-to-production, push-to-demo gp staging $(git symbolic-ref --short -q HEAD):master --force && staging migrate • Always rebuild assets with bower • Always run migrations • Always apply production data updates
  • 28. Heroku Buildpacks • Tim Pope’s Ruby buildpack tracks with Heroku’s buildpack, but always runs migrations without requiring a second connection and app restart • We use qnyp/heroku-buildpack-ruby-bower to automatically build our assets from Bower whenever we deploy, which helps avoid issues where we forget to sync assets
  • 30. Further Reading • Heroku's 12 Factor App site: http://12factor.net/ • parity gem: http://github.com/croaky/parity • Foreman as process manager, Pow as DNS server: http://robots.thoughtbot.com/foreman-as-process- manager-pow-as-dns-server-and-http • Beyond the default Rails environments: http://signalvnoise.com/posts/3535-beyond-the- default-rails-environments
  • 31. Thanks! I love talking about Ruby and Rails, so feel free to reach out to me with questions! email: geoff@cortexintel.com Github: geoffharcourt Twitter: @geoffharcourt

Editor's Notes

  1. At Cortex, we have production, staging (stakeholder QA), development (my laptop), test (my laptop), and CI (Travis, build verification)
  2. You should strive to have your development and production environments as close to each other in configuration and behavior as possible so that your development (or testing) environment is an accurate representation of your deployed code in production.
  3. Aaron Patterson from Rails Core has a joke that no app has ever successfully switched databases PG does not support strftime