SlideShare a Scribd company logo
PAGE
Industry Partner
Taking your code to production
Deployment and 12 factor
PAGE
Industry Partner
Speaker: Muayyad Alsadi
Free software contributor and
advocate. One of the Tech
leads at OpenSooq.com.
https://muayyad-alsadi.github.io/
PAGE
Industry Partner
It works on my laptop
● Developers write the code
● On their laptops they sacrifice anything
to get it to work
● They try and experiment with all kinds
of things
● They add all kinds of dependencies of
arbitrary random versions
● Their environment is not reproducible
● They even can’t tell you what they have
installed to get it to work
PAGE
Industry Partner
It works on my laptop
• The develop is not aware that he is using bleeding edge non-production
branch of library that only adds a shiny logo and millions of bugs
• The develop is too lazy, instead of using standard things he uses all kinds
of third party helpers
• The developer tries to avoid writing two lines of code by using thousands of
random code on the internet that he/she does not understand.
• The developer is trying to avoid reading the docs by re-inventing the wheel
• Re-inventing the square wheel indeed.
• The developer hacks the framework core so it no longer do what it’s
expected to do. And there is no documentation of the new behavior
• Too much magic behind the scenes.
PAGE
Industry Partner
PAGE
Industry Partner
PAGE
Industry Partner
PAGE
Industry Partner
It works on my laptop
• The data needed to reproduce the bug is not in the outdated or small dev
database.
• The bug is only seen at thousands of requests per seconds
• The bug is only seen when your first request lands on a server on one
region and then next requests on another requests
• The scenario needed to reproduce the bug involves new sign up with a new
real facebook account, sms verification with a real phone number in
another country, doing a payment ..etc.
• The bug is not even reproducible
• Heisenbug/schrödinbug is a bug that changes its behavior when you study
it (in the presence of tools to debug it)
PAGE
Industry Partner
Software Defined Everything
• Software can add more value (ex. a smartphone software can use
gyroscope sensor to do image stabilization)
• Software define the value
• Software defined does not mean fake or virtual but it means
– Controlled
– Scriptable and Automated
– Reproduced
• Software as a service
– “Everything as a service”
• Ironic is a bare-metal as a service
PAGE
Industry Partner
Microservice Architecture
• Infrastructure as code
• Microservice is Similar to Unix
Philosophy
– Do one thing and do it right
– Everything is a file (here
everything is a service)
– Every file is a text file (every
service is a load-balanced port)
PAGE
Industry Partner
Decouple
PAGE
Industry Partner
Pets vs. Cattle
PAGE
Industry Partner
Cattle vs. Ants
● Thousands of containers
○ docker
● Fast startup time
● Continue to work even if you kill many
of them
● Dev-Ops
PAGE
Industry Partner
Cattle vs. Burger
● Serverless
○ Lambda
○ Kubeless.io
● No-ops
PAGE
Industry Partner
On-premises vs. pay as you go
PAGE
Industry Partner
Introducing 12 Factor App
• https://12factor.net/
• By Heroku co-founder Adam Wiggins
• #1 code in a VCS (like git), one app, one code, many deployments.
– Dev1, dev2, staging, production, all same code, same repo
– No many apps sharing code (split common into libraries)
• #2 Explicitly declare and isolate dependencies
– No system-wide dependencies
• One app uses django 1.11 while other needs 1.9
– Scoped dependencies
• Python’s virtualenv
• Ruby’s bundler
• Php’s composer into vendor directory ..etc.
PAGE
Industry Partner
Introducing 12 Factor App
• #3 Strict separation of config from code
– Accept config from environment variable or service discovery
– No config hardcoded in the code
– “confd” can be used to template environment variable into config files
• #4 Treat backing services as attached resources
– Like MySQL or MongoDB or S3
– Resources can be attached and detached to deploys at will. For
example, if the app’s database is misbehaving due to a hardware
issue, the app’s administrator might spin up a new database server
restored from a recent backup. The current production database could
be detached, and the new database attached – all without any code
changes.
PAGE
Industry Partner
Introducing 12 Factor App
• #5 Strictly separate build and run stages
• #6 Execute the app as one or more stateless processes
– Stateful parts are via attached backing services
– Sticky sessions are a violation of twelve-factor and should never be
used or relied upon
• #7 Export services via port
• #8 Scale out via the process model
• #9 Disposability: Maximize robustness with fast startup and graceful
shutdown
– app’s processes are disposable, meaning they can be started or
stopped at a moment’s notice
• #10 Keep development, staging, and production as similar as possible
PAGE
Industry Partner
Introducing 12 Factor App
• #11 just output logs to standard output
– A twelve-factor app never concerns itself with routing or storage of its
output stream.
• #12 Run admin/management tasks as one-off processes
– One-off admin processes should be run in an identical environment as
the regular long-running processes of the app. They run against a
release, using the same codebase and config as any process run
against that release. Admin code must ship with application code to
avoid synchronization issues.
PAGE
Industry Partner
Similar Manifesto
• http://www.reactivemanifesto.org/
• Resilient: expect the failure as part of the
process
• Elastic:
– Scale-out (not scale up) to handle high loads
– Scale-in to save cost
• Message driven
PAGE
Industry Partner
Gitflow workflow
• An always stable production/release
branch
– Known to be working
• Each feature is a branch
– Developers work in
• A merge (staging) branch
– To be production branch
• Hotfix fast lane
• Tag for each past release
• Branch for past releases if you are
going to support them with backports
PAGE
Industry Partner
Code Quality
• Fail early
• Auto checks before you commit
– Pre-commit hook on developer machine
– “php -l” that checks syntax
– “python -m compileall MyApp”
• Lint your code for a common style and best practices
– Pylint for python, eslint for javascript/nodejs
PAGE
Industry Partner
Left: pylintrc showing how I disabled some warnings, and allowed some names
Right: Pylint telling you that you should put spaces around assignment “=”
PAGE
Industry Partner
PAGE
Industry Partner
CI/CD
• Continuous integration / continuous delivery
• The What?
– Each/some commits or tags or pushes triggers build
servers, integration and automated tests
• The Why? Reproducible builds, guaranteed quality
• The How
– Jenkins (I hate it, but it’s the most common)
– Gitlab ci
– Good old git hooks (server side), scripts, ansible ..etc.
PAGE
Industry Partner
Some types of testings
• Unit tests: test every function
– Positive assertions
– Negative assertions
– Coverage: did your test cases cover all code (cases for if
part, other cases for else part)
• Stress testing:
– siege/ab
– A way to skip cache (Always miss cache component)
– Replay network capture from live on test
PAGE
Industry Partner
Code review and process
PAGE
Industry Partner
Code review and process
PAGE
Industry Partner
Deployments
• Local
– developer code on developer machine
– In-office toy machine
• Test (developer code on non-developer environment)
• Staging
– Merge / Integration
– Many features and branches
– Avoid conflicting or competing changes
• Pre-Production
– Candidate code on production database
PAGE
Industry Partner
Canary testing
• Pass small fraction of production traffic to new candidate
code
• Deliver the new version of the app (ex. Via Google play) to
small fraction of users
• Enable the new feature to small fraction of user base (using
configuration service)
PAGE
Industry Partner
Blue-green deployment
• Roll the new release using a fan out, instead of all servers at
once
• Let’s denote current production version as green and new
release as blue
• Make 10% of servers blue, 90% green
• Increase the percent blue, while watching logs
• End with all blue servers.
PAGE
Industry Partner
Immutable servers
• You don’t just “git pull” code on existing servers
• You launch new servers running new code
• When done, you terminate old ones.
• Servers are not pets, they get launched and killed all
the time
• Deliver code as docker images
• Orchestrate containers using kubernetes
PAGE
Industry Partner
Questions?
PAGE
Industry Partner
Thank you

