Slide 1

Slide 1 text

How we built a heroku for ourselves

Slide 2

Slide 2 text

Senthil V S siliconsenthil jeechudeka Jeechu Deka

Slide 3

Slide 3 text

Before we start…

Slide 4

Slide 4 text

Done microservices?

Slide 5

Slide 5 text

Used AWS?

Slide 6

Slide 6 text

Know to cook?

Slide 7

Slide 7 text

Know to order food?

Slide 8

Slide 8 text

Cook or Buy

Slide 9

Slide 9 text

Agenda The problem cloudlift, our solution Learnings Q & A

Slide 10

Slide 10 text

Simpl Virtual CC for users make money simple, so that people can live well and do amazing things. PG for merchants We enable payment without banks

Slide 11

Slide 11 text

Platform Simpl Merchant servers to API Merchant apps SDKs Merchant apps Sim pl user facing Apps

Slide 12

Slide 12 text

Simpl architecture Services Streaming Platform Data Pipeline Dashboards Analytics ML models Merchant Apps Simpl Website Different tech stacks Scalability requirements Security requirements services

Slide 13

Slide 13 text

So… Four tech stacks (RoR, GoLang, Node, Python) Five developers. No (Dev)Ops Scaling needs are different Security needs are different Centralized logging Centralized config management

Slide 14

Slide 14 text

We wanted a solution, that…. Multiple tech stacks No (Dev)Ops. Easy to use Standard stack across platform Customizable standard

Slide 15

Slide 15 text

Possible solutions • Hand-crafted (?!) servers • Config management tools (chef, puppet etc.) • PaaS (Heroku, now.sh, AWS ElasticBeanstalk etc.)

Slide 16

Slide 16 text

Config management tools • Using Chef/puppet/Terraform etc. • Heavy-weight. Highly customizable leading to complex codebase. • Platform architecture being reflected. • Every change in service communications could require change in DevOps platform

Slide 17

Slide 17 text

PaaS • Easier to get started • No way to customize • Microservices: Internal vs external • Costly

Slide 18

Slide 18 text

PaaS is force-fitting IaaS is hard What did we do…

Slide 19

Slide 19 text

Or something in-between Cook or Buy

Slide 20

Slide 20 text

Build a PaaS on IaaS

Slide 21

Slide 21 text

Cloudformation • Infra as code • AWS specific • Resources defined in template and applied • Idempotent

Slide 22

Slide 22 text

Cloudformation template

Slide 23

Slide 23 text

ECS • ECS: Elastic Container Service • Orchestrator engine to run containers • Runs on cluster of EC2 instances • Exposes API to run/stop/scale containers • Container repository to push images

Slide 24

Slide 24 text

Service Task definition ✓ Network mode ✓ Constraints Container definition ✓ ECR image version ✓ Env vars ✓ Port mapping ✓ Command to run ✓ Logs ✓ Cluster i.e. set of EC2 instances ✓ Number of tasks ✓ High availability deployment ✓ Task placement ✓ Load balancing (ELB/ALB) ✓ Autoscaling ECS terms ✓ECR: EC2 Container registry ✓ELB: Elastic load balancer ✓ALB: Application load balancer ✓Port mapping ✓ Container port <-> Container instance port ✓ Can be dynamic ✓Task placement ✓ AZ Balanced spread ✓ One Task per Host ✓ BinPack ✓Constraints ✓ allow you to filter the instances ✓ using built-in or custom attributes ✓Network mode ✓ Bridge/Host etc. ✓Tasks run from Task definition ✓Containers run from Container definition

Slide 25

Slide 25 text

Demo Creating a service Deploying the service Scaling it Monitoring & logs

Slide 26

Slide 26 text

Cloudlift architecture click library (cli -> Python methods) Boto Python code to AWS api Cloudformation template

Slide 27

Slide 27 text

Cloudlift • Built by two developers at Simpl & in production use • Used in a heroku style. (Yeah. You can call it heroic style ;)) • Fully customizable • Open sourced

Slide 28

Slide 28 text

What happens on deploy_service ? Push local docker 
 image to ECR Ensure S3 has all required config env.sample Docker registry ECR Update the task definition with image version & env vars ECS runs new containers with updated version Stops the old version once new are up ★ The service name is guessed from current dir ★ image name is same as repo name in 
 spinal case without simpl- prefix ★ latest version is picked to push 1 2 3 4 5

Slide 29

Slide 29 text

A solution Multiple tech stacks No (Dev)Ops. Easy to use Standard stack across platform Customizable standard Docker }Cloudformation CLI

Slide 30

Slide 30 text

Show me code

Slide 31

Slide 31 text

Learnings

Slide 32

Slide 32 text

Microservices & DevOps - Keep it lightweight - Treat service creation/removal a frequent thing to do - Empower developers

Slide 33

Slide 33 text

Microservices & DevOps - Build time dependency => library - Runtime dependency => another microservice - Lifecycle dependency => DevOps

Slide 34

Slide 34 text

ECS is not batteries-included. Simple and does the job. Well.

Slide 35

Slide 35 text

Never hand-code Cloudformation template

Slide 36

Slide 36 text

Bake-in monitoring and alerts

Slide 37

Slide 37 text

Treat secrets and other configurations same.

Slide 38

Slide 38 text

12 factor apps Env var config Port binding Dev/prod parity Logs as event streams

Slide 39

Slide 39 text

Prefer CLI over GUI Building CLI is easier Easier to integrate in CI tools Security

Slide 40

Slide 40 text

CLI: Use defaults for almost everything

Slide 41

Slide 41 text

CLI: Avoid positional params except, readable command options

Slide 42

Slide 42 text

CLI: Help is must Because it’s for humans

Slide 43

Slide 43 text

CLI: Dry-run is must Because humans err

Slide 44

Slide 44 text

CLI: Dry-run is must Because humans err Confirm before running Ability to abort

Slide 45

Slide 45 text

CLI: Log the progress & details Because humans are impatient Log levels As colorful as possible

Slide 46

Slide 46 text

Follow standard unix exit codes Because machines have to understand too

Slide 47

Slide 47 text

Version it Because things improve

Slide 48

Slide 48 text

Q & A

Slide 49

Slide 49 text

siliconsenthil jeechudeka