wso2con eu 2016: understanding microservice architecture

39
Understanding Microservice Architecture Kasun Indrasiri Director, Integra.on Technologies WSO2

Upload: wso2-inc

Post on 08-Jan-2017

221 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: WSO2Con EU 2016: Understanding Microservice Architecture

UnderstandingMicroserviceArchitecture

KasunIndrasiriDirector,Integra.onTechnologiesWSO2

Page 2: WSO2Con EU 2016: Understanding Microservice Architecture

Microservices?

*

Page 3: WSO2Con EU 2016: Understanding Microservice Architecture

MonolithicArchitecture

Page 4: WSO2Con EU 2016: Understanding Microservice Architecture

MonolithicArchitecture

•  Allfunc.onali.esareimplemented/deployedintoasinglesoBwareapplica.on.

•  EnterprisesoBwareapplica.ons-ERPs,CRMsetc.•  SOA/webservices:'coarse-grained'services,broadscope,

mammothserviceswithseveraldozensofopera.onsandcomplexmessageformats

Page 5: WSO2Con EU 2016: Understanding Microservice Architecture

MonolithicArchitecture

•  Usecase:OnlineRetailsoBwareapplica.onwhichcomprisesofmul.plebusinessfunc.onali.es.

JVM

Page 6: WSO2Con EU 2016: Understanding Microservice Architecture

MonolithicArchitecture

•  Developedanddeployedasasingleunit.•  Overwhelminglycomplex;whichleadstonightmaresin

maintaining,upgradingandaddingnewfeatures.•  Redeploytheen>reapplica>on,inordertoupdateapartofit.•  Scaling:scaledasasingleapplica>onanddifficulttoscalewith

conflic>ngresourcerequirementswholeapplica>ondown•  Reliability-Oneunstableservicecanbringthe.•  Hardtoinnovate,prac>ceagiledevelopmentanddelivery

methodologies

Page 7: WSO2Con EU 2016: Understanding Microservice Architecture

MicroservicesArchitecture

Page 8: WSO2Con EU 2016: Understanding Microservice Architecture

MicroservicesArchitecture

•  Thefounda.onofmicroservicesarchitecture(MSA)isaboutdevelopingasingleapplica.onasasuiteoffine-grainedandindependentservicesthatarerunninginitsownprocess,developedanddeployedindependently.

•  Itismorethanjustsegrega.ngtheservicesinamonolith…

Page 9: WSO2Con EU 2016: Understanding Microservice Architecture

MicroservicesArchitecture

•  Usecase:Onlineretailapplica.oncanbeimplementedwithasuiteofmicroservices

JVM

JVM

JVM

JVM

Page 10: WSO2Con EU 2016: Understanding Microservice Architecture

DesigningMicroservices:Size,scopeandcapabili.es

•  CommonMisconcep.ons–  LinesofCode–  Teamsize–  'Micro'isabitmisleadingterm–  Usewebservicesandrebrandingthemasmicroservices

Page 11: WSO2Con EU 2016: Understanding Microservice Architecture

DesigningMicroservices:Size,scopeandcapabili.es

•  CommonMisconcep.ons–  LinesofCode–  Teamsize–  'Micro'isabitmisleadingterm–  Usewebservicesandrebrandingthemasmicroservices

Page 12: WSO2Con EU 2016: Understanding Microservice Architecture

DesigningMicroservices:Size,scopeandcapabili.es

•  SingleResponsibilityPrinciple(SRP):Havingalimitedandafocusedbusinessscope.

•  Scope–  Findtheserviceboundariesandalignthemwiththebusiness

capabili.es(akaDDD)–  Focusonscopeofthemicroservice.–  Itsnotaboutmakingservicessmall…

•  Agileandindependentdevelopmentanddeploymentoftheservice.•  Microserviceshouldhaveaveryfewopera.ons/func.onali.esand

simplemessageformat.

Page 13: WSO2Con EU 2016: Understanding Microservice Architecture

MessaginginMicroservices

