voxxed days thesaloniki 2016 - rightsize your services with wildfly & wildfly swarm

54
@dandreadis Right size you services with & Dimitris Andreadis Sr. Engineering Manager Red Hat JBoss EAP / WildFly

Upload: voxxed-days-thessaloniki

Post on 15-Apr-2017

114 views

Category:

Software


0 download

TRANSCRIPT

@dandreadis

Right size you serviceswith &

Dimitris Andreadis

Sr. Engineering ManagerRed Hat JBoss EAP / WildFly

@dandreadis

Once upon a time*

*http://dandreadis.blogspot.ch/2014/10/10-years-on-red-pill.html

@dandreadis

“WildFly:

the Swiss ArmyKnife of Runtimes”

@dandreadis

Agenda

● WildFly Architecture

● Thinking Microservices

● WildFly Swarm

@dandreadis

WildFly* pre-History

*the server once called JBoss Application Server

@dandreadis

Kernel Taxonomy

● JBoss AS 2.x, 3.x, 4.x– JMX MicroKernel

● JBoss AS 5.x, 6.x– JBoss MicroContainer

● AS7.x, WildFly 8.x, 9.x, 10.x– Modular Service Container

@dandreadis

Modular Service Container

● Small, lightweight and efficient (˜230 kb jar)

● Highly concurrent & scalable state machine

● Various start-up modes– Active, Passive,

Lazy, Never

Concurrent Service ContainerConcurrent Service Container

Service ControllerService Controller

Service RegistryService Registry

Service BuilderService Builder

ServiceService DepsDeps ValueValue ListenersListeners InjectorsInjectors

@dandreadis

JBoss Modules

● WF_ROOT/jboss-modules.jar (365 kb)– Highly Concurrent Classloading

– Fast O(1) dependency resolution

– See only the modules you import

– No need to break open the jars

java -jar jboss-modules.jar -mp <module-path> <module-spec>

module.xml

@dandreadis

WildFly Architecture

Java EE7 Full & Webdistribution (134 Mb)

standalone/ configuration/ configuration.xml

Servlet-Onlydistribution (28 Mb)

standalone/ configuration/ configuration.xml

@dandreadis

Out-of-the-box configurations

● standalone.xml – Web Profile++ (default)– standalone-ha – with clustering

● standalone-full.xml – plus JMS/ActiveMQ, IIOP, JSR77– standalone-full-ha – with clustering

● domain.xml – full-ha in domain management mode– Plus load-balancer Profile

@dandreadis

Domain Mode

@dandreadis

Load Balancer Setup

● Fully managed end-to-endJava-based solution

● WF/Undertow can serve as– Static file server

– Reverse Proxy

@dandreadis

Next Gen Web Server – Undertow

● JBossWeb replacement(fork of Tomcat)

● Scalable Async Core w.Blocking/Non-Blocking APIs

● Handler/Compositionbased Architecture

● Lightweight & fullyembeddable

● Servlet 3.1

● Latest Protocol Support– HTTP/1.x / HTTPS / AJP

– HTTP/2 (Plain & TLS-ALPN)

– Web Sockets (JSR-356)

– Server Sent Events

@dandreadis

Undertow Performance

*source: techempower.com

@dandreadis

Port Reduction using HTTP Upgrade

Only 2 Ports Open by Default

● 8080 – HTTP for Applications– Upgradable to JNDI, EJB, JMS

● 9990 – HTTP for Management (Console/JSON)– Upgradable to Native Management API (CLI/JMX)

@dandreadis

Unified Configuration

@dandreadis

Let’s talk Microservices

@dandreadis

What are Microservices?

This slide intentionally left blank

Martin Fowler definition omitted

@dandreadis

What are Microservices?

● A bit like SOA (but smaller?)

● Written in any cool programming language

● By (smaller?) two-pizza teams

● Who break monoliths into (small?) services

● That encapsulate fully some (small?) vertical application aspect

● And run them independently in their own (smaller?) containers

● Using fully automated deployment machinery

● Did I say small?

@dandreadis

What Enabled Microservices?

● Elastic infrastructure, a.k.a the Cloud

● Linux Containers (Docker, Rocket, etc.)

● Orchestration Technologies (Kubernetes, Mesos, etc)

● Continuous Integration / Deployment

● The DevOps movement

Caused by the need for Internet Scale

@dandreadis

Simpler services but more complex environments