More Related Content

What's hot

Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
Hannes Lowette
 
The Right Tool for the Right Project
The Right Tool for the Right ProjectThe Right Tool for the Right Project
The Right Tool for the Right Project
Ori Bendet
 
Designing APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI Spec
Adam Paxton
 
CD
CDCD
3x3: Speeding Up Mobile Releases
3x3: Speeding Up Mobile Releases3x3: Speeding Up Mobile Releases
3x3: Speeding Up Mobile Releases
Drew Hannay
 
Eclipse Testing Day 2010. Xored Q7
Eclipse Testing Day 2010. Xored Q7Eclipse Testing Day 2010. Xored Q7
Eclipse Testing Day 2010. Xored Q7
platoff
 
Test automation design patterns
Test automation design patternsTest automation design patterns
Test automation design patterns
Vitaly Tatarinov
 
Automating functional testing of Flex applications.
Automating functional testing of Flex applications.Automating functional testing of Flex applications.
Automating functional testing of Flex applications.
Gokuldas Pillai
 
Distribute your code with NUget and build vNext
Distribute your code with NUget and build vNextDistribute your code with NUget and build vNext
Distribute your code with NUget and build vNext
Gian Maria Ricci
 
The operational side of Mobile Apps
The operational side of Mobile AppsThe operational side of Mobile Apps
The operational side of Mobile Apps
Mobile Delivery Days
 
