Sean schofield & Richard Lister, Spree Commerce_ Fearless deployment @ Open Commerce Conference 2016

Spark Solutions
Spark SolutionsSpark Solutions
Fearless Deployment
Sean Schofield (@uberzealot)
Richard Lister (@bnzmnzhnz)
Background
● Open Source
● Consulting company
● VC Backed
● Acquired by First Data in 2015
What are we afraid of?
1. The “Real World”
2. Instability
3. Going Slow
The “Real World”
● Differences between staging and production
● Volume of data
● Nature of data
● Missing configuration
Instability
● Deployments cause most of the problems that impact customers
● Code being deployed as well as the deployment itself
● Risk increases over time
● External sources of instability
Going slow
● Speed of development
○ We don’t want stability at the expense of speed
○ Whatever solution we come up with it will just slow us down
● Intervals between deployments
○ The longer we go between deploys, the more worried we are about the next one
○ Migrations are more likely to fail
○ We’re only making the problem worse by delaying our deployments
Goal #1: Embrace the Real World
Embracing the “Real World”
● Two things keep us separated from the “Real World”
○ Application behavior
○ User behavior
● Let’s figure out a way to eliminate those differences
● No more surprises when we deploy!
Replace Staging Environment with Stacks
Use the stacks to go live
● Each release is done as a self-contained “stack”
● No more staging environment
● No more RAILS_ENV
● Think release candidate for your infrastructure
● No more surprises based on real world data
Stop separating the test data
● DynamoDB is designed for massive amounts of data
● Test data and live customer data can peacefully co-exist
● Use a test attribute to identify our test records
● Everything lives together in a single database!
Stop using ActiveRecord
● Learned things the hard way with Spree
● Really slow when doing a lot of writes
● Use Plain Old Ruby Objects (PORO) instead
● All of our tables have the same structure
○ store_id
○ object_id
○ object_value
Protect the real world data
● No database write access for developers
● Only the store owner change their own data
● No super admin
● Impossible for developers to change data while testing
● Ensure no real world side effects whenever we write data
Complete copy of the database
● Every stack has a complete database copy
● Migrations are performed at the same time as copy
● Shoryuken workers for multi-threaded processing
● We can copy 500,000 records in under ten minutes
Sync changes after the copy
● Track changes since our bulk copy
● DynamoDB streams to monitor these changes
● New data is continuously migrated
● Same migration logic as with bulk copy
● No more migrations on release day!
Goal #2: Stability
Ops Code as First Class Citizen
● Infrastructure must be change-controlled and repeatable
● Operations source-code is in same git repo as application code
● Every release is tracked as a single SHA in Github
● Check out a SHA to get a fully self-contained ops+app setup
● We use AWS Cloudformation templates to describe all resources
Cloudformation Top Tip
Don’t do this Do this
github.com/seanedwards/cfer
The stack contains everything we need
● Networking
● Load-balancers
● Auto-scaling groups
● Instance config
● Permissions
● Database
Docker Containers
● Provide a runnable application artifact
● Dependency management
○ System libraries
○ Ruby + Gems
○ Application code
Docker Decouples Application from OS
● Protect against changes in the underlying OS, which just provides:
○ Kernel
○ Docker daemon
○ Systemd, to start containers
● We are safer making OS updates
○ Updates to system libraries do not affect application
Amazon Machine Image
● AMI provides a runnable server artifact
○ We get the same artifact every time
● What if Docker repository goes down?
○ Create AMI with packer and bake in all docker images
○ We’re happy to trade AMI build time for stability
● What if Github or rubygems are down?
○ Instance needs no external information to start app
The Dreaded AWS Degradation Email
Cattle vs Pets
Don’t do this Do this
Auto Scaling
● Stop caring about individual instances
● Autoscaling replaces failed instances
● We trust replacement because we do it all the time
● Copy easily with changing load
Production Deployment
Release Procedure
● Tag branch in git
● Build docker container
● Build AMI
● Create stack
● Copy data from production
● Sync new data from production
● Test, test, test
● Update DNS
● Delete old stack
Immutable once we go live
● New releases require a new stack
● Emergency hotfixes require a new AMI
● Instances are replaced, not modified
● Once deployed nothing can be changed
● There is no SSH
Goal #3: Go Fast
Continuous Deployment for Developers
● We deploy many times a day - just not to production
○ Devs get a stack for each feature branch, with a full copy of production data
○ Go crazy, break things, it will be entirely deleted when done
● Docker lets us build image fast
○ We don’t want to wait for a brand new AMI with each commit
○ Write Dockerfile to use caching in a smart way
● Dev stacks can be deployed by just replacing docker image
Argus for Fast Docker Builds
● Enqueue docker builds using SQS
● Distributed workers for fast builds
● Workers pre-pull existing image layers
● This means all workers can use docker cache
● Pushes image to AWS EC2 Container Registry
github.com/rlister/argus
Developer Deploys
Developer Deploys Are Fast
● If the bundle is cached, docker build takes about 15 seconds
● AWS SSM Run Command runs a canned script
● Simply pulls latest docker image and restarts container
● Access is controlled with IAM
● Logs are in logstash
Summary
● All infrastructure and code is in the stack
● The stack is immutable
● We use stacks instead of a having a special staging environment
● We use a complete copy of real world data in our stacks
● We’re constantly deploying - just not to production
● Production deploys are just updating the DNS to the new stack
Resources
● github.com/solnic/virtus - Ruby library for PORO
● github.com/phstc/shoryuken - asynchronous Ruby workers with SQS
● github.com/rlister/argus - fast Docker build and push to ECR
● github.com/rlister/awful - Ruby library for common stack operations
● github.com/seanedwards/cfer - Ruby DSL for Cloudformation templates
● 12factor.net - guidelines for stateless software as a service
Questions?
1 of 36

