DEPLOYING MICROSERVICES ON AWS MICHAEL HABERMAN FOUNDER @ APPLICALLS
TODAY What is microservices? How to host microservices? Deployment aspect of microservices
GENERAL CONCEPT Instance User logic Payment logic Analytics logic Reporting logic Monolith User logic Payment logic Analytics logic Reporting logic
WHY IT IS GOOD FOR US? • Large project are hard to maintain • Easy to test • Safe to deploy • Can use different programming languages • Can use different databases
WHY IT IS GOOD FOR US? Who is us…?
WHY IT IS BAD FOR THEM? • Multiple instance to handle • Complicated deployment • A lot of automation • So many logs… • Complicated monitoring and alerts • Configuration….
WHY IT IS BAD FOR THEM? Who is them…?
MICROSERVICES TAG LINE
TODAY • What is microservices? • How to host microservices? • Deployment aspect of microservices
HOSTING OPTIONS IN AWS • EC2 – Elastic Cloud Compute • Elastic beanstalk • ECS – Elastic Container Service (Docker…) • Lambda Function - Serverless
EC2 • Simple VM in the cloud • Image as base installation • Manual maintenance (updates, backup) • Elastic beanstalk is fully managed • Auto Scaling defined by you • Pay per hour • Ideally instance per application / service
EC2 – CLOUD DIAGRAM Load balancer Service 1 Service 2 EC2 EC2 EC2 EC2
EC2 - PROS AND CONS • Pros • Easy to migrate • Better for different OS (Linux and Windows) • Cons • Expensive (Compute & storage) • Hard to maintain • Auto scaling may take time
ECS • Managed Docker by AWS
Docker Host (EC2) DOCKER Docker Host (EC2) Container 1 Container 2 Container 3 Container 4 Container 3 OS Web Server App code
ECS • Managed Docker by AWS • Container ”image” as Code (Docker) • Cluster image managed by AWS • Two level auto scale, cluster & container • High resources utilization • Container == service (or in javascript container === service)
ECS – CLOUD DIAGRAM Load balancer EC2 #1 EC2 #2 Service 1 Service 2 Service 1 Service 2
ECS - PROS AND CONS • Pros • Easy to move from AWS • Easy to run locally • Good utilization of resources • Easy and fast auto scale • Easy to maintain the containers • Cons • Another technology knowledge (Docker) • Windows Docker container is problematic
LAMBDA FUNCTION • Serverless – no underlying infrastructure • No maintenance • Pay only of runtime • Focus on the code
LAMBDA – CLOUD DIAGRAM API Gateway Lambda 1 Lambda 2
LAMBDA - PROS AND CONS • Pros • Cheap at low – medium scale • Much less maintenance • Fully managed by AWS (scaling) • Cons • Hard to develop locally • Specific programing languages • No file system • Limited installations • Not mature enough
COMPARISON EC2 ECS Lambda Maintenance High Medium Low Cost Effective Low High Depends on scale Flexibility Low High High Auto scaling A lot of work Some work Managed by AWS Coupled with AWS None Low High Local development Easy Easy Complex
HOSTING We will use ECS
TODAY • What is microservices? • How to host microservices? • Deployment aspect of microservices
DEPLOYMENT • Source control • Build • Test • Deploy • Test & rollback • Monitor • Alerts
SOURCE CONTROL • What do we need: • Allow multiple developers to work in parallel • Easy way to merge • Easy way to get specific version code • Support multiple environments
SOURCE CONTROL GIT FLOW ENV BASED Master Dev Feature
LAMBDA - PROS AND CONS What would you choose?
SOURCE CONTROL • Why git flow? • Docker image should be build once • Same image moves between envs freely • Use tags to indicate image usage • Don’t rebuild images between envs • It is a new app (npm install….)
BUILD • Independent build server! • Jenkins, CodeBuild • Don’t set configuration at this point • Build should include tests (more on that later) • Push to repository with matching tag (latest stable build)
TEST • Static • No need to run the service, but specific parts • Dynamic • Need to run the service, but doesn’t communicate • Depended dynamic • Need to run the service and it’s dependencies
DEPLOY • Deploy single service vs Entire cluster • Retag • Live testing • rollback
Docker Host (EC2) SINGLE CONTAINER DEPLOYMENT Docker Host (EC2) Container 1 Container 2 Container 3 Container 1 Container 2 Container 3 Container 3 new Container 3 new Traffic routed to new Killed after no traffic Tested
Docker Host (EC2) CLUSTER DEPLOYMENT Docker Host (EC2) Container 1 Container 2 Container 3 Container 1 Container 2 Container 3 new Traffic routed to newKilled after no traffic Tested
DEPLOY SINGLE SERVICE VS ENTIRE CLUSTER • Entire Cluster • Easier to deploy few services together • Single Container • Simpler
LIVE TESTING • Once deployed • Run E2E / API testing • Rollback if needed
MONITORING • Application monitoring • Logs • Configuration • Infrastructure monitoring • Logs • Metrics • Automatic actions • Cost
ALERTS • Based on metrics and events • Should support: Email, SMS, Phone calls, Slack, and APIs • Should support alerts based on logs
TODAY • What is microservices? • How to host microservices? • Deployment aspect of microservices
THANK YOU! MICHAEL@APPLICALLS.IO

