Download - Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Transcript
Page 1: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Building microservices with Vert.xBert Jan Schrijver

AMSTERDAM 11-12 MAY 2016

@bjschrijver

Page 2: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Let’s meet

Bert Jan Schrijver

@bjschrijver

Page 3: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Introduction -Why Vert.x? - Basic demo - Deep dive - Advanced demo -Microservices with Vert.x - Vert.x in practice

Outline

Page 4: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Introduction -Why Vert.x? - Deep dive - Demo -Microservices with Vert.x

Introduction

MalmbergisaneducationalpublisherintheNetherlands. Malmbergisbuildingmodern,richandscalablee-learning

applicationsusingJava8,Vert.x,AngularJSandMongoDB,

runningonAmazoncloudservices.

Page 5: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Vert.x basics

@bjschrijver

Page 6: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Toolkit for building reactive applications on the JVM - General purpose application framework - Swiss army knife for building modern and scalable

web apps - Event-driven, non-blocking - Polyglot - Lightweight and fast - Fun to work with!

Vert.x: the basics

Page 7: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

-We love open source - Powerful module system - Reactive characteristics

Why did we choose Vert.x?

Page 8: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Vert.x is reactive

Page 9: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Demo

@bjschrijver

Page 10: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Vert.x in depth

@bjschrijver

Page 11: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Verticle, application, instance, JVM:

Vert.x in depth

Host

JVMVert.x instance

Verticle Verticle

Verticle Verticle

Event Bus

JVMVert.x instance

Verticle Verticle

Verticle Verticle

Page 12: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Verticle, application, instance, JVM:Host

Vert.x in depth

Host

JVMVert.x instance

Verticle Verticle

Verticle Verticle

Event Bus

JVMVert.x instance

Verticle Verticle

Verticle Verticle

Page 13: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Event driven and non blocking event loop -Multi-reactor pattern - Actor-like concurrency - Distributed event bus -Management and monitoring built-in

Vert.x in depth

Page 14: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Both request/response and publish/subscribe -Messages are received by Handlers - All Vert.x instances have access to the

event bus - Verticles interact using messages

Vert.x event bus

Page 15: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Never ever ever block the event loop - Need to to blocking stuff? Use a worker

Vert.x’s golden rule

Page 16: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Source: http://www.slideshare.net/clement.escoffier/vertx-31-be-reactive-on-the-jvm-but-not-only-in-java

Vert.x in one slide

Page 17: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Demo

@bjschrijver

Page 18: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Vert.x & microservices

@bjschrijver

Page 19: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Small in size, single responsibility - Runs in its own process - Has its own data store - Distributed by default - Independently develop, deploy, upgrade, scale - Potentially heterogeneous/polyglot - Light-weight communication

Anatomy of a microservice

Page 20: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

microserviceAnatomy of a Vert.x module

- Small in size, single responsibility - Runs in its own process - Has its own data store - Distributed by default - Independently develop, deploy, upgrade, scale - Potentially heterogeneous/polyglot - Light-weight communication

Page 21: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Vert.x in practice

@bjschrijver

Page 22: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Organisation structure: - Core platform team (infrastructure) - Core modules team (Vert.x modules) - Product teams

- Deployment model: AWS, Nginx, MongoDB -Multiple lightweight artifacts

3 years of Vert.x: situation

Page 23: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

3 years of Vert.x: deployments

- Rolled our own deployment tooling and open sourced it(https://github.com/msoute/vertx-deploy-tools) - Controlled from Jenkins - Zero-downtime deployments -Microservice deployments

Page 24: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Very suitable for test driven development - Integration tests with embedded MongoDB - Good cooperation from the Vert.x team

3 years of Vert.x: experiences

Page 25: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Callback hell - Java 8 helped a LOT - Rx fixes the remaining issues

- Blocking the event loop - Scaling / JVM overhead - Debugging - Static code analysis - Upgrade from Vert.x 2 to Vert.x 3

3 years of Vert.x: challenges

Page 26: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Almost there ;-)

@bjschrijver

Page 27: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- Vert.x: toolkit for reactive applications on the JVM - Polyglot, event-driven - Very suitable for building microservices

Summary

Page 28: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

- https://github.com/bertjan/vertx3-examples - http://vertx.io - http://vertx.io/blog/my-first-vert-x-3-

application - https://github.com/vert-x3/vertx-examples - http://github.com/msoute/vertx-deploy-tools

Resources

Don’t worry, I’ll tweet a link to the slide deck ;-)

Page 29: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Q & A

@bjschrijver

Page 30: Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterdam 2016

Thanks!

@[email protected]

All pictures belong to their respective authors

AMSTERDAM 9-12 MAY 2016