Jenkins CI in Action
Jenkins CI in ActionJenkins CI in Action
Jenkins CI in Action
Mikhail Pobolovets
 
Continuous Integration with Bamboo for Salesforce
Continuous Integration with Bamboo for SalesforceContinuous Integration with Bamboo for Salesforce
Continuous Integration with Bamboo for Salesforce
Klea Kolaric
 
Continuous Testing
Continuous TestingContinuous Testing
Continuous Testing
Karim Fanadka
 
WSO2 IoTS Device Manufacturer Guide
WSO2 IoTS Device Manufacturer GuideWSO2 IoTS Device Manufacturer Guide
WSO2 IoTS Device Manufacturer Guide
hugo lu
 
Efficient mobile automation
Efficient mobile automationEfficient mobile automation
Efficient mobile automation
Vitaly Tatarinov
 
Versioning strategy for a complex internal API (Konstantin Yakushev)
Versioning strategy for a complex internal API (Konstantin Yakushev)Versioning strategy for a complex internal API (Konstantin Yakushev)
Versioning strategy for a complex internal API (Konstantin Yakushev)
Nordic APIs
 
Build Time Hacking
Build Time HackingBuild Time Hacking
Build Time Hacking
Mohammed Tanveer
 
The Magic Behind Faster API Development, Testing and Delivery with API Virtua...
The Magic Behind Faster API Development, Testing and Delivery with API Virtua...The Magic Behind Faster API Development, Testing and Delivery with API Virtua...
The Magic Behind Faster API Development, Testing and Delivery with API Virtua...
SmartBear
 
SonarQube: Continuous Code Inspection
SonarQube: Continuous Code InspectionSonarQube: Continuous Code Inspection
SonarQube: Continuous Code Inspection
Michael Jesse
 

What's hot (19)

Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
 
The Right Tool for the Right Project
The Right Tool for the Right ProjectThe Right Tool for the Right Project
The Right Tool for the Right Project
 
Designing APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI Spec
 
CD
CDCD
CD
 
3x3: Speeding Up Mobile Releases
3x3: Speeding Up Mobile Releases3x3: Speeding Up Mobile Releases
3x3: Speeding Up Mobile Releases
 
Eclipse Testing Day 2010. Xored Q7
Eclipse Testing Day 2010. Xored Q7Eclipse Testing Day 2010. Xored Q7
Eclipse Testing Day 2010. Xored Q7
 
Test automation design patterns
Test automation design patternsTest automation design patterns
Test automation design patterns
 
Automating functional testing of Flex applications.
Automating functional testing of Flex applications.Automating functional testing of Flex applications.
Automating functional testing of Flex applications.
 
Distribute your code with NUget and build vNext
Distribute your code with NUget and build vNextDistribute your code with NUget and build vNext
Distribute your code with NUget and build vNext
 
