SlideShare a Scribd company logo
1 of 43
Working with
Microservices and ECS at
Airtime
Abby Fuller, Ops
@abbyfuller
Airtime is a new social experience that lets real friends share real moments
in real time through group video, messaging, and more.
Things I promised I’d cover
● Microservices and ECS overview
● What does the Airtime architecture look like?
● Developing locally with Docker and Vagrant
● Testing and deploying with CircleCI
● Working with ECR
● We’re live on ECS!
● Demo time.
● Questions?
Monolith to microservices
● Rebuilt infrastructure a couple of months ago to solve significant issues:
○ Environment inconsistencies
○ Limited velocity
○ Unhappy developers
○ Struggles with configuration management
○ Hard to debug issues
● Single monolith, to containerized microservices, built on AWS ECS
Why microservices and containers?
● Containers are atomic
● Can change a single piece without affecting the whole
● Majority of requirements are at container level, reduces need for heavily
customized servers
● Same container can be tested locally, and then deployed remotely to staging
and production- consistency!
A little bit about ECS
● Amazon’s container management services: allows you to run Docker
containers on EC2 instances, and helps with scheduling, resource
management, etc.
● Native integration with other AWS features: ELB/ALB, IAM roles for services
and tasks, Cloudwatch
● Containers are registered to services, which are registered to clusters.
Architecture highlights
ELB as service discovery
● ECS automatically
associates cluster
instances with ELBs
● Gives us service discovery
for free
● Looking forward: we can
do this with ALBs
Let’s get to the fun stuff.
What are we aiming for with dev environments?
● Support developer productivity
● Low learning curve for contribution
● Should not require knowledge of the backend services themselves
● Should be repeatable, and self-contained
● Should mimic the actual staging and production environments as closely as
possible.
So how’d we do this?
Developing locally with Docker and Vagrant
● Every feature is developed and tested locally with Vagrant environments
● Allows us to quickly describe development environments (resources, ports,
etc.), and run a provisioner that sets up service-level requirements
● Increases velocity, since a working container can be developed locally,
pushed to ECR, and then deployed to staging or production
Why we use Vagrant
● Developer happiness, easy to start, easy to maintain provisioners
● Protection! Services run inside Vagrant environment, inaccessible from host
unless we explicitly forward ports
● Consistent and repeatable: developers work from environments set up
identically, reduces “it works locally!”
Setting up the environment
● All we need is the Vagrantfile in our project’s root directory
● Vagrantfile does a couple of things for us:
○ Defines the open ports we need for our containers
○ Defines the resources we allocate to the virtual environment
○ Runs our chosen provisioner (more about this up next
● Vagrant uses shared directories, so developers can work locally from their
editor, and changes will be reflected in the virtual environment
Want to see actual code? You can see a slightly edited version of
my real-life Vagrant file here.
A closer look at the Ansible provisioner
● We provision service-level requirements with Ansible.
● Provisioner handles a couple of things for us:
○ Install environment requirements
○ Pull/start dependency containers (Redis and MongoDB)
○ Pull and start service containers from ECR
○ Runs NPM install for containers and host
○ Grabs container IP that we can use for cross-container linking
● We handle local secrets with ansible-vault
Like the Vagrantfile, there is a gist of the provisioner here.
$ vagrant up
So what happened here?
Let’s break it down. A few things are happening:
● Vagrant started the environment we described and forwarded ports
● Vagrant sees that we’re running an Ansible provisioner, and that we use
ansible-vault.
● This prompts us for a vault password
Once we’ve entered the Vault password to start decrypting our secrets, Vagrant
runs our Ansible set-up tasks.
A closer look at the development workflow
A little bit closer now.
CI/CD with CircleCI
Once a feature has been developed and tested locally, you’re ready to test on
staging. This process starts with merging a pull request to develop:
View from the top
Working with ECR
● We version control all of our containers through ECR
● Lots of tagging schemes out there, but this one is ours:
○ Individual builds are tagged with the commit SHA1 from CircleCI. This allows us to tie a
specific container version to a specific commit.
○ Develop branches are tagged with both the SHA1, and with :develop
○ Master branches are tagged with both the SHA1, and with :latest
● We use :latest and :develop for local purposes only. ECS task definitions
exclusively use SHAs for debugging purposes
● ECR lets us pull directly from our repositories from our cluster machines
Walking through the build process
Deploying to ECS
The final CircleCI build step triggers the ECS deployment:
There are a couple different pieces to this, so we’ll walk through them individually.
First, we create a ContainerDefinition:
Next, we create a TaskDefinition:
And finally, we register it to our cluster:
Let’s talk about ECS, baby.
With ECS, TaskDefinitions are registered to services, which are in turn registered
to clusters. Here’s what that looks like:
A top-level view of a cluster
OK, so where were we?
Once CircleCI makes the call to switch over to our new TaskDefinition, ECS takes
over the deployment process:
Looking more closely at connection draining
In the previous example, the deployment went smoothly: we deployed a new
revision, it passed health checks, and ECS drained connections off the old
revision, to replace it with our new one. Zero downtime deployments FTW. But
what happens if that doesn’t work?
A service pre-deploy
A service during deploy
Uh-oh, our deploy failed!
The good news
In that last case, ECS doesn’t drain connections off and route traffic to the new
task, since it fails to pass healthchecks. From the console side, that looks
something like this:
Preventing bad deploys
Besides connection-draining, which we get for free with ECS, we take a couple
more steps to prevent bad deployments:
● TDD, and developing locally with Vagrant
● Services run individual tests on CircleCI
● NotoriousJPG (Hubot) runs an additional test suite, plus load tests
So, we only make the call to deploy a service if both the local tests, and the
CircleCI tests pass. Errors that have snuck through can be caught by ECS
healthchecks, or by the automated tests. And finally...
Monitoring our microservices
● Lots of microservices means lots of monitoring
● ECS creates automatic memory and CPU usage metrics in Cloudwatch for
each service.
● Custom Cloudwatch dashboard that allows us to check the health of all our
services at a glance.
Logging beyond Cloudwatch
● We use Sumologic to grab application logs
● We instrument application-side with Newrelic
● Errors, and warnings, and other fatal issues are sent to PagerDuty
A little bit more detail on container logging
● We run Sumologic as a container on the cluster hosts, started at boot
● From the containers, we use syslog as our log driver:
echo OPTIONS="--log-driver=syslog" >> /etc/sysconfig/docker
● Sumologic follows /var/log/messages on the cluster host
● allows us to catch application logs from containers even if the container
process fails quickly.
Bonus round: autoscaling with ECS
● Lots of AWS options for keeping user experience consistent.
● We autoscale with ECS at both the cluster, and the service level
Scaling the cluster hosts
● Like with regular autoscaling groups, can scale ECS cluster hosts based on
metrics (like CPU usage, etc.)
Stop! Demo time.
What we’re going to do:
1. Change a service locally
2. Hope tests pass on CircleCI
3. PR against develop
4. Merge our branch into develop
5. Hope tests still pass on CircleCI
6. Watch our changes go to ECS
7. Check to see if our new TaskDefinition deploys successfully
8. Profit
Questions?

More Related Content

What's hot

What's hot (20)

Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
AWS re:Invent 2016: All Your Chats are Belong to Bots: Building a Serverless ...
AWS re:Invent 2016: All Your Chats are Belong to Bots: Building a Serverless ...AWS re:Invent 2016: All Your Chats are Belong to Bots: Building a Serverless ...
AWS re:Invent 2016: All Your Chats are Belong to Bots: Building a Serverless ...
 
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless CloudAWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
 
AWS re:Invent 2016: Getting Started with Serverless Architectures (CMP211)
AWS re:Invent 2016: Getting Started with Serverless Architectures (CMP211)AWS re:Invent 2016: Getting Started with Serverless Architectures (CMP211)
AWS re:Invent 2016: Getting Started with Serverless Architectures (CMP211)
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
ENT303 Another Day, Another Billion Packets
ENT303 Another Day, Another Billion PacketsENT303 Another Day, Another Billion Packets
ENT303 Another Day, Another Billion Packets
 
AWS Lambda and the Serverless Cloud
AWS Lambda and the Serverless CloudAWS Lambda and the Serverless Cloud
AWS Lambda and the Serverless Cloud
 
AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...
AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...
AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...
 
Serverless for Developers
Serverless for DevelopersServerless for Developers
Serverless for Developers
 
(CMP403) AWS Lambda: Simplifying Big Data Workloads
(CMP403) AWS Lambda: Simplifying Big Data Workloads(CMP403) AWS Lambda: Simplifying Big Data Workloads
(CMP403) AWS Lambda: Simplifying Big Data Workloads
 
Deep Dive on Microservices and Amazon ECS
Deep Dive on Microservices and Amazon ECSDeep Dive on Microservices and Amazon ECS
Deep Dive on Microservices and Amazon ECS
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
AWS re:Invent 2016: From Monolithic to Microservices: Evolving Architecture P...
AWS re:Invent 2016: From Monolithic to Microservices: Evolving Architecture P...AWS re:Invent 2016: From Monolithic to Microservices: Evolving Architecture P...
AWS re:Invent 2016: From Monolithic to Microservices: Evolving Architecture P...
 
AWS October Webinar Series - AWS Lambda Best Practices: Python, Scheduled Job...
AWS October Webinar Series - AWS Lambda Best Practices: Python, Scheduled Job...AWS October Webinar Series - AWS Lambda Best Practices: Python, Scheduled Job...
AWS October Webinar Series - AWS Lambda Best Practices: Python, Scheduled Job...
 
AWS re:Invent 2016: The State of Serverless Computing (SVR311)
AWS re:Invent 2016: The State of Serverless Computing (SVR311)AWS re:Invent 2016: The State of Serverless Computing (SVR311)
AWS re:Invent 2016: The State of Serverless Computing (SVR311)
 
You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
You Can’t Protect What You Can’t See: AWS Security Monitoring & Compliance Va...
 
AWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the Cloud
 
Creating Your Virtual Data Center
Creating Your Virtual Data CenterCreating Your Virtual Data Center
Creating Your Virtual Data Center
 
Deep Dive on Microservices and Amazon ECS
Deep Dive on Microservices and Amazon ECSDeep Dive on Microservices and Amazon ECS
Deep Dive on Microservices and Amazon ECS
 
Getting started with aws io t.compressed.compressed
Getting started with aws io t.compressed.compressedGetting started with aws io t.compressed.compressed
Getting started with aws io t.compressed.compressed
 

Viewers also liked

AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps and Hybrid
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps and HybridAWS Summit Tel Aviv - Enterprise Track - Enterprise Apps and Hybrid
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps and Hybrid
Amazon Web Services
 
Media Content Ingest, Storage, and Archiving with AWS - John Downey, Amazon W...
Media Content Ingest, Storage, and Archiving with AWS - John Downey, Amazon W...Media Content Ingest, Storage, and Archiving with AWS - John Downey, Amazon W...
Media Content Ingest, Storage, and Archiving with AWS - John Downey, Amazon W...
Amazon Web Services
 

Viewers also liked (20)

Continuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECSContinuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECS
 
CI, CD with Docker, Jenkins and Tutum
CI, CD with Docker, Jenkins and TutumCI, CD with Docker, Jenkins and Tutum
CI, CD with Docker, Jenkins and Tutum
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandCI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
 
AWS Webcast - AWS Webinar Series for Education #2 - Getting Started with AWS
AWS Webcast - AWS Webinar Series for Education #2 - Getting Started with AWSAWS Webcast - AWS Webinar Series for Education #2 - Getting Started with AWS
AWS Webcast - AWS Webinar Series for Education #2 - Getting Started with AWS
 
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps and Hybrid
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps and HybridAWS Summit Tel Aviv - Enterprise Track - Enterprise Apps and Hybrid
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps and Hybrid
 
AWS Summit Auckland 2014 | Managing the Pace of Innovation: Behind the Scenes...
AWS Summit Auckland 2014 | Managing the Pace of Innovation: Behind the Scenes...AWS Summit Auckland 2014 | Managing the Pace of Innovation: Behind the Scenes...
AWS Summit Auckland 2014 | Managing the Pace of Innovation: Behind the Scenes...
 
Cost Optimization at Scale
Cost Optimization at ScaleCost Optimization at Scale
Cost Optimization at Scale
 
Deploying a Disaster Recovery Site on AWS: Minimal Cost with Maximum Efficiency
Deploying a Disaster Recovery Site on AWS: Minimal Cost with Maximum EfficiencyDeploying a Disaster Recovery Site on AWS: Minimal Cost with Maximum Efficiency
Deploying a Disaster Recovery Site on AWS: Minimal Cost with Maximum Efficiency
 
AWS Summit Auckland 2014 | Black Belt Tips on AWS
AWS Summit Auckland 2014 | Black Belt Tips on AWS AWS Summit Auckland 2014 | Black Belt Tips on AWS
AWS Summit Auckland 2014 | Black Belt Tips on AWS
 
Customer Sharing: Weather Risk - Weather on the Cloud
Customer Sharing: Weather Risk - Weather on the CloudCustomer Sharing: Weather Risk - Weather on the Cloud
Customer Sharing: Weather Risk - Weather on the Cloud
 
AWS Summit Sydney 2014 | Moving to the Cloud. What does it Mean to your Business
AWS Summit Sydney 2014 | Moving to the Cloud. What does it Mean to your BusinessAWS Summit Sydney 2014 | Moving to the Cloud. What does it Mean to your Business
AWS Summit Sydney 2014 | Moving to the Cloud. What does it Mean to your Business
 
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
 
Customer Sharing: HTC - What is in AWS Cloud for me?
Customer Sharing: HTC - What is in AWS Cloud for me?Customer Sharing: HTC - What is in AWS Cloud for me?
Customer Sharing: HTC - What is in AWS Cloud for me?
 
AWS Summit Auckland 2014 | Continuous Integration and Deployment Best Practic...
AWS Summit Auckland 2014 | Continuous Integration and Deployment Best Practic...AWS Summit Auckland 2014 | Continuous Integration and Deployment Best Practic...
AWS Summit Auckland 2014 | Continuous Integration and Deployment Best Practic...
 
Media Content Ingest, Storage, and Archiving with AWS - John Downey, Amazon W...
Media Content Ingest, Storage, and Archiving with AWS - John Downey, Amazon W...Media Content Ingest, Storage, and Archiving with AWS - John Downey, Amazon W...
Media Content Ingest, Storage, and Archiving with AWS - John Downey, Amazon W...
 
Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati...
Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati...Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati...
Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati...
 
Wild rydes serverless website workshop
Wild rydes   serverless website workshopWild rydes   serverless website workshop
Wild rydes serverless website workshop
 
Getting Started with AWS Security
Getting Started with AWS SecurityGetting Started with AWS Security
Getting Started with AWS Security
 
Scmp aws digitalmedia_2013
Scmp aws digitalmedia_2013Scmp aws digitalmedia_2013
Scmp aws digitalmedia_2013
 
AWS Summit Sydney 2014 | Reduce Risk in eCommerce Projects through Outcome Ba...
AWS Summit Sydney 2014 | Reduce Risk in eCommerce Projects through Outcome Ba...AWS Summit Sydney 2014 | Reduce Risk in eCommerce Projects through Outcome Ba...
AWS Summit Sydney 2014 | Reduce Risk in eCommerce Projects through Outcome Ba...
 

Similar to Working with microservices and Amazon ECS at Airtime

Similar to Working with microservices and Amazon ECS at Airtime (20)

2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Docker on Amazon ECS
Docker on Amazon ECSDocker on Amazon ECS
Docker on Amazon ECS
 
9th docker meetup 2016.07.13
9th docker meetup 2016.07.139th docker meetup 2016.07.13
9th docker meetup 2016.07.13
 
Building Efficient Parallel Testing Platforms with Docker
Building Efficient Parallel Testing Platforms with DockerBuilding Efficient Parallel Testing Platforms with Docker
Building Efficient Parallel Testing Platforms with Docker
 
Docker on AWS - the Right Way
Docker on AWS - the Right WayDocker on AWS - the Right Way
Docker on AWS - the Right Way
 
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 ...
ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...
 
Container Days
Container DaysContainer Days
Container Days
 
Scalable Spark deployment using Kubernetes
Scalable Spark deployment using KubernetesScalable Spark deployment using Kubernetes
Scalable Spark deployment using Kubernetes
 
MongoDB Ops Manager and Kubernetes - James Broadhead
MongoDB Ops Manager and Kubernetes - James BroadheadMongoDB Ops Manager and Kubernetes - James Broadhead
MongoDB Ops Manager and Kubernetes - James Broadhead
 
Localize content Devops
Localize content DevopsLocalize content Devops
Localize content Devops
 
Lessons learned migrating 100+ services to Kubernetes
Lessons learned migrating 100+ services to KubernetesLessons learned migrating 100+ services to Kubernetes
Lessons learned migrating 100+ services to Kubernetes
 
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
 
From Heroku to Amazon AWS
From Heroku to Amazon AWSFrom Heroku to Amazon AWS
From Heroku to Amazon AWS
 
Velocity NYC 2016 - Containers @ Netflix
Velocity NYC 2016 - Containers @ NetflixVelocity NYC 2016 - Containers @ Netflix
Velocity NYC 2016 - Containers @ Netflix
 
Advanced Container Scheduling
Advanced Container SchedulingAdvanced Container Scheduling
Advanced Container Scheduling
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14
 
Seminar Modernizing Your Development Using Microservices, Container & Kubernetes
Seminar Modernizing Your Development Using Microservices, Container & KubernetesSeminar Modernizing Your Development Using Microservices, Container & Kubernetes
Seminar Modernizing Your Development Using Microservices, Container & Kubernetes
 
Kubernetes and CoreOS @ Athens Docker meetup
Kubernetes and CoreOS @ Athens Docker meetupKubernetes and CoreOS @ Athens Docker meetup
Kubernetes and CoreOS @ Athens Docker meetup
 
Container on azure
Container on azureContainer on azure
Container on azure
 

More from Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 

Working with microservices and Amazon ECS at Airtime

  • 1. Working with Microservices and ECS at Airtime Abby Fuller, Ops @abbyfuller
  • 2. Airtime is a new social experience that lets real friends share real moments in real time through group video, messaging, and more.
  • 3. Things I promised I’d cover ● Microservices and ECS overview ● What does the Airtime architecture look like? ● Developing locally with Docker and Vagrant ● Testing and deploying with CircleCI ● Working with ECR ● We’re live on ECS! ● Demo time. ● Questions?
  • 4. Monolith to microservices ● Rebuilt infrastructure a couple of months ago to solve significant issues: ○ Environment inconsistencies ○ Limited velocity ○ Unhappy developers ○ Struggles with configuration management ○ Hard to debug issues ● Single monolith, to containerized microservices, built on AWS ECS
  • 5. Why microservices and containers? ● Containers are atomic ● Can change a single piece without affecting the whole ● Majority of requirements are at container level, reduces need for heavily customized servers ● Same container can be tested locally, and then deployed remotely to staging and production- consistency!
  • 6. A little bit about ECS ● Amazon’s container management services: allows you to run Docker containers on EC2 instances, and helps with scheduling, resource management, etc. ● Native integration with other AWS features: ELB/ALB, IAM roles for services and tasks, Cloudwatch ● Containers are registered to services, which are registered to clusters.
  • 8. ELB as service discovery ● ECS automatically associates cluster instances with ELBs ● Gives us service discovery for free ● Looking forward: we can do this with ALBs
  • 9. Let’s get to the fun stuff.
  • 10. What are we aiming for with dev environments? ● Support developer productivity ● Low learning curve for contribution ● Should not require knowledge of the backend services themselves ● Should be repeatable, and self-contained ● Should mimic the actual staging and production environments as closely as possible. So how’d we do this?
  • 11. Developing locally with Docker and Vagrant ● Every feature is developed and tested locally with Vagrant environments ● Allows us to quickly describe development environments (resources, ports, etc.), and run a provisioner that sets up service-level requirements ● Increases velocity, since a working container can be developed locally, pushed to ECR, and then deployed to staging or production
  • 12. Why we use Vagrant ● Developer happiness, easy to start, easy to maintain provisioners ● Protection! Services run inside Vagrant environment, inaccessible from host unless we explicitly forward ports ● Consistent and repeatable: developers work from environments set up identically, reduces “it works locally!”
  • 13. Setting up the environment ● All we need is the Vagrantfile in our project’s root directory ● Vagrantfile does a couple of things for us: ○ Defines the open ports we need for our containers ○ Defines the resources we allocate to the virtual environment ○ Runs our chosen provisioner (more about this up next ● Vagrant uses shared directories, so developers can work locally from their editor, and changes will be reflected in the virtual environment Want to see actual code? You can see a slightly edited version of my real-life Vagrant file here.
  • 14. A closer look at the Ansible provisioner ● We provision service-level requirements with Ansible. ● Provisioner handles a couple of things for us: ○ Install environment requirements ○ Pull/start dependency containers (Redis and MongoDB) ○ Pull and start service containers from ECR ○ Runs NPM install for containers and host ○ Grabs container IP that we can use for cross-container linking ● We handle local secrets with ansible-vault Like the Vagrantfile, there is a gist of the provisioner here.
  • 16. So what happened here? Let’s break it down. A few things are happening: ● Vagrant started the environment we described and forwarded ports ● Vagrant sees that we’re running an Ansible provisioner, and that we use ansible-vault. ● This prompts us for a vault password
  • 17. Once we’ve entered the Vault password to start decrypting our secrets, Vagrant runs our Ansible set-up tasks.
  • 18. A closer look at the development workflow
  • 19.
  • 20. A little bit closer now.
  • 21. CI/CD with CircleCI Once a feature has been developed and tested locally, you’re ready to test on staging. This process starts with merging a pull request to develop:
  • 23. Working with ECR ● We version control all of our containers through ECR ● Lots of tagging schemes out there, but this one is ours: ○ Individual builds are tagged with the commit SHA1 from CircleCI. This allows us to tie a specific container version to a specific commit. ○ Develop branches are tagged with both the SHA1, and with :develop ○ Master branches are tagged with both the SHA1, and with :latest ● We use :latest and :develop for local purposes only. ECS task definitions exclusively use SHAs for debugging purposes ● ECR lets us pull directly from our repositories from our cluster machines
  • 24. Walking through the build process
  • 25. Deploying to ECS The final CircleCI build step triggers the ECS deployment: There are a couple different pieces to this, so we’ll walk through them individually.
  • 26. First, we create a ContainerDefinition:
  • 27. Next, we create a TaskDefinition: And finally, we register it to our cluster:
  • 28. Let’s talk about ECS, baby. With ECS, TaskDefinitions are registered to services, which are in turn registered to clusters. Here’s what that looks like:
  • 29. A top-level view of a cluster
  • 30. OK, so where were we? Once CircleCI makes the call to switch over to our new TaskDefinition, ECS takes over the deployment process:
  • 31. Looking more closely at connection draining In the previous example, the deployment went smoothly: we deployed a new revision, it passed health checks, and ECS drained connections off the old revision, to replace it with our new one. Zero downtime deployments FTW. But what happens if that doesn’t work?
  • 34. Uh-oh, our deploy failed!
  • 35. The good news In that last case, ECS doesn’t drain connections off and route traffic to the new task, since it fails to pass healthchecks. From the console side, that looks something like this:
  • 36. Preventing bad deploys Besides connection-draining, which we get for free with ECS, we take a couple more steps to prevent bad deployments: ● TDD, and developing locally with Vagrant ● Services run individual tests on CircleCI ● NotoriousJPG (Hubot) runs an additional test suite, plus load tests So, we only make the call to deploy a service if both the local tests, and the CircleCI tests pass. Errors that have snuck through can be caught by ECS healthchecks, or by the automated tests. And finally...
  • 37. Monitoring our microservices ● Lots of microservices means lots of monitoring ● ECS creates automatic memory and CPU usage metrics in Cloudwatch for each service. ● Custom Cloudwatch dashboard that allows us to check the health of all our services at a glance.
  • 38. Logging beyond Cloudwatch ● We use Sumologic to grab application logs ● We instrument application-side with Newrelic ● Errors, and warnings, and other fatal issues are sent to PagerDuty
  • 39. A little bit more detail on container logging ● We run Sumologic as a container on the cluster hosts, started at boot ● From the containers, we use syslog as our log driver: echo OPTIONS="--log-driver=syslog" >> /etc/sysconfig/docker ● Sumologic follows /var/log/messages on the cluster host ● allows us to catch application logs from containers even if the container process fails quickly.
  • 40. Bonus round: autoscaling with ECS ● Lots of AWS options for keeping user experience consistent. ● We autoscale with ECS at both the cluster, and the service level
  • 41. Scaling the cluster hosts ● Like with regular autoscaling groups, can scale ECS cluster hosts based on metrics (like CPU usage, etc.)
  • 42. Stop! Demo time. What we’re going to do: 1. Change a service locally 2. Hope tests pass on CircleCI 3. PR against develop 4. Merge our branch into develop 5. Hope tests still pass on CircleCI 6. Watch our changes go to ECS 7. Check to see if our new TaskDefinition deploys successfully 8. Profit