Vert.X: Microservices Were Never So Easy (Clement Escoffier)
-
Upload
red-hat-developers -
Category
Software
-
view
553 -
download
1
Transcript of Vert.X: Microservices Were Never So Easy (Clement Escoffier)
![Page 1: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/1.jpg)
VERT.XMICROSERV ICES WERE NEVER SOEASY
CLEMENTESCOFFIER
Vert.xCoreDeveloper,RedHat
![Page 2: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/2.jpg)
VERT.XI N 1 0 SL IDES . . .
![Page 3: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/3.jpg)
VERT.X I S A TOOLK IT TO BU I LDDISTR IBUTED AND REACT IVEAPPL ICAT IONS ON TOP OF THE JVMUS ING AN ASYNCHRONOUS NON-BLOCK ING DEVELOPMENT MODEL .
![Page 4: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/4.jpg)
TOOLKITVert.xisaplainboringjarVert.xcomponentsareplainboringjarsYourapplicationdependsonthissetofjars(classpath,fat-jar,...)
![Page 5: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/5.jpg)
TOOLKITTheseslidesareservedbyavert.xapplication:
executedonOpenshiftpackagedasafatjar
vertx-core:themainvert.xcomponentvertx-web:acomponenttobuildmodernwebapplicationsvertx-hazelcast:animplementationofthevert.xclustermanagervertx-service-discovery-bridge-kubernetes:anextensiontointeractwithKubernetes
![Page 6: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/6.jpg)
DISTRIBUTED
![Page 7: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/7.jpg)
DISTRIBUTED“ Youknowyouhaveadistributedsystemwhenthecrashofacomputeryou'veneverheardsofstopsyoufromgettinganyworkdone.(LeslieLamport)
![Page 8: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/8.jpg)
REACTIVEReactivesystemsare
Responsive-theyrespondinanacceptabletimeElastic-theyscaleupanddownResilient-theyaredesignedtohandlefailuresgracefullyAsynchronous-theyinteractusingasyncmessages
http://www.reactivemanifesto.org/
![Page 9: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/9.jpg)
REACTIVE“ "Moore'slaw"istheobservationthat,overthehistoryofcomputinghardware,thenumberoftransistorsinadenseintegratedcircuithasdoubledapproximatelyevery2years.
Unfortunately,nofreelunchanymore...
![Page 10: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/10.jpg)
REACTIVECPUmanufacturerscannotgetasingle-coreCPUtogoanyfaster
Multi-coreProcessorsRequireparallelexecutionRequireadifferentwaytodesign,developandexecutesoftwareReactivesystemsisonesolutiontothisissue
![Page 11: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/11.jpg)
POLYGLOTVert.xapplicationscanbedevelopedusing
JavaGroovyRuby(JRuby)JavaScript(Nashorn)Ceylon
![Page 12: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/12.jpg)
MICROSERVICESREBRAND INGD ISTR IBUTEDAPPL ICAT IONS
![Page 13: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/13.jpg)
MICROSERVICES“ Themicroservicearchitecturalstyleisanapproachtodevelopingasingleapplicationasasuiteofsmallservices,eachrunninginitsownprocessandcommunicatingwithlightweightmechanisms,oftenanHTTPresourceAPI.Theseservicesarebuiltaroundbusinesscapabilitiesandindependentlydeployablebyfullyautomateddeploymentmachinery.Thereisabareminimumofcentralizedmanagementoftheseservices,whichmaybewrittenindifferentprogramminglanguagesandusedifferentdatastoragetechnologies.(MartinFowler)
![Page 14: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/14.jpg)
ASUITEOFINDEPENDENTSERVICES:Eachservicerunsinitsownprocess
Sotheyaredistributedapplications
Lightweightinteractions-Loose-coupling
NotonlyHTTPMessagingStreams(async)RPC
![Page 15: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/15.jpg)
ASUITEOFINDEPENDENTSERVICES:Independentlydeveloped,testedanddeployed
Automatedprocess(Liskov)substitutability
It'sallaboutagility
AgilityofthecompositionYoucanreplaceanymicroserviceYoucandecidewhouseswho
![Page 16: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/16.jpg)
SORRY...NOFREELUNCHDistributedapplicationsarehard
fail(fail-stop,byzantinefault)DiscoverabilityissueReliabilityissueAvailabilityissue
Howtokeepthingsontrack
MonitoringHealthTracing...
![Page 17: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/17.jpg)
COMPLEXITYGROWTH
![Page 18: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/18.jpg)
VERT.X&MICROSERVICESWewont'buildregularmicroservices,butreactivemicroservices
Responsive-fast,isabletohandlealargenumberofevents/connectionsElastic-scaleupanddownbyjuststartingandstoppingnodes,round-robinResilient-failureasfirst-classcitizen,fail-overAsynchronousmessage-passing-asynchronousandnon-blockingdevelopmentmodel
![Page 19: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/19.jpg)
ASYNCHRONOUS&NON-BLOCKING
![Page 20: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/20.jpg)
WHATDOESVERT.XPROVIDETOBUILDMICROSERVICES?TCP,UDP,HTTP1&2serversandclients(non-blocking)DNSclientEventbus(messaging)DistributeddatastructuresLoad-balancingFail-overServicediscoveryFailuremanagement,Circuit-breakerShell,Metrics,Deploymentsupport
![Page 21: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/21.jpg)
HTTP&RESTBECAUSE I T ALWAYSBEG IN W ITH A REST
![Page 22: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/22.jpg)
VERT.XHELLOWORLDvertx.createHttpServer() .requestHandler(request -> { // Handler receiving requests request.response().end("World !"); }) .listen(8080, ar -> { // Handler receiving start sequence completion (AsyncResult) if (ar.succeeded()) { System.out.println("Server started on port " + ar.result().actualPort()); } else { ar.cause().printStackTrace(); } });
![Page 23: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/23.jpg)
VERT.XHELLOWORLDInvoke
![Page 24: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/24.jpg)
EVENT LOOPS
![Page 25: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/25.jpg)
VERT.XASYNCHTTPCLIENTHttpClient client = vertx.createHttpClient( new HttpClientOptions() .setDefaultHost(host) .setDefaultPort(port));
client.getNow("/", response -> { // Handler receiving the response
// Get the content response.bodyHandler(buffer -> { // Handler to read the content });});
![Page 26: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/26.jpg)
SERVICEDISCOVERYLocatetheservices,environment-agnostic
![Page 27: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/27.jpg)
SERVICEDISCOVERY-KUBERNETESNoneedforpublication-ImportKubernetesservices
HttpEndpoint.getClient(discovery, new JsonObject().put("name", "vertx-http-server"), result -> { if (result.failed()) { rc.response().end("D'oh no matching service"); return; } HttpClient client = result.result(); client.getNow("/", response -> { response.bodyHandler(buffer -> { rc.response().end("Hello " + buffer.toString()); }); }); });
![Page 28: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/28.jpg)
CHAINEDHTTPREQUESTS
Invoke
![Page 29: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/29.jpg)
INTERACTINGWITHBLOCKINGSYSTEMS
![Page 30: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/30.jpg)
MESSAGINGWITHTHEEVENTBUSTHE SP INE OF VERT . X
APPL ICAT IONS
![Page 31: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/31.jpg)
THEEVENTBUSTheeventbusisthenervoussystemofvert.x:
Allowsdifferentcomponentstocommunicateregardlesstheimplementationlanguageandtheirlocationwhethertheyrunonvert.xornot(usingbridges)
Address:MessagesaresenttoanaddressHandler:Messagesarereceivedinhandlers.
![Page 32: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/32.jpg)
POINTTOPOINT
![Page 33: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/33.jpg)
PUBLISH/SUBSCRIBE
![Page 34: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/34.jpg)
REQUEST/RESPONSE
![Page 35: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/35.jpg)
DISTRIBUTEDEVENTBUSAlmostanythingcansendandreceivemessages
![Page 36: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/36.jpg)
DISTRIBUTEDEVENTBUSLet'shaveajava(Vert.x)app,andanodeappsendingdatajusthere:
hellofromjava(8321)
hellofromjava(8320)
hellofromjava(8319)
hellofromjava(8318)
hellofromjava(8317)
hellofromjava(8316)
hellofromjava(8315)
hellofromjava(8314)
hellofromjava(8313)
![Page 37: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/37.jpg)
DISTRIBUTEDEVENTBUS
![Page 38: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/38.jpg)
EVENTBUSCLIENTSANDBRIDGESClients:
SockJS:browser,node.jsTCP:everysystemabletoopenaTCPsocketGo:forsystemdevelopinGo
Bridges:
StompAMQPCamel
![Page 39: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/39.jpg)
RELIABILITYPATTERNS
DON 'T BE FOOL , BEPREPARED TO FA IL
![Page 40: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/40.jpg)
RELIABILITYIt'snotaboutbeingbug-freeorbulletproof,it'simpossible.
It'saboutbeingpreparedtofail,andhandlingthesefailures.
![Page 41: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/41.jpg)
MANAGINGFAILURESDistributedcommunicationmayfail
vertx.eventbus().send(..., ..., new DeliveryOptions().setSendTimeout(1000), reply -> { if (reply.failed()) { System.out.println("D'oh, he did not reply to me !"); } else { System.out.println("Got a mail " + reply.result().body()); }});
![Page 42: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/42.jpg)
MANAGINGFAILURES
Invoke
![Page 43: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/43.jpg)
MANAGINGFAILUREclient.get("/", response -> { response .exceptionHandler(t -> { // If the content cannot be read rc.response().end("Sorry... " + t.getMessage()); }) .bodyHandler(buffer -> { rc.response().end("Ola " + buffer.toString()); }); }) .setTimeout(3000) .exceptionHandler(t -> { // If the connection cannot be established rc.response().end("Sorry... " + t.getMessage()); }) .end();
![Page 44: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/44.jpg)
MANAGINGFAILURE
Invoke
![Page 45: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/45.jpg)
CIRCUITBREAKER
![Page 46: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/46.jpg)
CIRCUITBREAKERcb.executeWithFallback(future -> { // Async operation client.get("/", response -> { response.bodyHandler(buffer -> { future.complete("Ola " + buffer.toString()); }); }) .exceptionHandler(future::fail) .end(); },
// Fallback t -> "Sorry... " + t.getMessage() + " (" + cb.state() + ")") // Handler called when the operation has completed .setHandler(content -> /* ... */);
![Page 47: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/47.jpg)
CIRCUITBREAKER
Invoke
![Page 48: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/48.jpg)
SCALABILITYPATTERNS
BE PREPARED TO BEFAMOUS
![Page 49: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/49.jpg)
BALANCINGTHELOADWhenseveralconsumerslistentothesameaddress,Vert.xdispatchesthesentmessagesusingaroundrobin.
So,toimprovethescalability,justspawnanewnode!
![Page 50: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/50.jpg)
BALANCINGTHELOAD
![Page 51: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/51.jpg)
BALANCINGTHELOADInvoke
![Page 52: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/52.jpg)
SCALINGHTTP
![Page 53: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/53.jpg)
THISISNOTTHEEND()
BUTTHEFIRSTSTEPONTHEREACTIVEMICROSERVICEROAD
![Page 54: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/54.jpg)
![Page 55: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/55.jpg)
HOWTOSTART?http://vertx.iohttp://vertx.io/blog/posts/introduction-to-vertx.htmlhttp://vertx-lab.dynamis-technologies.comhttps://github.com/vert-x3/vertx-examples
![Page 56: Vert.X: Microservices Were Never So Easy (Clement Escoffier)](https://reader034.fdocuments.us/reader034/viewer/2022042723/586fdbd61a28ab18428b62a9/html5/thumbnails/56.jpg)
RedHatNews
youtube.com/RedHat
facebook.com/redhatinc
THANKYOU!
linkedin.com/company/red-hat