Just enough app server

60
Just Enough App Server by antonio goncalves @agoncal

Transcript of Just enough app server

Page 1: Just enough app server

Just Enough App Server

by antonio goncalves@agoncal

Page 2: Just enough app server

2 @agoncal

Antonio Goncalves

Page 3: Just enough app server

Take what you need from Java EE

and resize your App Server

Page 4: Just enough app server

4 @agoncal

How do we see Java EE App Servers ?

One Monolith !SlowFat

Heavyweight

Old

Not sexy

Boring

Page 5: Just enough app server

App servers are

monolithic !

Page 6: Just enough app server

6 @agoncal

Java EE

Page 7: Just enough app server

7 @agoncal

Web Profile

Page 8: Just enough app server

8 @agoncal

Servlets

Page 9: Just enough app server

9 @agoncal

Three types of Java EE App Servers

Three Monoliths !

Page 10: Just enough app server

10 @agoncal

Bits & Pieces

Page 11: Just enough app server

11 @agoncal

Servlets

JSP

Expression LanguageServlets

JSTL

Page 12: Just enough app server

12 @agoncal

Web Profile

JSP

Expression LanguageServlets

JSTL

Interceptors JAX-RS

JSON-P

CDI

JPAWebSocket

JTA

Bean Validation

Page 13: Just enough app server

13 @agoncal

Java EE

JSP

Expression LanguageServlets

JSTL

Interceptors JAX-RS

JSON-P

CDI

JPAWebSocket

JTA

Bean Validation

JMSJSFJAX-WS EJB

JavaMail

JCA

Concurrency

Batch

JASPIC

Page 14: Just enough app server

14 @agoncal

JVM

JSP

Expression LanguageServlets

JSTL

Interceptors JAX-RS

JSON-P

CDI

JPAWebSocket

JTA

Bean Validation

JMSJSFJAX-WS EJB

JavaMail

JCA

Concurrency

Batch

JASPIC

JVM

Page 15: Just enough app server

15 @agoncal

JVM

JTA

JMS

JSP

Interceptors JAX-RS

Expression Language

JSF

Servlets

JSON-P

CDI

JAX-WS

JPA

Bean Validation

EJB

JavaMailWebSocket

JSTL

JCA

Concurrency

Batch

JASPIC

JDBC JNDI Logging JAX-B JMXCommons

Annotations

Page 16: Just enough app server

16 @agoncal

Your own app

JTA

JMS

JSP

Interceptors JAX-RS

Expression Language

JSF

Servlets

JSON-P

CDI

JAX-WS

JPA

Bean Validation

EJB

JavaMailWebSocket

JSTL

JCA

Concurrency

Batch

JASPIC

JDBC JNDI Logging JAX-B JMXCommons

Annotations

My code

Page 17: Just enough app server

17 @agoncal

Your own app dependencies

JTA

JMS

JSP

Interceptors JAX-RS

Expression Language

JSF

Servlets

JSON-P

CDI

JAX-WS

JPA

Bean Validation

EJB

JavaMailWebSocket

JSTL

JCA

Concurrency

Batch

JASPIC

JDBC JNDI Logging JAX-B JMXCommons

Annotations

My code SLF4J Angular ReactPrimefaces Bootstrap JQuery

Page 18: Just enough app server

App servers are

slow !

Page 19: Just enough app server

19 @agoncal

Startup time of App Servers

Page 20: Just enough app server

20 @agoncal

Startup time of JBoss

Using a Windows XP virtual machine (Virtual Box)

3.2.8 4.2.3 5.1 6.1 7 Beta0

5

10

15

20

25

30

35

40

Startup time

Specs

Page 21: Just enough app server

App servers

consume resources !

Page 22: Just enough app server

22 @agoncal

Memory consumption of App Servers

Page 23: Just enough app server

App servers use

outdated packaging !

Page 24: Just enough app server

24 @agoncal

Your own app… needs packaging

JTA

JMS

JSP

Interceptors JAX-RS

Expression Language