Recommended

Michael Tucker, GoDaddy_How GoDaddy used Spree to build their Online Store pr... by
Michael Tucker, GoDaddy_How GoDaddy used Spree to build their Online Store pr...Michael Tucker, GoDaddy_How GoDaddy used Spree to build their Online Store pr...
Michael Tucker, GoDaddy_How GoDaddy used Spree to build their Online Store pr...Spark Solutions
12K views36 slides
Jimmie Lindstrom, Braintree_ePayment Workshop @ Open Commerce Conference 2016 by
Jimmie Lindstrom, Braintree_ePayment Workshop @ Open Commerce Conference 2016Jimmie Lindstrom, Braintree_ePayment Workshop @ Open Commerce Conference 2016
Jimmie Lindstrom, Braintree_ePayment Workshop @ Open Commerce Conference 2016Spark Solutions
10K views20 slides
Stripe con 2021 UI stack by
Stripe con 2021 UI stackStripe con 2021 UI stack
Stripe con 2021 UI stackMaximeRainville1
115 views31 slides
Tanner Ellen - Forcelandia 2016 - Dev Stack.pptx by
Tanner Ellen - Forcelandia 2016 - Dev Stack.pptxTanner Ellen - Forcelandia 2016 - Dev Stack.pptx
Tanner Ellen - Forcelandia 2016 - Dev Stack.pptxSeedCode
2.1K views18 slides
Reactjs workshop by
Reactjs workshop Reactjs workshop
Reactjs workshop Ahmed rebai
738 views71 slides
Azure series 2 creating a cloud service - web role by
Azure series 2   creating a cloud service - web roleAzure series 2   creating a cloud service - web role
Azure series 2 creating a cloud service - web roleSaravanan Subburayal
1.8K views17 slides

More Related Content

What's hot