The operational side of Mobile Apps
The operational side of Mobile AppsThe operational side of Mobile Apps
The operational side of Mobile Apps
 
Jenkins CI in Action
Jenkins CI in ActionJenkins CI in Action
Jenkins CI in Action
 
Continuous Integration with Bamboo for Salesforce
Continuous Integration with Bamboo for SalesforceContinuous Integration with Bamboo for Salesforce
Continuous Integration with Bamboo for Salesforce
 
Continuous Testing
Continuous TestingContinuous Testing
Continuous Testing
 
WSO2 IoTS Device Manufacturer Guide
WSO2 IoTS Device Manufacturer GuideWSO2 IoTS Device Manufacturer Guide
WSO2 IoTS Device Manufacturer Guide
 
Efficient mobile automation
Efficient mobile automationEfficient mobile automation
Efficient mobile automation
 
Versioning strategy for a complex internal API (Konstantin Yakushev)
Versioning strategy for a complex internal API (Konstantin Yakushev)Versioning strategy for a complex internal API (Konstantin Yakushev)
Versioning strategy for a complex internal API (Konstantin Yakushev)
 
Build Time Hacking
Build Time HackingBuild Time Hacking
Build Time Hacking
 
The Magic Behind Faster API Development, Testing and Delivery with API Virtua...
The Magic Behind Faster API Development, Testing and Delivery with API Virtua...The Magic Behind Faster API Development, Testing and Delivery with API Virtua...
The Magic Behind Faster API Development, Testing and Delivery with API Virtua...
 
SonarQube: Continuous Code Inspection
SonarQube: Continuous Code InspectionSonarQube: Continuous Code Inspection
SonarQube: Continuous Code Inspection
 

Similar to Taking your code to production

Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development Pipeline
GlobalLogic Ukraine
 
Dublin Unity User Group Meetup Sept 2015
Dublin Unity User Group Meetup Sept 2015Dublin Unity User Group Meetup Sept 2015
Dublin Unity User Group Meetup Sept 2015
Dominique Boutin
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2
Andrew Yatsenko
 
DevOps: Infrastructure as Code
DevOps: Infrastructure as CodeDevOps: Infrastructure as Code
DevOps: Infrastructure as Code
Julio Aziz Flores Casab
 
Build automation best practices
Build automation best practicesBuild automation best practices
Build automation best practices
Code Mastery
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integration
XPDays
 
Developer 1: Workflows And Code Management
Developer 1: Workflows And Code ManagementDeveloper 1: Workflows And Code Management
Developer 1: Workflows And Code Management
Inflectra
 
IBM Z for the Digital Enterprise - DevOps for Z
IBM Z for the Digital Enterprise - DevOps for Z IBM Z for the Digital Enterprise - DevOps for Z
IBM Z for the Digital Enterprise - DevOps for Z
DevOps for Enterprise Systems
 
Dev ops for z
Dev ops for z Dev ops for z
Dev ops for z
bamadhu
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
Roberto Pérez Alcolea
 
SamSegalResume
SamSegalResumeSamSegalResume
SamSegalResume
samuel segal
 
Twelve factor apps
Twelve factor appsTwelve factor apps
Twelve factor apps
Alea Soluciones, S.L.
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
National Cheng Kung University
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Theo Jungeblut
 
Enter the mind of an Agile Developer
Enter the mind of an Agile DeveloperEnter the mind of an Agile Developer
Enter the mind of an Agile Developer
BSGAfrica
 
The Rocky Cloud Road
The Rocky Cloud RoadThe Rocky Cloud Road
The Rocky Cloud Road
Gert Drapers
 
Making software development processes to work for you
Making software development processes to work for youMaking software development processes to work for you
Making software development processes to work for you
Ambientia
 
Infrastructure as Code for Network
Infrastructure as Code for NetworkInfrastructure as Code for Network
Infrastructure as Code for Network
Damien Garros
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web Application
Michael Choi
 