JSF

Servlets

JSON-P

CDI

JAX-WS

JPA

Bean Validation

EJB

JavaMailWebSocket

JSTL

JCA

Concurrency

Batch

JASPIC

JDBC JNDI Logging JAX-B JMXCommons

Annotations

My code SLF4J Angular ReactPrimefaces Bootstrap JQuery

Page 25: Just enough app server

25 @agoncal

Skinny War

JTA

JMS

JSP

Interceptors JAX-RS

Expression Language

JSF

Servlets

JSON-P

CDI

JAX-WS

JPA

Bean Validation

EJB

JavaMailWebSocket

JSTL

JCA

Concurrency

Batch

JASPIC

JDBC JNDI Logging JAX-B JMXCommons

Annotations

My code SLF4J Angular ReactPrimefaces Bootstrap JQuery

Page 26: Just enough app server

26 @agoncal

My code

Fat War

JTA

JMS

JSP

Interceptors JAX-RS

Expression Language

JSF

Servlets

JSON-P

CDI

JAX-WS

JPA

Bean Validation

EJB

JavaMailWebSocket

JSTL

JCA

Concurrency

Batch

JASPIC

JDBC JNDI Logging JAX-B JMXCommons

Annotations

SLF4J ApacheCommons Drools SLF4J Angular React

Page 27: Just enough app server

Demo

CD-BookStoreTop BooksTop CDs

https://github.com/agoncal/agoncal-sample-javaee/06-EnoughAppServer

Page 28: Just enough app server

3 apps

3 different needs !

Page 29: Just enough app server

29 @agoncal

CD-Book Store

JTA

JMS

JSP

Interceptors JAX-RS

Expression Language

JSF

Servlets

JSON-P

CDI

JAX-WS

JPA

Bean Validation

EJB

JavaMailWebSocket

JSTL

JCA

Concurrency

Batch

JASPIC

JDBC JNDI Logging JAX-B JMXCommons

Annotations

My code Primefaces Bootstrap JQuery

Page 30: Just enough app server

30 @agoncal

Top Books

JTA

JMS

JSP

Interceptors JAX-RS

Expression Language

JSF

Servlets

JSON-P

CDI

JAX-WS

JPA

Bean Validation

EJB

JavaMailWebSocket

JSTL

JCA

Concurrency

Batch

JASPIC

JDBC JNDI Logging JAX-B JMXCommons

Annotations

My code

Page 31: Just enough app server

31 @agoncal

Top CDs

JTA

JMS

JSP

Interceptors JAX-RS

Expression Language

JSF

Servlets

JSON-P

CDI

JAX-WS

JPA

Bean Validation

EJB

JavaMailWebSocket

JSTL

JCA

Concurrency

Batch

JASPIC

JDBC JNDI Logging JAX-B JMXCommons

Annotations

My code

Page 32: Just enough app server

What a Waste !

Let's package what we need…

...in a “uber” Jar

Page 33: Just enough app server

33 @agoncal

My code

CD-Book Store

JTAInterceptors

JAX-RS

Expression Language

JSF

Servlets

JSON-PCDI

JPA

Bean Validation

EJB

JDBC JNDI Logging JAX-BCommons

Annotations

Primefaces Bootstrap JQuery

Page 34: Just enough app server

34 @agoncal

My code

Top Books

JTAInterceptors

Expression LanguageServlets

JSON-PCDI

JPA

Bean Validation

JDBC JNDI Logging JAX-BCommons

Annotations

JAX-RS

Page 35: Just enough app server

35 @agoncal

My code

Top CDs

Servlets

CommonsAnnotations Logging

Page 36: Just enough app server

36 @agoncal

Several solutions to choose from

● Full Java EE● WildFly Swarm● Payara Micro● TomEE● KumuluzEE

● “Sort of” Java EE● Spring Boot

● Other● Dropwizard● Lagom

Page 37: Just enough app server

Demo

WildFly Swarm

https://github.com/agoncal/agoncal-sample-javaee/06-EnoughAppServer