•  InMonolithicarchitecture:–  Func.oncallsorlanguage-levelmethodcalls–  SOA/webservices:SOAPandWS*withHTTP,JMSetc.–  Webserviceswithseveraldozensofopera.onsandcomplex

messageschemas•  InMicroservicesarchitecture:

–  Simpleandlightweightmessagingmechanism.

Page 14: WSO2Con EU 2016: Understanding Microservice Architecture

MessaginginMicroservices

•  SynchronousMessaging–  Clientexpectsa.melyresponsefromtheserviceandwaits.llitgetit.–  REST,ThriB

Page 15: WSO2Con EU 2016: Understanding Microservice Architecture

MessaginginMicroservices

•  AsynchronousMessaging–  Clientdoesn'texpectsaresponseimmediately,ornotacceptsaresponseatall–  AMQP,STOMP,MQTT

•  MessageFormats–  JSON,XML,ThriB,ProtoBuf,Avro

•  ServiceContracts–  Definingtheserviceinterfaces-Swagger,RAML,ThriBIDL

Page 16: WSO2Con EU 2016: Understanding Microservice Architecture

DataManagement

•  Monolithicapplica.onsuseacentralizeddatabase

Page 17: WSO2Con EU 2016: Understanding Microservice Architecture

DataManagement

•  Monolithicapplica.onsuseacentralizeddatabase

Page 18: WSO2Con EU 2016: Understanding Microservice Architecture

DataManagement

•  DecentralizedDatamanagementwithMicroservices–  Eachmicroservicecanhaveaprivatedatabasetopersistthedatathat

requirestoimplementthebusinessfunc.onalityofferedfromit.–  Canonlyaccessthededicatedprivatedatabasebutnotthedatabases

ofothermicroservices.–  Youmighthavetoupdateseveraldatabaseforasingletransac.on.In

suchscenarios,thedatabasesofothermicroservicesshouldbeupdatedthroughitsserviceAPIonly.

Page 19: WSO2Con EU 2016: Understanding Microservice Architecture

DecentralizedGovernance

•  Governance–“establishingandenforcinghowpeopleandsolu.onsworktogethertoachieveorganiza.onalobjec.ves”,run.me/design.me.

•  InMSA:–  Nocentralizeddesign-.megovernance.–  Maketheirowndecisionsaboutitsdesignandimplementa.on.–  Fosterthesharingofcommon/reusableservices.–  Run-.megovernanceaspectssuchasSLAs,throgling,monitoring,

commonsecurityrequirementsandservicediscoverymaybeimplementedatAPI-GWlevel.

Page 20: WSO2Con EU 2016: Understanding Microservice Architecture

ServiceRegistryandServiceDiscovery

•  ServiceRegistry–  Holdsthemicroservicesinstancesandtheirloca.ons

•  ServiceDiscovery–  findtheavailablemicroservicesandtheirloca.on

Page 21: WSO2Con EU 2016: Understanding Microservice Architecture

ServiceDiscovery

•  Client-sideDiscovery

Page 22: WSO2Con EU 2016: Understanding Microservice Architecture

ServiceDiscovery

•  Server-sideDiscovery

Page 23: WSO2Con EU 2016: Understanding Microservice Architecture

MicroservicesDeployment

•  Abilitytodeploy/un-deployindependentlyofothermicroservices.•  Mustbeabletoscaleateachmicroserviceslevel.•  Buildinganddeployingmicroservicesquickly.•  Failureinonemicroservicemustnotaffectanyoftheother

services.

Page 24: WSO2Con EU 2016: Understanding Microservice Architecture

MicroservicesDeployment

•  Docker–  Dockerisbecominganextremelypopularwayofpackagingand

deployingservices.–  Packagethemicroserviceasa(Docker)containerimage.–  Deployeachserviceinstanceasacontainer.–  Scalingisdonebasedonchangingthenumberofcontainerinstances.–  Building,deployingandstar.ngmicroserviceswillbemuchfasteras

weareusingDockercontainers

Page 25: WSO2Con EU 2016: Understanding Microservice Architecture

MicroservicesDeployment