Automated perf optimization - html5 dev conf
Automated perf optimization - html5 dev confAutomated perf optimization - html5 dev conf
Automated perf optimization - html5 dev conf
Matthew Lancaster
 

Similar to Taking your code to production (20)

Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development Pipeline
 
Dublin Unity User Group Meetup Sept 2015
Dublin Unity User Group Meetup Sept 2015Dublin Unity User Group Meetup Sept 2015
Dublin Unity User Group Meetup Sept 2015
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2
 
DevOps: Infrastructure as Code
DevOps: Infrastructure as CodeDevOps: Infrastructure as Code
DevOps: Infrastructure as Code
 
Build automation best practices
Build automation best practicesBuild automation best practices
Build automation best practices
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integration
 
Developer 1: Workflows And Code Management
Developer 1: Workflows And Code ManagementDeveloper 1: Workflows And Code Management
Developer 1: Workflows And Code Management
 
IBM Z for the Digital Enterprise - DevOps for Z
IBM Z for the Digital Enterprise - DevOps for Z IBM Z for the Digital Enterprise - DevOps for Z
IBM Z for the Digital Enterprise - DevOps for Z
 
Dev ops for z
Dev ops for z Dev ops for z
Dev ops for z
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
SamSegalResume
SamSegalResumeSamSegalResume
SamSegalResume
 
Twelve factor apps
Twelve factor appsTwelve factor apps
Twelve factor apps
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
 
Enter the mind of an Agile Developer
Enter the mind of an Agile DeveloperEnter the mind of an Agile Developer
Enter the mind of an Agile Developer
 
The Rocky Cloud Road
The Rocky Cloud RoadThe Rocky Cloud Road
The Rocky Cloud Road
 
Making software development processes to work for you
Making software development processes to work for youMaking software development processes to work for you
Making software development processes to work for you
 
Infrastructure as Code for Network
Infrastructure as Code for NetworkInfrastructure as Code for Network
Infrastructure as Code for Network
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web Application
 
Automated perf optimization - html5 dev conf
Automated perf optimization - html5 dev confAutomated perf optimization - html5 dev conf
Automated perf optimization - html5 dev conf
 

More from muayyad alsadi

Accelerating stochastic gradient descent using adaptive mini batch size3
Accelerating stochastic gradient descent using adaptive mini batch size3Accelerating stochastic gradient descent using adaptive mini batch size3
Accelerating stochastic gradient descent using adaptive mini batch size3
muayyad alsadi
 
Visualizing botnets with t-SNE
Visualizing botnets with t-SNEVisualizing botnets with t-SNE
Visualizing botnets with t-SNE
muayyad alsadi
 
Introduction to Raft algorithm
Introduction to Raft algorithmIntroduction to Raft algorithm
Introduction to Raft algorithm
muayyad alsadi
 
Techtalks: taking docker to production
Techtalks: taking docker to productionTechtalks: taking docker to production
Techtalks: taking docker to production
muayyad alsadi
 
How to think like hardware hacker
How to think like hardware hackerHow to think like hardware hacker
How to think like hardware hacker
muayyad alsadi
 
الاختيار بين التقنيات
الاختيار بين التقنياتالاختيار بين التقنيات
الاختيار بين التقنيات
muayyad alsadi
 
ملتقى الصناع هيا نصنع أردوينو وندخل إلى خفاياه
ملتقى الصناع  هيا نصنع أردوينو وندخل إلى خفاياهملتقى الصناع  هيا نصنع أردوينو وندخل إلى خفاياه
ملتقى الصناع هيا نصنع أردوينو وندخل إلى خفاياهmuayyad alsadi
 

More from muayyad alsadi (7)

Accelerating stochastic gradient descent using adaptive mini batch size3
Accelerating stochastic gradient descent using adaptive mini batch size3Accelerating stochastic gradient descent using adaptive mini batch size3
Accelerating stochastic gradient descent using adaptive mini batch size3
 
Visualizing botnets with t-SNE
Visualizing botnets with t-SNEVisualizing botnets with t-SNE
Visualizing botnets with t-SNE
 