The WordPress Performance Team by
The WordPress Performance TeamThe WordPress Performance Team
The WordPress Performance TeamFelix Arntz
562 views11 slides
Polymer, HTML includes y core-ajax by
Polymer, HTML includes y core-ajaxPolymer, HTML includes y core-ajax
Polymer, HTML includes y core-ajaxRadamantis Torres
337 views15 slides
Smoothing the Continuous Delivery Path - A Tale of Two Teams by
Smoothing the Continuous Delivery Path - A Tale of Two TeamsSmoothing the Continuous Delivery Path - A Tale of Two Teams
Smoothing the Continuous Delivery Path - A Tale of Two TeamsEqual Experts
311 views25 slides
Fastest to Mobile with Scalatra + Swagger by
Fastest to Mobile with Scalatra + SwaggerFastest to Mobile with Scalatra + Swagger
Fastest to Mobile with Scalatra + SwaggerTony Tam
2.3K views33 slides
How to adopt React for moving fast startup by
How to adopt React for moving fast startupHow to adopt React for moving fast startup
How to adopt React for moving fast startupSira Sujjinanont
484 views25 slides
Angular vs React - Devoxx BE 2017 by
Angular vs React - Devoxx BE 2017Angular vs React - Devoxx BE 2017
Angular vs React - Devoxx BE 2017Deepu K Sasidharan
619 views63 slides

What's hot(20)

The WordPress Performance Team by Felix Arntz
The WordPress Performance TeamThe WordPress Performance Team
The WordPress Performance Team
Felix Arntz562 views
Smoothing the Continuous Delivery Path - A Tale of Two Teams by Equal Experts
Smoothing the Continuous Delivery Path - A Tale of Two TeamsSmoothing the Continuous Delivery Path - A Tale of Two Teams
Smoothing the Continuous Delivery Path - A Tale of Two Teams
Equal Experts311 views
Fastest to Mobile with Scalatra + Swagger by Tony Tam
Fastest to Mobile with Scalatra + SwaggerFastest to Mobile with Scalatra + Swagger
Fastest to Mobile with Scalatra + Swagger
Tony Tam2.3K views
How to adopt React for moving fast startup by Sira Sujjinanont
How to adopt React for moving fast startupHow to adopt React for moving fast startup
How to adopt React for moving fast startup
Sira Sujjinanont484 views
How we use Silverstripe CMS to deliver bilingual and accessible websites by MichaelPritchard21
How we use Silverstripe CMS to deliver bilingual and accessible websitesHow we use Silverstripe CMS to deliver bilingual and accessible websites
How we use Silverstripe CMS to deliver bilingual and accessible websites
MichaelPritchard21167 views
GitLab Frontend and VueJS at GitLab by Fatih Acet
GitLab Frontend and VueJS at GitLabGitLab Frontend and VueJS at GitLab
GitLab Frontend and VueJS at GitLab
Fatih Acet1.9K views
How to automate your BizTalk Installations and Deployments with Chef by BizTalk360
How to automate your BizTalk Installations and Deployments with ChefHow to automate your BizTalk Installations and Deployments with Chef
How to automate your BizTalk Installations and Deployments with Chef
BizTalk3601.2K views
Extending GWT by isurusndr
Extending GWTExtending GWT
Extending GWT
isurusndr320 views
How to Build Single Page HTML5 Apps that Scale by Phil Leggetter
How to Build Single Page HTML5 Apps that ScaleHow to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that Scale
Phil Leggetter1.5K views
Next.js vs React | what to choose for frontend development_ by ForceBolt
Next.js vs React | what to choose for frontend development_Next.js vs React | what to choose for frontend development_
Next.js vs React | what to choose for frontend development_
ForceBolt372 views
Introduzione a web e servizi con .net e azure by dotnetabruzzo
Introduzione a web e servizi con .net e azureIntroduzione a web e servizi con .net e azure
Introduzione a web e servizi con .net e azure
dotnetabruzzo430 views
TRAX technical highlights by ESUG
TRAX technical highlightsTRAX technical highlights
TRAX technical highlights
ESUG171 views
Deploying a static website on Azure for $5 / month by Tim Hermie ☁️
Deploying a static website on Azure for $5 / monthDeploying a static website on Azure for $5 / month
Deploying a static website on Azure for $5 / month
React in production (react global summit 2021) by Souvik Basu
React in production (react global summit 2021)React in production (react global summit 2021)
React in production (react global summit 2021)
Souvik Basu375 views