Page 38: Just enough app server

And what about multiple apps ?

Page 39: Just enough app server

39 @agoncal

My code

Top CDsssssssss

Servlets

CommonsAnnotations Logging

My code

Servlets

CommonsAnnotations

Logging

My code

Servlets

CommonsAnnotations

Logging

My code

Servlets

CommonsAnnotations Logging

My code

Servlets

CommonsAnnotations

Logging

My code

Servlets

CommonsAnnotations

Logging

Page 40: Just enough app server

40 @agoncal

My code

Top CDsssssssss

CommonsAnnotations Logging

My code

CommonsAnnotations

Logging

My code

CommonsAnnotations

Logging

My code

CommonsAnnotations Logging

My code

CommonsAnnotations

Logging

My code

CommonsAnnotations

Logging

ServletsLocal Maven Repo

If only we had Jigsaw !

Page 41: Just enough app server

Demo

WildFly Swarmwith M2_REPO

https://github.com/agoncal/agoncal-sample-javaee/06-EnoughAppServer

Page 42: Just enough app server

Some metrics

Page 43: Just enough app server

43 @agoncal

Packaging Size

Page 44: Just enough app server

44 @agoncal

Startup time

Page 45: Just enough app server

And how do I manage it now ?

Page 46: Just enough app server

46 @agoncal

Configure your apppublic class MyMain { public static void main(String...args) { new Container() .fraction(new DatasourcesFraction() .jdbcDriver("h2", (d) -> { d.driverClassName("org.h2.Driver"); d.driverModuleName("com.h2database.h2"); }) .dataSource("ExampleDS", (ds) -> { ds.driverName("h2"); ds.connectionUrl("jdbc:h2:mem:test"); ds.userName("foo"); ds.password("bar"); })) .start() .deploy();

Page 47: Just enough app server

Demo

WildFly Swarmwith management

https://github.com/agoncal/agoncal-sample-javaee/06-EnoughAppServer

Page 48: Just enough app server

And what about Docker ?

Page 49: Just enough app server

49 @agoncal

Dockerfile

FROM java:openjdk-8-jdk

EXPOSE 8081

ADD target/topcds-swarm.jar /opt/topcds-swarm.jarENTRYPOINT ["java", "-jar", "/opt/topcds-swarm.jar"]

Page 50: Just enough app server

Demo

Docker

https://github.com/agoncal/agoncal-sample-javaee/06-EnoughAppServer

Page 51: Just enough app server

Demo

Raspberry PI

https://github.com/agoncal/agoncal-sample-javaee/06-EnoughAppServer

Page 52: Just enough app server

Final word

Page 53: Just enough app server

53 @agoncal

Wildfly Swarm

● Based on good old JBoss AS● Bundles several fractions

● Java EE● Netflix OSS (Ribbon, Hystrix, RxJava)● Spring● Logstash● Swagger● ...

Page 54: Just enough app server

54 @agoncal

Java EE App Servers

● Java EE app server have changed● Are not monolithic, slow, consume resources ● Package the way you want (skinny/fat war, uber

jar)● Re-use your Java EE expertise● Look Ma, « Microservices inside »● « I’m centralised and I’m proud! »

Page 55: Just enough app server

That's it !

Page 56: Just enough app server

56 @agoncal

http://amazon.com/author/agoncal

Page 57: Just enough app server

57 @agoncal

https://www.pluralsight.com/authors/antonio-goncalves

Page 58: Just enough app server

Thanks

[email protected]

@agoncal@pluralsight

@devoxxfr@lescastcodeurs

Page 59: Just enough app server

Q & A

Page 60: Just enough app server

60 antonio goncalves

Creative Commons

● Attribution — You must attribute the work inthe manner specified by the author or licensor(but not in any way that suggests that theyendorse you or your use of the work).

● Noncommercial — You may not use this work forcommercial purposes.

● Share Alike — If you alter, transform, or buildupon this work, you may distribute the resultingwork only under the same or similar license tothis one.