Contenu connexe Plus de Michael Hofmann (6) Microservices with JEE - Best Practices and a Close Look using WebSphere Liberty Profile1. Microservices with JEE
Best Practices and a Close Look using
WebSphere Liberty Profile
Michael Hofmann, ARS Computer und Consulting GmbH
and
Erin Schnabel, IBM
IBM InterConnect 2017 Conference (Session ID: BMC-4741)
2. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
2
IBM Redbook
Motivation
market interest
missing literature about
microservices
with Java showing best practices
even less literature on
microservices with Java EE
Target
Microservices with Java and
Java EE from development
to production
3. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
3
Twelve factor applications
“A methodology for building
software-as-a-service applications”
Factors are independent of
programming language
backing services
cloud provider
http://12factor.net/
4. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
4
Factor 2 - Dependencies
Key points:
App declares all dependencies
App doesn’t rely on “pre-requisite”
system-wide packages
use dependency isolation tool (build
time, e.g. Gradle)
Runtime aspect:
Liberty Features declared in
server.xml
Package application with Liberty
5. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
5
Factor 3 - Config
Key points:
Config includes anything that
can vary between deploys
does not include internal
application config
Liberty:
central config file
can be managed in source
repository (scm)
dynamic reload
JNDI variables
6. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
6
Factor 4 - Backing Services
Key points:
Backing services
e.g. Datastore, Watson, ….
Resources can be
attached and detached at will
Java and Java EE support a lot
of different backing services…
7. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
7
Backing Service
Polyglot Persistence
SQL
NoSQL
Messaging Systems
Java Messaging System (JMS) Client
AMQP
MQTT
8. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
8
Factor 5 – Build, Release, Run
Key points:
strict separation between
stages: Build, Release, Run
e.g. no code changes at runtime
The Liberty way:
Build pipeline!
Git commit to master -> build -> live!
Liberty in docker container
Liberty own packaging feature
9. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
9
Package … deploy … config
One single executable JAR file
Spring Boot
Wildfly Swarm (JBoss)
IBM WebSphere Liberty
All alternatives
Application together with
external configuration (immutable artifact) and
necessary runtime
in minimalised form
augmented with functions for metrics and health care
10. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
10
Factor 8 - Concurrency
Key points:
Recommends splitting processes
based on the type of work
Scale by making more processes
Liberty supports:
Autoscaling
Dynamic Routing
Cluster
Elasticity
11. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
11
Scalability
Core characteristic of a microservice
Better when microservices scale automatically
Disadvantage of static provisioning
Spring Boot und Wildfly Swarm depend on infrastructure
Liberty has additional features
12. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
12
Liberty features for Scalability
Fast startup time
Low memory footprint
IBM supports Liberty in a docker container
Liberty Collectives and Cluster with Autoscaling und Dynamic-
Routing
Automatic scaling with Liberty exclusive features possible!
13. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
13
IBM WAS Liberty Collective
14. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
14
IBM WAS Liberty Collective with Dynamic Routing
15. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
15
Liberty elasticity
Scaling Controller installs new Liberty servers
Minimal installation package
(server + app)
Host leader
communicates with Scaling Controller
monitors workload
informs members about commands from Scaling Controller
Polyglot environments
StrongLoop server
Liberty server
Liberty Docker containers
16. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
16
Factor 11 - Logs
Key points:
A 12-factor app never concerns
itself with routing or storage of
its output stream
Process streams are captured
by the execution environment
Usage of:
Liberty feature for ELK-Stack
Create correlation-ID with UUID
to track calls across service
boundaries
17. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
17
Factor 12 – Admin processes
Key points:
Keep admin task code with
application code
Run admin tasks in an identical
environment to the app
Run against a “Release”
/ Same config
Same dependency isolation:
gradlew
bundle exec
python virtualenv
18. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
18
Liberty Monitoring/Administration
Liberty feature: monitor-1.0
Collects performance data at runtime
Accessible with JMX or REST
Liberty feature: adminCenter-1.0
Admin-Web-Client:
used heap memory
loaded classes
active JVM threads
CPU usage
other metrics, depending on resource
19. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
19
High demands on prod stage
Liberty healthManager-1.0 and healthAnalyzer-1.0
Max. percent of request timeouts and max. response time
Intense memory consumption
Potential Memory-Leaks
Results in the following actions:
Server restart
Create Heap or Thread Dump
Toggle server to Maintenance Mode
Executed on:
Host, Cluster or Server
20. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
20
http://MicroProfile.io
21. © ARS Computer und Consulting GmbH 2017
Microservices with JEE
21
Contact information
Michael Hofmann, ARS Computer und Consulting GmbH
michael.hofmann@ars.de
www.ars.de
Erin Schnabel, IBM
schnabel@us.ibm.com
Twitter: @ebullientworks