Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Microservices mit Jersey und einem In-Memory Data Grid JFS, Juli 2016
Peter Doschkinow Michael Bräuer
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
3
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Agenda
• Microservices
– Java EE and Microservices
• Oracle lightweight technologies for microservices
• Demos
4
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Characteristics of Existing Monolith Architecture
5
The status quo has served us well but there are new alternatives
Hardware
Operating System
Hypervisor
Operating System
Application Container
Large Monolithic Application One large archive, including UI(s) and application code
VM
• Three tiers
• Scale by cloning behind load balancer (X-axis scaling)
• One programming language
• Everything centralized – messaging, storage, database, etc
Feature-rich – support large, complicated applications, many use cases
Provide 100% isolation between tenants
Procured and manually set up
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Existing Monolith Architecture Has its Limits
6
Too Slow Teams split up by function – UI,
application, middleware, database, etc. Takes forever to get anything done due to
cross-ticketing
Too Fragile A bug will quickly bring down an entire
application. Little resiliency
Inefficient Testing Each time you touch the application, you have to re-test the whole thing. Hard to
support continuous delivery
No Ownership Code falls victim to “tragedy of the
commons” – when there’s little ownership, you see neglect
Too Complex Apps get too big and complicated for a
developer to understand over time. Shared layers (ORM, messaging, etc) have to handle
100% of use cases – no point solutions
No Ownership
Too Slow
No Specialization
Too Complex
Inefficient Testing
Too Fragile
No Specialization Different parts of applications have different needs – more CPU, more
memory, faster network, etc.. Can not evolve at a different pace
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
What Are Microservices?
7
Minimal function services that are deployed separately but can interact together to achieve a broader use-case
Status Quo Microservices
Single, Monolithic App
Must Test/Deploy/Scale Entire App
One Database for Entire App
In-process Calls Locally, SOAP Externally
Organized Around Technology Layers
One Technology Stack for Entire App
Developers Don’t Do Ops
Many, Smaller Minimal Function Microservices
Can Test/Deploy/Scale Each Microservice Independently
Each Microservice Has Its Own Datastore
REST Calls Over HTTP, Messaging, or Binary
Organized Around Business Capabilities (Bounded Ctx)
Choice of Technology for Each Microservice
Developers + Ops Support Production in Perpetuity
New infrastructure, design patterns and goals
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• Microservices
– Smart endpoints, dumb pipes
– Goals: Agility and Scalability
– APIs: Private (Within the Application)
– New Design Patterns and Infrastructure
• SOA
– Dumb endpoints, smart pipes
– Goals: Composition and Reuse
– APIs: Published (Outside the Application)
– Traditional Patterns and Infrastructure
8
Microservices vs. SOA
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Benefits of Microservices Come With Costs
9
Increase Agility
Massive Scalability (develoment too!)
Strong Module Boundaries
Independent Deployment
Each team is free to deploy what/when they want
Ability to Pick Different Technology
Each team can pick the best technologies for each microservice
Distributed Computing
Microservice deployed separately, with latency separating each service
Eventual Consistency
System as a whole is eventually consistent because data is fragmented
Operational Complexity
Need mature DevOps team, with very high skills
Be
ne
fits
Co
sts
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 10
Monolitic Deployment
Feature
Feature
Feature
Feature
Developer
Developer
Developer
Developer
QA Release
Integration
Production Replace old with
new Release
• Infrequent releases (months) • Limited scale • High risk • One technology
Bugs
Bugs
Gartner Application Architecture, Development & Integration Summit, May 2016
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 11
Microservices Deployment
Feature
Feature
Feature
Feature
Feature Team
Feature Team
Feature Team
Feature Team
Old Release still running
• Release when ready • Autonomous teams • Scaling of development • Polyglot
Bugs
Deploy feature to Production
Deploy feature to Production
Deploy feature to Production
Deploy feature to Production
Deploy feature to Production
Gartner Application Architecture, Development & Integration Summit, May 2016
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Microservices: The Bottom Line
– Majority of systems just fine as “monoliths”
– Majority of systems needing microservices could evolve into “hybrids”
– Few practical enterprise systems can or need to achieve microservices nirvana
12
… don’t even consider microservices unless you have a system that’s too complex to manage as a monolith. The majority of software systems should be built as a single monolithic application. Do pay attention to good modularity within that monolith, but don’t try to separate it into separate services
http://martinfowler.com/bliki/MicroservicePremium.html
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Microservices Related Technologies
• Frameworks: fat jars, “containerless”
– Spring Boot, Dropwizard, Vert.x
– WildFly Swarm, Payara Micro(GlassFish), KumuluzEE, TomEE Embedded
– Grizzly(HTTP) + Jersey(JAX-RS) + Tyrus(WebSocket) + ...
• Virtualization
–Docker Container, WebLogic Microcontainer
• Cloud
–IaaS, PaaS
• Java libraries for reactive programming and microserivices patterns
–RxJava, Hystrix
13
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Building blocks for pragmatic microserveces
Java EE and Microservices
JAX-RS JMS
JSON-P CDI Bean
Validation
EJB JPA JTA
Administration Monitoring High
Availability Security Resources
WebSocket Servlet
JCA
JAXB
14
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
http://microprofile.io initiative
Java EE and Microservices
JAX-RS JMS
JSON-P CDI Bean
Validation
EJB JPA JTA
Administration Monitoring High
Availability Security Resources
WebSocket Servlet
JCA
JAXB
15
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
WebLogic Multitenant Microcontainer for Microservices
• Each microservice instance can have its own light-weight WebLogic container-like partition
• Partition isolation inside the JVM
• Easily move partitions between WebLogic hosts
• Each partition is exceptionally light
• Each WebLogic host can support hundreds of partitions
16
Similar to Oracle Database pluggable/container databases
WebLogic
JVM
Microservice
OS Process
Operating System Instance
Microservice Microservice
Microservice Microservice Microservice
Microservice Microservice Microservice
Microservice Microservice Microservice
Microservice Microservice Microservice
Multi Tenant WebLogic
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• Microservices either implement or rely on docker container frameworks for all non-functional requirements
• Stronger resource isolation
• Security issues
– Container exploits propagate to all containers and the host
– http://www.boycottdocker.org/
• Extreme lightweight microservices
• All non-functional requirements are inhereted from WebLogic infrastructure
• Weaker resource isolation
17
Docker vs. WebLogic based Microservices
Microservices on Docker Container Microservices on WLS Microcontainer
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Agenda
• Microservices
– Java EE and Microservices
• Oracle lightweight technologies for microservices
• Demos
• 18
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JAX-RS/Jersey
• JAX-RS 2.0
– part of Java EE 7 (2013)
– defines a standard API for • Implementing RESTful web services in Java
• REST client API
• Jersey 2.0
– provides production ready JAX-RS 2.0 reference implementation
– brings several non-standard features
– Current version is 2.22.1
19
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Jersey for Microservices
• Integration with various HTTP containers and client transports
• Reactive/Async Client
• Test Framework, Monitoring and Tracing
• Support for SSE
• Dynamic reloading
• Various data bindings
• Security
• MVC view templates
• Weld (CDI) support
20
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Oracle Coherence In-Memory Data Grid
• Distributed in-memory management of application objects
– High performance, scalability and availability
• Typical use cases: caching, analytics, event processing
• Implements JCache JSR-107
• Support for Java SE 8 lambdas and Stream-like API
• Can be used as a service in a microservice architecture
– For application state, configuration and service registration and lookup
• Lightweight – Start as a jar with a config file:
• java –Dcoherence.cacheconfig=<config-file> -jar <one-jar-containing-coherence-lib>
21
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Using Application Container Cloud Service For Microservices
22
A modern platform for lightweight application development
Database Cloud Service
Oracle Cloud
Application Container Cloud Service NoSQL Cloud Service
Oracle Management Cloud - Management/Logging/Alerting
Messaging Cloud Service
Caching Cloud Service for State
Java SE Cloud
Service
API Load Balancer
Service Discovery
Configuration
Node Cloud
Service
Other Polyglot
Runtimes
Bring Your Own Container
Jersey + Grizzly
Docker Containers
Container Placement
Dev
elo
per
Clo
ud
Ser
vice
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Agenda
• Microservices
– Java EE and Microservices
• Oracle lightweight technologies for microservices
• Demos
• 23
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• Collaborative drawing
• Two-page application
– List of drawings
– Drawing
• Demonstrating – Server-side
• Java EE 7: JAX-RS, JSON, WebSocket
• Jersey specific: SSE, JSON-B
• Lightweight integration Jersey+Tyrus+Grizzly – only ~10 MB footprint!
– Client-side: AngularJS or JavaFX
24
https://github.com/doschkinow/ijug-roadshow-2015/tree/master/drawingboard-light
HTML5 App with Jersey+Tyrus+Grizzly: Drawing Board Demo
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 25
light implementation – no app server
Drawing Board Demo
HTTP/S
Web Sockets
SSE
Clients
JSON
JSON
HTML5 Browser
JavaFX
WebView/WebKit
webSocketSend.send(...)
send(...) onEvent(...)
DrawingService.query(...)
DataProvider POJO
(Drawings HashMap)
JAX
-RS,
SS
E (J
erse
y)
WS
End
po
int
(Tyr
us)
Grizzly
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 26
Splitting into microservices
Drawing Board Demo
HTTP/S
SSE
Clients
JSON
HTML5 Browser
JavaFX
WebView/WebKit
webSocketSend.send(...)
send(...) onEvent(...)
DrawingService.query(...)
DataProvider POJO
(Drawings HashMap) JA
X-R
S, S
SE
(Jer
sey)
Grizzly
HTTP/S
JSON DataProvider
POJO (Drawings HashMap) So
cket
.IO
Node.js
Web Sockets
JAX
-RS/
SSE
M
icro
serv
ice
W
ebsl
ock
et
Mic
rose
rvic
e
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 27
Splitting into microservices, deployed on the Application Container Cloud Service https://dbmicrosse-gse00000361.apaas.em2.oraclecloud.com/
Drawing Board Demo
HTTP/S
SSE
Clients
JSON
HTML5 Browser
JavaFX
WebView/WebKit
webSocketSend.send(...)
send(...) onEvent(...)
DrawingService.query(...)
DataProvider POJO
(Drawings HashMap) JA
X-R
S, S
SE
(Jer
sey)
Grizzly
HTTP/S
JSON DataProvider
POJO (Drawings HashMap) So
cket
.IO
Node.js
Web Sockets
JAX
-RS/
SSE
M
icro
serv
ice
W
ebsl
ock
et
Mic
rose
rvic
e
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
DataProvider POJO
(Drawings HashMap) So
cket
.IO
Node.js
DataProvider uses a
Coherence distributed
Cache
JAX
-RS,
SSE
(J
erse
y)
Grizzly
28
Splitting into microservices using a distributed cache service
Drawing Board Demo
HTTP/S
SSE
Clients
JSON
HTML5 Browser
JavaFX
WebView/WebKit
webSocketSend.send(...)
send(...) onEvent(...)
DrawingService.query(...)
DataProvider uses a
Coherence distributed
Cache
JAX
-RS,
SSE
(J
erse
y)
Grizzly
JAX
-RS/
SSE
M
icro
serv
ice
HTTP/S
JSON DataProvider
uses a Coherence distributed
Cache
Tyru
s
Grizzly
Web Sockets
Co
he
ren
ce C
lust
er
Web
slo
cket
M
icro
serv
ice
Co
her
ence
M
icro
serv
ice
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
WLS
2
29
Scalability and HA for SSE and WS Microservices with OTD and WLS Multitenancy
Drawing Board Demo
HTTP/S SSE,
WebSocket
Clients
JSON
HTML5 Browser
JavaFX
WebView/WebKit
webSocketSend.send(...)
send(...) onEvent(...)
DrawingService.query(...)
Part
itio
n 2
Clu
ster
ed C
oh
eren
ce
Mic
rose
rvic
e
Part
itio
n 1
WLS
1
OTD
SSE
1
SSE
2
WLS
4 C
ach
e fo
r Pa
rtit
ion
2
WLS
3
WS
1
WS
2
Cac
he
for
Part
itio
n 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Summary
• Microservices are a valuable architectural technique, but:
– not necessarily for everyone
– not necessary always
– not necessarily all-at-once
• Building microservises with Jersey is easier
– Many microservices-related features in Jersey are going to be standardized
• Oracle is working on providing a cloud platform for microservices
30
Top Related