Introduction to Raft algorithm
Introduction to Raft algorithmIntroduction to Raft algorithm
Introduction to Raft algorithm
 
Techtalks: taking docker to production
Techtalks: taking docker to productionTechtalks: taking docker to production
Techtalks: taking docker to production
 
How to think like hardware hacker
How to think like hardware hackerHow to think like hardware hacker
How to think like hardware hacker
 
الاختيار بين التقنيات
الاختيار بين التقنياتالاختيار بين التقنيات
الاختيار بين التقنيات
 
ملتقى الصناع هيا نصنع أردوينو وندخل إلى خفاياه
ملتقى الصناع  هيا نصنع أردوينو وندخل إلى خفاياهملتقى الصناع  هيا نصنع أردوينو وندخل إلى خفاياه
ملتقى الصناع هيا نصنع أردوينو وندخل إلى خفاياه
 

Taking your code to production

  • 1. PAGE Industry Partner Taking your code to production Deployment and 12 factor
  • 2. PAGE Industry Partner Speaker: Muayyad Alsadi Free software contributor and advocate. One of the Tech leads at OpenSooq.com. https://muayyad-alsadi.github.io/
  • 3. PAGE Industry Partner It works on my laptop ● Developers write the code ● On their laptops they sacrifice anything to get it to work ● They try and experiment with all kinds of things ● They add all kinds of dependencies of arbitrary random versions ● Their environment is not reproducible ● They even can’t tell you what they have installed to get it to work
  • 4. PAGE Industry Partner It works on my laptop • The develop is not aware that he is using bleeding edge non-production branch of library that only adds a shiny logo and millions of bugs • The develop is too lazy, instead of using standard things he uses all kinds of third party helpers • The developer tries to avoid writing two lines of code by using thousands of random code on the internet that he/she does not understand. • The developer is trying to avoid reading the docs by re-inventing the wheel • Re-inventing the square wheel indeed. • The developer hacks the framework core so it no longer do what it’s expected to do. And there is no documentation of the new behavior • Too much magic behind the scenes.
  • 8. PAGE Industry Partner It works on my laptop • The data needed to reproduce the bug is not in the outdated or small dev database. • The bug is only seen at thousands of requests per seconds • The bug is only seen when your first request lands on a server on one region and then next requests on another requests • The scenario needed to reproduce the bug involves new sign up with a new real facebook account, sms verification with a real phone number in another country, doing a payment ..etc. • The bug is not even reproducible • Heisenbug/schrödinbug is a bug that changes its behavior when you study it (in the presence of tools to debug it)
  • 9. PAGE Industry Partner Software Defined Everything • Software can add more value (ex. a smartphone software can use gyroscope sensor to do image stabilization) • Software define the value • Software defined does not mean fake or virtual but it means – Controlled – Scriptable and Automated – Reproduced • Software as a service – “Everything as a service” • Ironic is a bare-metal as a service
  • 10. PAGE Industry Partner Microservice Architecture • Infrastructure as code • Microservice is Similar to Unix Philosophy – Do one thing and do it right – Everything is a file (here everything is a service) – Every file is a text file (every service is a load-balanced port)
  • 13. PAGE Industry Partner Cattle vs. Ants ● Thousands of containers ○ docker ● Fast startup time ● Continue to work even if you kill many of them ● Dev-Ops
  • 14. PAGE Industry Partner Cattle vs. Burger ● Serverless ○ Lambda ○ Kubeless.io ● No-ops
  • 16. PAGE Industry Partner Introducing 12 Factor App • https://12factor.net/ • By Heroku co-founder Adam Wiggins • #1 code in a VCS (like git), one app, one code, many deployments. – Dev1, dev2, staging, production, all same code, same repo – No many apps sharing code (split common into libraries) • #2 Explicitly declare and isolate dependencies – No system-wide dependencies • One app uses django 1.11 while other needs 1.9 – Scoped dependencies • Python’s virtualenv • Ruby’s bundler • Php’s composer into vendor directory ..etc.
  • 17. PAGE Industry Partner Introducing 12 Factor App • #3 Strict separation of config from code – Accept config from environment variable or service discovery – No config hardcoded in the code – “confd” can be used to template environment variable into config files • #4 Treat backing services as attached resources – Like MySQL or MongoDB or S3 – Resources can be attached and detached to deploys at will. For example, if the app’s database is misbehaving due to a hardware issue, the app’s administrator might spin up a new database server restored from a recent backup. The current production database could be detached, and the new database attached – all without any code changes.
  • 18. PAGE Industry Partner Introducing 12 Factor App • #5 Strictly separate build and run stages • #6 Execute the app as one or more stateless processes – Stateful parts are via attached backing services – Sticky sessions are a violation of twelve-factor and should never be used or relied upon • #7 Export services via port • #8 Scale out via the process model • #9 Disposability: Maximize robustness with fast startup and graceful shutdown – app’s processes are disposable, meaning they can be started or stopped at a moment’s notice • #10 Keep development, staging, and production as similar as possible
  • 19. PAGE Industry Partner Introducing 12 Factor App • #11 just output logs to standard output – A twelve-factor app never concerns itself with routing or storage of its output stream. • #12 Run admin/management tasks as one-off processes – One-off admin processes should be run in an identical environment as the regular long-running processes of the app. They run against a release, using the same codebase and config as any process run against that release. Admin code must ship with application code to avoid synchronization issues.
  • 20. PAGE Industry Partner Similar Manifesto • http://www.reactivemanifesto.org/ • Resilient: expect the failure as part of the process • Elastic: – Scale-out (not scale up) to handle high loads – Scale-in to save cost • Message driven
  • 21. PAGE Industry Partner Gitflow workflow • An always stable production/release branch – Known to be working • Each feature is a branch – Developers work in • A merge (staging) branch – To be production branch • Hotfix fast lane • Tag for each past release • Branch for past releases if you are going to support them with backports
  • 22. PAGE Industry Partner Code Quality • Fail early • Auto checks before you commit – Pre-commit hook on developer machine – “php -l” that checks syntax – “python -m compileall MyApp” • Lint your code for a common style and best practices – Pylint for python, eslint for javascript/nodejs
  • 23. PAGE Industry Partner Left: pylintrc showing how I disabled some warnings, and allowed some names Right: Pylint telling you that you should put spaces around assignment “=”
  • 25. PAGE Industry Partner CI/CD • Continuous integration / continuous delivery • The What? – Each/some commits or tags or pushes triggers build servers, integration and automated tests • The Why? Reproducible builds, guaranteed quality • The How – Jenkins (I hate it, but it’s the most common) – Gitlab ci – Good old git hooks (server side), scripts, ansible ..etc.
  • 26. PAGE Industry Partner Some types of testings • Unit tests: test every function – Positive assertions – Negative assertions – Coverage: did your test cases cover all code (cases for if part, other cases for else part) • Stress testing: – siege/ab – A way to skip cache (Always miss cache component) – Replay network capture from live on test
  • 29. PAGE Industry Partner Deployments • Local – developer code on developer machine – In-office toy machine • Test (developer code on non-developer environment) • Staging – Merge / Integration – Many features and branches – Avoid conflicting or competing changes • Pre-Production – Candidate code on production database
  • 30. PAGE Industry Partner Canary testing • Pass small fraction of production traffic to new candidate code • Deliver the new version of the app (ex. Via Google play) to small fraction of users • Enable the new feature to small fraction of user base (using configuration service)
  • 31. PAGE Industry Partner Blue-green deployment • Roll the new release using a fan out, instead of all servers at once • Let’s denote current production version as green and new release as blue • Make 10% of servers blue, 90% green • Increase the percent blue, while watching logs • End with all blue servers.
  • 32. PAGE Industry Partner Immutable servers • You don’t just “git pull” code on existing servers • You launch new servers running new code • When done, you terminate old ones. • Servers are not pets, they get launched and killed all the time • Deliver code as docker images • Orchestrate containers using kubernetes