Similar to Sean schofield & Richard Lister, Spree Commerce_ Fearless deployment @ Open Commerce Conference 2016

The Professional Programmer by
The Professional ProgrammerThe Professional Programmer
The Professional ProgrammerDave Cross
481 views112 slides
Snowflake Automated Deployments / CI/CD Pipelines by
Snowflake Automated Deployments / CI/CD PipelinesSnowflake Automated Deployments / CI/CD Pipelines
Snowflake Automated Deployments / CI/CD PipelinesDrew Hansen
3.8K views42 slides
A vision of persistence by
A vision of persistenceA vision of persistence
A vision of persistenceDocker, Inc.
257 views24 slides
Devoxx : being productive with JHipster by
Devoxx : being productive with JHipsterDevoxx : being productive with JHipster
Devoxx : being productive with JHipsterJulien Dubois
14.8K views88 slides
Instant developer onboarding with self contained repositories by
Instant developer onboarding with self contained repositoriesInstant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositoriesYshay Yaacobi
157 views53 slides
JOSA TechTalks - Docker in Production by
JOSA TechTalks - Docker in ProductionJOSA TechTalks - Docker in Production
JOSA TechTalks - Docker in ProductionJordan Open Source Association
88 views34 slides

Similar to Sean schofield & Richard Lister, Spree Commerce_ Fearless deployment @ Open Commerce Conference 2016(20)

The Professional Programmer by Dave Cross
The Professional ProgrammerThe Professional Programmer
The Professional Programmer
Dave Cross481 views
Snowflake Automated Deployments / CI/CD Pipelines by Drew Hansen
Snowflake Automated Deployments / CI/CD PipelinesSnowflake Automated Deployments / CI/CD Pipelines
Snowflake Automated Deployments / CI/CD Pipelines
Drew Hansen3.8K views
A vision of persistence by Docker, Inc.
A vision of persistenceA vision of persistence
A vision of persistence
Docker, Inc.257 views
Devoxx : being productive with JHipster by Julien Dubois
Devoxx : being productive with JHipsterDevoxx : being productive with JHipster
Devoxx : being productive with JHipster
Julien Dubois14.8K views
Instant developer onboarding with self contained repositories by Yshay Yaacobi
Instant developer onboarding with self contained repositoriesInstant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositories
Yshay Yaacobi157 views
ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ... by DynamicInfraDays
ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...
ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...
DynamicInfraDays784 views
Truemotion Adventures in Containerization by Ryan Hunter
Truemotion Adventures in ContainerizationTruemotion Adventures in Containerization
Truemotion Adventures in Containerization
Ryan Hunter200 views
Expedia 3x3 presentation by Drew Hannay
Expedia 3x3 presentationExpedia 3x3 presentation
Expedia 3x3 presentation
Drew Hannay445 views
Confoo - DevOps & Agile Infrastructure by Will Stevens
Confoo - DevOps & Agile InfrastructureConfoo - DevOps & Agile Infrastructure
Confoo - DevOps & Agile Infrastructure
Will Stevens975 views
Spark and S3 with Ryan Blue by Databricks
Spark and S3 with Ryan BlueSpark and S3 with Ryan Blue
Spark and S3 with Ryan Blue
Databricks3.9K views
Getting started with docker (2017) by JEMLI Fathi
Getting started with docker (2017)Getting started with docker (2017)
Getting started with docker (2017)
JEMLI Fathi298 views
Continuous delivery of Windows micro services in the cloud by Owain Perry
Continuous delivery of Windows micro services in the cloud Continuous delivery of Windows micro services in the cloud
Continuous delivery of Windows micro services in the cloud
Owain Perry748 views
Taking Docker to Production: What You Need to Know and Decide by Bret Fisher
Taking Docker to Production: What You Need to Know and DecideTaking Docker to Production: What You Need to Know and Decide
Taking Docker to Production: What You Need to Know and Decide
Bret Fisher53 views
Taking Docker to Production: What You Need to Know and Decide by Docker, Inc.
Taking Docker to Production: What You Need to Know and DecideTaking Docker to Production: What You Need to Know and Decide
Taking Docker to Production: What You Need to Know and Decide
Docker, Inc.1K views
Docker primer and tips by Samuel Chow
Docker primer and tipsDocker primer and tips
Docker primer and tips
Samuel Chow108 views
Dockerfile for rust project by Hien Nguyen
Dockerfile for rust projectDockerfile for rust project
Dockerfile for rust project
Hien Nguyen48 views