Deploying microservices on AWS

  • 1.
  • 2.
    TODAY What is microservices? Howto host microservices? Deployment aspect of microservices
  • 3.
    GENERAL CONCEPT Instance User logic Paymentlogic Analytics logic Reporting logic Monolith User logic Payment logic Analytics logic Reporting logic
  • 4.
    WHY IT ISGOOD FOR US? • Large project are hard to maintain • Easy to test • Safe to deploy • Can use different programming languages • Can use different databases
  • 5.
    WHY IT ISGOOD FOR US? Who is us…?
  • 6.
    WHY IT ISBAD FOR THEM? • Multiple instance to handle • Complicated deployment • A lot of automation • So many logs… • Complicated monitoring and alerts • Configuration….
  • 7.
    WHY IT ISBAD FOR THEM? Who is them…?
  • 8.
  • 9.
    TODAY • What ismicroservices? • How to host microservices? • Deployment aspect of microservices
  • 10.
    HOSTING OPTIONS INAWS • EC2 – Elastic Cloud Compute • Elastic beanstalk • ECS – Elastic Container Service (Docker…) • Lambda Function - Serverless
  • 11.
    EC2 • Simple VMin the cloud • Image as base installation • Manual maintenance (updates, backup) • Elastic beanstalk is fully managed • Auto Scaling defined by you • Pay per hour • Ideally instance per application / service
  • 12.
    EC2 – CLOUDDIAGRAM Load balancer Service 1 Service 2 EC2 EC2 EC2 EC2
  • 13.
    EC2 - PROSAND CONS • Pros • Easy to migrate • Better for different OS (Linux and Windows) • Cons • Expensive (Compute & storage) • Hard to maintain • Auto scaling may take time
  • 14.
  • 15.
    Docker Host (EC2) DOCKER DockerHost (EC2) Container 1 Container 2 Container 3 Container 4 Container 3 OS Web Server App code
  • 16.
    ECS • Managed Dockerby AWS • Container ”image” as Code (Docker) • Cluster image managed by AWS • Two level auto scale, cluster & container • High resources utilization • Container == service (or in javascript container === service)
  • 17.
    ECS – CLOUDDIAGRAM Load balancer EC2 #1 EC2 #2 Service 1 Service 2 Service 1 Service 2
  • 18.
    ECS - PROSAND CONS • Pros • Easy to move from AWS • Easy to run locally • Good utilization of resources • Easy and fast auto scale • Easy to maintain the containers • Cons • Another technology knowledge (Docker) • Windows Docker container is problematic
  • 19.
    LAMBDA FUNCTION • Serverless– no underlying infrastructure • No maintenance • Pay only of runtime • Focus on the code
  • 20.
    LAMBDA – CLOUDDIAGRAM API Gateway Lambda 1 Lambda 2
  • 21.
    LAMBDA - PROSAND CONS • Pros • Cheap at low – medium scale • Much less maintenance • Fully managed by AWS (scaling) • Cons • Hard to develop locally • Specific programing languages • No file system • Limited installations • Not mature enough
  • 22.
    COMPARISON EC2 ECS Lambda MaintenanceHigh Medium Low Cost Effective Low High Depends on scale Flexibility Low High High Auto scaling A lot of work Some work Managed by AWS Coupled with AWS None Low High Local development Easy Easy Complex
  • 23.
  • 24.
    TODAY • What ismicroservices? • How to host microservices? • Deployment aspect of microservices
  • 25.
    DEPLOYMENT • Source control •Build • Test • Deploy • Test & rollback • Monitor • Alerts
  • 26.
    SOURCE CONTROL • Whatdo we need: • Allow multiple developers to work in parallel • Easy way to merge • Easy way to get specific version code • Support multiple environments
  • 27.
    SOURCE CONTROL GIT FLOWENV BASED Master Dev Feature
  • 28.
    LAMBDA - PROSAND CONS What would you choose?
  • 29.
    SOURCE CONTROL • Whygit flow? • Docker image should be build once • Same image moves between envs freely • Use tags to indicate image usage • Don’t rebuild images between envs • It is a new app (npm install….)
  • 30.
    BUILD • Independent buildserver! • Jenkins, CodeBuild • Don’t set configuration at this point • Build should include tests (more on that later) • Push to repository with matching tag (latest stable build)
  • 31.
    TEST • Static • Noneed to run the service, but specific parts • Dynamic • Need to run the service, but doesn’t communicate • Depended dynamic • Need to run the service and it’s dependencies
  • 32.
    DEPLOY • Deploy singleservice vs Entire cluster • Retag • Live testing • rollback
  • 33.
    Docker Host (EC2) SINGLECONTAINER DEPLOYMENT Docker Host (EC2) Container 1 Container 2 Container 3 Container 1 Container 2 Container 3 Container 3 new Container 3 new Traffic routed to new Killed after no traffic Tested
  • 34.
    Docker Host (EC2) CLUSTERDEPLOYMENT Docker Host (EC2) Container 1 Container 2 Container 3 Container 1 Container 2 Container 3 new Traffic routed to newKilled after no traffic Tested
  • 35.
    DEPLOY SINGLE SERVICEVS ENTIRE CLUSTER • Entire Cluster • Easier to deploy few services together • Single Container • Simpler
  • 36.
    LIVE TESTING • Oncedeployed • Run E2E / API testing • Rollback if needed
  • 37.
    MONITORING • Application monitoring •Logs • Configuration • Infrastructure monitoring • Logs • Metrics • Automatic actions • Cost
  • 38.
    ALERTS • Based onmetrics and events • Should support: Email, SMS, Phone calls, Slack, and APIs • Should support alerts based on logs
  • 39.
    TODAY • What ismicroservices? • How to host microservices? • Deployment aspect of microservices
  • 40.