•  Kubernetes–  ExtendingDockercapabili.esbyallowingtomanageaclusterofLinux

containersasasinglesystem,managingandrunningDockercontainersacrossmul.plehosts,offeringco-loca.onofcontainers,servicediscoveryandreplica.oncontrol.

Page 26: WSO2Con EU 2016: Understanding Microservice Architecture

MicroservicesDeployment

•  Usecase:ThemicroservicesofOnlineRetailsoBwareapplica.onwithcanbedeployedandscaledwithDockerandKubernetes.

Page 27: WSO2Con EU 2016: Understanding Microservice Architecture

Security

•  SecurityinMonolithicapplica.ons–  'whoisthecaller','whatcanthecallerdo'and'howdowepropagate

thatinforma>on’–  Implementedatacommonsecuritycomponentwhichisatthe

beginningoftherequesthandlingchainandthatcomponentpopulatestherequiredinforma.onwiththeuseofanunderlyinguserrepository

Page 28: WSO2Con EU 2016: Understanding Microservice Architecture

Security

•  SecurityinMicroservices–  Asecuritycomponenthastobeimplementedateachmicroservices

levelthatusesacentraluserrepository/store.–Notscalable!–  LeveragethewidelyusedAPI-SecuritystandardssuchasOAuth2and

OpenIDConnect(OIDC)

OAuth2.0–AccessToken:ByReference OIDC–JWT:ByValue

Page 29: WSO2Con EU 2016: Understanding Microservice Architecture

Security

•  MicroservicesecuritywithOAuth2andOpenIDConnect

Page 30: WSO2Con EU 2016: Understanding Microservice Architecture

Orchestra.ngMicroservices

•  NoESBinMSA.Thenhow?

Page 31: WSO2Con EU 2016: Understanding Microservice Architecture

Orchestra.ngMicroservices

•  Point-to-pointstyle-Invokingservicesdirectly–  Spaghejintegra.onan.-pagern?

Page 32: WSO2Con EU 2016: Understanding Microservice Architecture

Orchestra.ngMicroservices

•  Orchestra.onattheGatewayLayer

Page 33: WSO2Con EU 2016: Understanding Microservice Architecture

Orchestra.ngMicroservices

•  Orchestra.onatMicroservicesLayer

Page 34: WSO2Con EU 2016: Understanding Microservice Architecture

MicroservicesinModernEnterprises•  InnerandOuterArchitecture

–  InnerArchitecture:Thepuremicroservicescomponentswhichislesscomplexarecategorizedunder'InnerArchitecture'

–  OuterArchitecture:Thisdeliverstheplakormcapabili.esthatarerequiredtobuildasolu.onaroundthemicroservicesthatwebuild.

Page 35: WSO2Con EU 2016: Understanding Microservice Architecture

MicroservicesinModernEnterprises

MicroIntegra.ons

Page 36: WSO2Con EU 2016: Understanding Microservice Architecture

WSO2MSF4J•  Alightweight,highperformanceframeworkforbuilding

microservicesinJava.•  AgendSameera’stalkonApp-Devtrack.

Page 37: WSO2Con EU 2016: Understanding Microservice Architecture

Conclusion

•  Microservicesisnotapanacea:Itwon'tsolveallyourenterpriseITneeds.

•  ‘SOAdoneright’!•  Mostenterprisewon'tbeabletoconverttheiren.reenterpriseIT

systemstomicroservices.•  EnterpriseIntegra.onnevergoesaway.•  MicroservicesareexposedasAPIs.•  Interac.onbetweenmicroservicesshouldbesupportviaa

lightweightorchestra.onengineorinsideanothermicroservice.

Page 38: WSO2Con EU 2016: Understanding Microservice Architecture

Reference

•  hgp://kasunpanorama.blogspot.co.uk/2015/11/microservices-in-prac.ce.html

•  hgp://microservices.io/pagerns/microservices.html

Page 39: WSO2Con EU 2016: Understanding Microservice Architecture

ThankYou!

#WSO2ConEU

Shareyourfeedbackforthissessionwso2con.com/app