Recently uploaded

Uni Systems for Power Platform.pptx by
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptxUni Systems S.M.S.A.
61 views21 slides
Future of AR - Facebook Presentation by
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook PresentationRob McCarty
62 views27 slides
NTGapps NTG LowCode Platform by
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform Mustafa Kuğu
365 views30 slides
Business Analyst Series 2023 - Week 4 Session 7 by
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7DianaGray10
126 views31 slides
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ by
Confidence in CloudStack - Aron Wagner, Nathan Gleason - AmericConfidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
Confidence in CloudStack - Aron Wagner, Nathan Gleason - AmericShapeBlue
88 views9 slides
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...ShapeBlue
144 views12 slides

Recently uploaded(20)

Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty62 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu365 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10126 views
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ by ShapeBlue
Confidence in CloudStack - Aron Wagner, Nathan Gleason - AmericConfidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
ShapeBlue88 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue144 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash153 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue179 views
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue by ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue176 views
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li80 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue210 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue181 views
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue88 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays53 views
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue132 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue163 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue98 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue112 views

Sean schofield & Richard Lister, Spree Commerce_ Fearless deployment @ Open Commerce Conference 2016

  • 1. Fearless Deployment Sean Schofield (@uberzealot) Richard Lister (@bnzmnzhnz)
  • 2. Background ● Open Source ● Consulting company ● VC Backed ● Acquired by First Data in 2015
  • 3. What are we afraid of? 1. The “Real World” 2. Instability 3. Going Slow
  • 4. The “Real World” ● Differences between staging and production ● Volume of data ● Nature of data ● Missing configuration
  • 5. Instability ● Deployments cause most of the problems that impact customers ● Code being deployed as well as the deployment itself ● Risk increases over time ● External sources of instability
  • 6. Going slow ● Speed of development ○ We don’t want stability at the expense of speed ○ Whatever solution we come up with it will just slow us down ● Intervals between deployments ○ The longer we go between deploys, the more worried we are about the next one ○ Migrations are more likely to fail ○ We’re only making the problem worse by delaying our deployments
  • 7. Goal #1: Embrace the Real World
  • 8. Embracing the “Real World” ● Two things keep us separated from the “Real World” ○ Application behavior ○ User behavior ● Let’s figure out a way to eliminate those differences ● No more surprises when we deploy!
  • 10. Use the stacks to go live ● Each release is done as a self-contained “stack” ● No more staging environment ● No more RAILS_ENV ● Think release candidate for your infrastructure ● No more surprises based on real world data
  • 11. Stop separating the test data ● DynamoDB is designed for massive amounts of data ● Test data and live customer data can peacefully co-exist ● Use a test attribute to identify our test records ● Everything lives together in a single database!
  • 12. Stop using ActiveRecord ● Learned things the hard way with Spree ● Really slow when doing a lot of writes ● Use Plain Old Ruby Objects (PORO) instead ● All of our tables have the same structure ○ store_id ○ object_id ○ object_value
  • 13. Protect the real world data ● No database write access for developers ● Only the store owner change their own data ● No super admin ● Impossible for developers to change data while testing ● Ensure no real world side effects whenever we write data
  • 14. Complete copy of the database ● Every stack has a complete database copy ● Migrations are performed at the same time as copy ● Shoryuken workers for multi-threaded processing ● We can copy 500,000 records in under ten minutes
  • 15. Sync changes after the copy ● Track changes since our bulk copy ● DynamoDB streams to monitor these changes ● New data is continuously migrated ● Same migration logic as with bulk copy ● No more migrations on release day!
  • 17. Ops Code as First Class Citizen ● Infrastructure must be change-controlled and repeatable ● Operations source-code is in same git repo as application code ● Every release is tracked as a single SHA in Github ● Check out a SHA to get a fully self-contained ops+app setup ● We use AWS Cloudformation templates to describe all resources
  • 18. Cloudformation Top Tip Don’t do this Do this github.com/seanedwards/cfer
  • 19. The stack contains everything we need ● Networking ● Load-balancers ● Auto-scaling groups ● Instance config ● Permissions ● Database
  • 20. Docker Containers ● Provide a runnable application artifact ● Dependency management ○ System libraries ○ Ruby + Gems ○ Application code
  • 21. Docker Decouples Application from OS ● Protect against changes in the underlying OS, which just provides: ○ Kernel ○ Docker daemon ○ Systemd, to start containers ● We are safer making OS updates ○ Updates to system libraries do not affect application
  • 22. Amazon Machine Image ● AMI provides a runnable server artifact ○ We get the same artifact every time ● What if Docker repository goes down? ○ Create AMI with packer and bake in all docker images ○ We’re happy to trade AMI build time for stability ● What if Github or rubygems are down? ○ Instance needs no external information to start app
  • 23. The Dreaded AWS Degradation Email
  • 24. Cattle vs Pets Don’t do this Do this
  • 25. Auto Scaling ● Stop caring about individual instances ● Autoscaling replaces failed instances ● We trust replacement because we do it all the time ● Copy easily with changing load
  • 27. Release Procedure ● Tag branch in git ● Build docker container ● Build AMI ● Create stack ● Copy data from production ● Sync new data from production ● Test, test, test ● Update DNS ● Delete old stack
  • 28. Immutable once we go live ● New releases require a new stack ● Emergency hotfixes require a new AMI ● Instances are replaced, not modified ● Once deployed nothing can be changed ● There is no SSH
  • 29. Goal #3: Go Fast
  • 30. Continuous Deployment for Developers ● We deploy many times a day - just not to production ○ Devs get a stack for each feature branch, with a full copy of production data ○ Go crazy, break things, it will be entirely deleted when done ● Docker lets us build image fast ○ We don’t want to wait for a brand new AMI with each commit ○ Write Dockerfile to use caching in a smart way ● Dev stacks can be deployed by just replacing docker image
  • 31. Argus for Fast Docker Builds ● Enqueue docker builds using SQS ● Distributed workers for fast builds ● Workers pre-pull existing image layers ● This means all workers can use docker cache ● Pushes image to AWS EC2 Container Registry github.com/rlister/argus
  • 33. Developer Deploys Are Fast ● If the bundle is cached, docker build takes about 15 seconds ● AWS SSM Run Command runs a canned script ● Simply pulls latest docker image and restarts container ● Access is controlled with IAM ● Logs are in logstash
  • 34. Summary ● All infrastructure and code is in the stack ● The stack is immutable ● We use stacks instead of a having a special staging environment ● We use a complete copy of real world data in our stacks ● We’re constantly deploying - just not to production ● Production deploys are just updating the DNS to the new stack
  • 35. Resources ● github.com/solnic/virtus - Ruby library for PORO ● github.com/phstc/shoryuken - asynchronous Ruby workers with SQS ● github.com/rlister/argus - fast Docker build and push to ECR ● github.com/rlister/awful - Ruby library for common stack operations ● github.com/seanedwards/cfer - Ruby DSL for Cloudformation templates ● 12factor.net - guidelines for stateless software as a service