Top Banner
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Abby Fuller, Sr Technical Evangelist, AWS Peter Wong, Travelex June 28, 2017 Deep Dive on Microservices and ECS
47

Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Mar 17, 2018

Download

Documents

ngoduong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

©2016,AmazonWebServices,Inc.oritsAffiliates.Allrightsreserved.

AbbyFuller,Sr TechnicalEvangelist,AWSPeterWong,Travelex

June28,2017

DeepDiveonMicroservices andECS

Page 2: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Agenda

• Whataremicroservices?• LightningECSoverview• Let’sgetfeaturespecific• FlexibleorchestrationandECS• Containerlifecyclewithecs-cli• Customerusecase:Travelex

Page 3: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Whataremicroservices?

Page 4: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

”Serviceorientedarchitecturecomposedoflooselycoupledelementsthathaveboundedcontexts.”

- AdrianCockroft

Page 5: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Monolithvs.Microservices

webserver

.package

OrderUI

OrderService

InventoryService

ShippingService

OrderUI

ShippingService

OrderService

InventoryService

Page 6: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

CharacteristicsofMicroserviceArchitectures

DoonethingwellIndependent

Decentralized

Blackbox

Polyglot

Youbuildit,yourunit

Page 7: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

AmazonEC2ContainerService

Page 8: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

AmazonEC2ContainerService(ECS)

Highlyscalable,highperformancecontainermanagementsystem.

Eliminatestheneedtoinstall,operate,andscaleyourowncontainermanagementinfrastructure.

Page 9: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

AmazonEC2ContainerService(ECS)

ECSprovidesamanagedplatformfor:

Containerorchestration

DeepAWSintegration

Clustermanagement

Page 10: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

HowdoesECSmaptotraditionalworkloads?

Instances:standardEC2boxes.OnceregisteredtoaCluster,yourTasksrunhere

Services:layerthatmanagesandplacesTasks

Tasks:containerwrapperandconfigurationaroundprocessesrunningontheinstance

Page 11: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

WhoisusingECS?

…andmanymore!

Page 12: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

WhyECS?

• Fullymanaged• Sharedstateoptimistic

scheduling• NativeCloudwatch integrationfor

monitoringandlogging• NativeintegrationwithCode*

servicesforCI/CD

Page 13: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

ChooseyourownScheduler

BatchJobs

• ECStaskscheduler• Runtasksonce• Batchjobs• RunTask (random)StartTask(placed)

Long-RunningApps

ECSserviceschedulerHealthmanagementScale-upandscale-downAZawareGroupedcontainers

Page 14: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Let’sget(feature)specific

Page 15: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

AmazonECSTaskPlacement

• Ataskplacementstrategyisanalgorithmforselectinginstancesfortaskplacement,ortasksfortermination

• Ataskplacementconstraintisaruletakenintoconsiderationduringtaskplacement

• Strategiesandconstraintscanbeusedtogether

Page 16: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Howcanstrategiesandpoliciesbeused?

Name Example

AMIID attribute:ecs.ami-id==ami-eca289fb

AvailabilityZone attribute:ecs.availability-zone==us-east-1a

InstanceType attribute:ecs.instance-type==t2.small

DistinctInstances type=“distinctInstances”

Custom attribute:stack==prod

Page 17: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Multiplestrategiesaresupported

???

Binpacking Random Spread

Page 18: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Howitworks

ClusterConstraints SatisfyCPU,memory,andportrequirements

Filterforlocation,instance-type,AMI,orcustomattributeconstraintsIdentifyinstancesthatmeetspreadorbinpackplacementstrategy

Selectfinalcontainerinstancesforplacement

CustomConstraints

PlacementStrategies

Applyfilter

Page 19: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

AmazonECSEventStreamforCloudwatchLogs• Receivenearreal-timeupdatesaboutboththecurrentstateofboththecontainerinstanceswithintheECSCluster,andthecurrentstateofalltasksrunningonthosecontainerinstances.• Canbeusedtobuildcustomschedulers,ortomonitorclusterstateandhandlethosestatechangesbyconsumingeventswithotherAWSservices,suchasLambda.

Page 20: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

FlexibleorchestrationandECS

Page 21: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Flexibilityisaboutchoices

Orchestrationplatformsshouldhave:

• Sensibledefaults• Theabilitytoextendandcustomize

Pickone,oracombinationofboth.

Page 22: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Firstoff:youhaveoptions

Page 23: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Spoileralert:Iliketheconsole

Whytheconsole?• JSON• Quickertotestandgetstarted• Visualfeedback• JSON

Page 24: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Buttheconsoleisnotforeveryone

Ifyou’recustomizingorautomating,theCLImightbeabetterchoice.

Enterecs-cli:• Opensource• TakesDockercomposefiles• UsedtomanagecontainerlifecyclesfromstarttofinishonECS

I<3CLIs

Page 25: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Containerlifecyclewithecs-cli

Page 26: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Firststop:creatingacluster

$ aws ecs create-cluster --cluster-name ”summit"

Shouldreturnsomethinglike:

{

"cluster": {

"status": "ACTIVE",

"clusterName": ”summit",

"registeredContainerInstancesCount": 0,

"pendingTasksCount": 0,

"runningTasksCount": 0,

"activeServicesCount": 0,

}

}

Page 27: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Then,createatask

$ aws ecs register-task-definition --cli-input-jsonfile://path/summit.json

YoucanalsouseaJSONstring:

$ aws ecs register-task-definition --family summit --container-definitions "[{\"name\":\”summit\",\"image\":\”alpine\",\"cpu\":10,\"command\":[\"sleep\",\"360\"],\"memory\":10,\"essential\":true}]"

Page 28: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Next,useourtasktocreateaservice

$ aws ecs create-service --service-name summit--task-definition summit --desired-count 2

Youcanaddmoreparametershere,suchasplacementstrategy.YoucanalsoregisteryournewservicewithanELB/ALB.

Page 29: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Summitsareprettypopular.Let’sscaleup.

$ aws ecs update-service --service summit --desired-count 4

Wecouldusethissamecommandtoscaledown(whichwe’lllookatnext),butalsotoupdatethetaskdefinition.Effectively,deployanewversion!

Page 30: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Wedon’twanttowasteresourcesthough,solet’sscalebackdown

$ aws ecs update-service --service my-http-service --desired-count 2

Inaproductionenvironment,thisissomethingwemightwanttohandleinresponsetootherevents:autoscaling!

Page 31: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Wecanalsoquerystate

$ aws ecs describe-services --service summit

ThisreturnsATONofinformationaboutourservice:mostimportantly,itshowsusourcurrentdeployment,andwhateventsarehappeninginourcluster:

"events": [{

"message": "(service summit) has reached a steady state."

Page 32: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

ByeLondon!

$ aws ecs delete-cluster --cluster summit

Importanttonotethatwehavetoscaleourservicedownto0,andremovetheservicebeforerunningthis:justincase!

$ aws ecs update-service --service summit --desired-count 0

$ aws ecs delete-service --service summit

Page 33: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Customerusecase:TravelexPeterWong

Page 34: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

FirstopenedinLondonin1976,Travelexisaworldleadingforeignexchangeexpertwithpresencein29countries,agrowingonlineandmobileforeignexchangeplatformandanetworkof1,000ATMsand1,500stores

Travelexataglance

Page 35: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Travelexataglance1980

35

1990 2000 2010

1976:FirststoreopensinSouthamptonRow,London

1982:FirstferryoutletopensontheP&O

ferryservingRotterdam

1984:Firstoverseasbranchopensinthe

Netherlands,NorthSeaterminal,Rotterdam

1986:Firstnon-bankFXprovideratHeathrowT4

1989:FirstbranchesopenedintheUSA,inJFK

airport

1990:FirstbranchesopenedinAustralia,Brisbane(Domesticterminal)

2016:40th anniversary

2015:FirstexclusiveforeignexchangeprovideratHeathrow

airport

2015:TravelexsoldtoDrShettyandMrSaeed

BinButti

2014:Travelexembarksondigital

transformationstrategy

2004:TravelexopensinChina

2003:TravelexopensinIndiaandtheMiddleEast(inOman)

2003:TravelexpartnerswiththeNationalTheatretolaunch

Travelexticketseason

2001:TravelexacquiresThomasCookFS

1999:Travelexacquires

Barclay’sFXintheUK– start

ofvault

1995:AbbeyNationalbuysa33%stakeofTravelex–takeoveroftheirFX

2017:TravelexWirelaunches

Page 36: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

• Deliverinternationalpaymentssecurely atscale

• EngineeringChallenges:• E2EEncryption• E2EAuditability(build,test,release,deploy,runtime)– compliance• Ingressandegresssecurity• Multi-tenancy– multipleclients• ReusableAPIdrivencomponents– crossproducts• ContinuousDeployment• 24/7operations

Engineering@Travelex

36

Page 37: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

• Singlefunction• Composable• Reducerisks• Reducetimetomarket• Increasedevelopmentflexibility• Increaseoperationalflexibility• …

Developmicro-servicesarchitecture

37

Page 38: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

38

Page 39: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

• Codebase• Dependencies• Config• Backingservices• Build,Release,Run• Process

• Portbinding• Concurrency• Disposability• Dev/prodparity• Logs• Adminprocess

Developmicro-servicesarchitecturefollowing12-FactorApp

39

Page 40: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

• Codebase• Dependencies• Config• Backingservices• Build,Release,Run• Process

• Portbinding• Concurrency• Disposability• Dev/prodparity• Logs• Adminprocess

Developmicro-servicesarchitecturefollowing12-FactorAppwithAWSECS

40

Page 41: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

• Codebase• Dependencies• Config• Backingservices• Build,Release,Run• Process• Portbinding

• Concurrency• Disposability• Dev/prodparity• Logs• Adminprocess

Developmicro-servicesarchitecturefollowing12-FactorAppwithAWSECS

41

Page 42: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

42

• Cloudfront• ClassicELB• RDS• ECS• Route53• SES• SQS• SNS• S3• Nginx(reverseproxy)

ServiceprovisioningviaCloudformation

Page 43: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

43

• Cloudfront toNginx• ServicetoService• ServicetoInternet

(3rd parties)• ServicetoRDS• Hashicorp Vault(PKI)

E2EIngressandEgressFlows

Page 44: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

• Retrievearatefroma3rd party• Apply%margin• Applynumericalmethodstofixquoteside

Example:fetchingarate

44

Page 45: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

45

Page 46: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Thank You

46

Page 47: Deep Dive on Microservicesand ECSlondon-summit-slides-2017.s3.amazonaws.com/12.50 - Deep...Deep Dive on Microservicesand ECS Agenda •What are microservices? •Lightning ECS overview

Thankyou!