*source: wikibon.com/evolving-container-arhitectures

@dandreadis

A Word of Caution

● Every remote call will likelybe x100 slower than anin-VM call

● You need to actively codefor failure when crossingVMs

● Sharing state needs to bewell thought of (or avoided)

@dandreadis

A different view of Microservices

@dandreadis

Welcome to WildFly Swarm

@dandreadis

What is WildFly Swarm?

● WildFly Broken Apart– Decompose and reconstruct WildFly

around your application

– With additional functionality outside Java EElike NetflixOSS libraries, etc.

– Just enough app-server for your Microservicepackaged into an UberJar

● Part of the JBoss / Red Hat ecosystem

@dandreadis

Why WildFly Swarm?

● Leverage your Java EE expertise

● Build on mature technologiesand a scalable runtime

● Be part of the future of Java EEand help shape it for the Cloud

Is portability and supportability a thing of the past?

@dandreadis

Rightsize your Runtime around your App

@dandreadis

Pick up the EE pieces you really need

@dandreadis

Plus a lot more components!

● Keycloak (SSO)

● Hystrix (Circuit Breaker)

● Ribbon (client side LB)

● Vert.x (reactive)

● Undertow (web server)

● Camel (integration)

● Hashicorp Consul (discovery)

● Swagger (service contracts)

● LogStash (log aggregation)

● and more...

@dandreadis

Self-contained (Uber) Jar

● bundles your application,

● the Fractions to support it,

● an internal Maven repository withthe dependencies,

● and Bootstrap code.

● There is also the notion of aHollow launch-pad type of jar.

@dandreadis

Fractions

● WildFly Swarm compositional units

● Focus on serving specific usecases

● Define dependencies to other Fractions

● Tie together– Metadata

– WildFly subsystems

– MSC Services

– Modules

– Deployments

@dandreadis

Fractions layer on WildFly-Core and

● Enable WildFly subsystems (e.g. Infinispan)

● Integrate additional frameworks/services (e.g. Topology)

● Provide deployments (e.g. Swagger, Jolokia)

● Add API dependencies (e.g. JAX-RS)

● Alter deployments (e.g. SSO)

@dandreadis

Fractions (cont.)

● Expressed as Maven (GAV) coordinates:– org.wildfly.swarm:<fraction>:<version>, e.g

– org.wildfly.swarm:undertow:2016.10.0

● 83 fractions currently available– 48 stable

– 35 experimental

● About 50% wrap WildFly components

● More in the pipeline

@dandreadis

Where do I start?

http://wildfly-swarm.io/generator/

@dandreadis

@dandreadis

demo.zip (1kb)

├── pom.xml

└── src

└── main

└── java

└── com

└── example

└── demo

└── rest

└── HelloWorldEndpoint.java

@dandreadis

HelloWorldEndpoint.java

@dandreadis

How is WildFly Swarm enabled?

@dandreadis

Building / Running

● Build:

– mvn package

● Run:

– mvn wildfly-swarm:run

– java -jar demo-swarm.jar

– IDE > Run … MyMain

– IDE > Run o.w.s.Swarm

@dandreadis

@dandreadis

@dandreadis

demo-swarm.jar (9.3Mb)

...

_bootstrap/demo.war

m2repo/<fractions & modules jars>

modules/<bootstrap-modules.xml

<bootstrap-classes>

...

@dandreadis

Auto-detecting Fractions

● Absence of dependenciestriggers fractionDetectMode

● In this example JAXRS isdetected, leaving out BeanValidation, CDI &Transactions

● 4.3Mb jar

● 1330msboot time

@dandreadis

How Fractions are configured?

● Default configuration with sensible defaults

● System properties to override common settings

● standalone.xml or a fragment of it can override settings

● - or -

● Take control of main() and use the fluent Java API– Covers all WildFly subsystems

– Generated from the WF configuration schema

@dandreadis

Taking control of main()

@dandreadis

Setup JDBC driver and Datasource

@dandreadis

Find out more…

wildfly-swarm.gitbooks.io/wildfly-swarm-users-guide/

@dandreadis

Who’s said Java EEneeds to be boring?

@dandreadis

Resources

● www.wildfly.org● github.com/wildfly

● @wildflyAS

● wildfly.org/joinus

● wildfly-swarm.io● github.com/wildfly-swarm

● @wildflyswarm

● irc: #wildfly-swarm

microprofile.io