microservices & osgi - better together? - graham charters

35
© 2016 IBM Corporation Graham Charters Senior Technical Staff Member, WebSphere Application Server Microservices and OSGi: Better together?

Upload: mfrancis

Post on 16-Apr-2017

348 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Microservices & OSGi - Better Together? - Graham Charters

© 2016 IBM Corporation

Graham Charters

Senior Technical Staff Member,

WebSphere Application Server

Microservices and OSGi: Better together?

Page 2: Microservices & OSGi - Better Together? - Graham Charters

2 Page © 2016 IBM Corporation

Agenda

– Introduction to Modularity, Microservices & OSGi

– Comparison of OSGi and Microservice capabilities

– Microservices challenges

– OSGi smoothing the way to Microservices

Page 3: Microservices & OSGi - Better Together? - Graham Charters

3 Page © 2016 IBM Corporation

What is Modularity

– “Modular programming is a software

design technique that emphasizes

separating the functionality of a

program into independent,

interchangeable modules, such that

each contains everything necessary to

execute only one aspect of the desired

functionality.”

– “A module interface expresses the

elements that are provided and

required by the module. …”

https://en.wikipedia.org/wiki/Modular_programming

Photo by: https://www.flickr.com/photos/zaxl4/

License: https://creativecommons.org/licenses/by-sa/2.0/

Page 4: Microservices & OSGi - Better Together? - Graham Charters

4 Page © 2016 IBM Corporation http://martinfowler.com/articles/microservices.html (25 March 2014)

What are Microservices

Page 5: Microservices & OSGi - Better Together? - Graham Charters

5 Page © 2016 IBM Corporation http://martinfowler.com/articles/microservices.html

Microservices are Modularity

Page 6: Microservices & OSGi - Better Together? - Graham Charters

6 Page © 2016 IBM Corporation

What is OSGi

– Enables products to

be assembled from

Modules

– Modules callable

through Services

– Modules and their

Services have a

dynamic lifecycle

Bundle Bundle

Bundle

listen

provide use

Service

Page 7: Microservices & OSGi - Better Together? - Graham Charters

7 Page © 2016 IBM Corporation

Not all modularity is equal

• Not all module technologies

enable the same capabilities

• Modularity Maturity Model

provides a way to compare

technologies and understand

the benefits

• Inspired by customer

experiences adopting OSGi

“Towards a Modularity Maturity Model”,

OSGi Community Event 2011 presentation @ http://slidesha.re/q8EHFp

Page 8: Microservices & OSGi - Better Together? - Graham Charters

8 Page © 2016 IBM Corporation

Modularity Levels

Level Name Summary

1 Ad Hoc Nothing

2 Modules Formal identity, decoupled from artifact

3 Modularity Formal module contracts, decoupled from identity

4 Loose-Coupling Services, semantic versioning, decoupled from implementation

5 Devolution Modularity-aware repositories, collaboration, governance,

decoupled from ownership

6 Dynamism Life-cycle awareness and independence, decoupled from time

Page 9: Microservices & OSGi - Better Together? - Graham Charters

9 Page © 2016 IBM Corporation

What was it Lewis and Fowler said?

Level Name Summary

1 Ad Hoc Nothing

2 Modules Formal identity

3 Modularity Formal module contracts

4 Loose-Coupling Services, semantic versioning, Componentization via Services

5 Devolution Modularity-aware repositories, collaboration, governance,

Organized around Business Capabilities

6 Dynamism Life-cycle awareness and independence, Design for failure

Page 10: Microservices & OSGi - Better Together? - Graham Charters

10 Page © 2016 IBM Corporation

Filling in the gaps

Level Name Summary

1 Ad Hoc Nothing

2 Modules Formal identity, Deployable service (likely a build artefact)

3 Modularity Formal module contracts, Service Contracts – e.g. Swagger

4 Loose-Coupling Services, semantic versioning, Componentization via Services

5 Devolution Modularity-aware repositories, collaboration, governance,

Organized around Business Capabilities

6 Dynamism Life-cycle awareness and independence, Design for failure

Page 11: Microservices & OSGi - Better Together? - Graham Charters

11 Page © 2016 IBM Corporation

Didn’t you just tell us we don’t need OSGi?

htt

ps:/

/cre

ativecom

mons.o

rg/lic

enses/b

y-n

d/2

.0/

htt

ps:/

/ww

w.f

lickr.

com

/photo

s/4

0601656@

N07/

Page 12: Microservices & OSGi - Better Together? - Graham Charters

12 Page © 2016 IBM Corporation

The answer’s Microservices, what’s the question?

htt

ps:/

/ww

w.g

art

ne

r.co

m/d

oc/3

37

17

27

/hyp

e-c

ycle

-ap

plic

atio

n-s

erv

ices-

By J

ere

myke

mp

at E

ng

lish

Wik

iped

ia, C

C B

Y-S

A 3

.0,

htt

ps:/

/co

mm

on

s.w

ikim

ed

ia.o

rg/w

/in

dex.p

hp

?cu

rid=

10

54

70

51

Gartner

says we’re

here

Early publicity produces a number of

success stories—often accompanied by

scores of failures. Some companies take

action; most don't.

Peak of Inflated Expectations

Page 13: Microservices & OSGi - Better Together? - Graham Charters

13 Page © 2016 IBM Corporation

Evolution, not revolution

Martin Fowler:

“As I hear stories about teams using a microservices architecture, I've noticed a

common pattern.

1. Almost all the successful microservice stories have started with a monolith that

got too big and was broken up

2. Almost all the cases where I've heard of a system that was built as a

microservice system from scratch, it has ended up in serious trouble.”

http://martinfowler.com/bliki/MonolithFirst.html

Page 14: Microservices & OSGi - Better Together? - Graham Charters

14 Page © 2016 IBM Corporation

Design is still hard

http://www.codingthearchitecture.com/2014/10/01/modularity_and_testability.html

Simon Brown:

“Technologies like Spring Boot make creating and deploying

microservices relatively straightforward, but the design thinking

behind partitioning a software system into services is still as

hard as it's ever been.”

http://www.codingthearchitecture.com/presentations/devnexus2016-modular-monoliths

Page 15: Microservices & OSGi - Better Together? - Graham Charters

15 Page © 2016 IBM Corporation

Document your poop

Page 16: Microservices & OSGi - Better Together? - Graham Charters

16 Page © 2016 IBM Corporation

The costs of Microservices

http://martinfowler.com/articles/microservice-trade-offs.html

Page 17: Microservices & OSGi - Better Together? - Graham Charters

17 Page © 2016 IBM Corporation

So should we or shouldn’t we do Microservices?

https://creativecommons.org/licenses/by/2.0/

https://www.flickr.com/photos/sufferingsocrates/

Page 18: Microservices & OSGi - Better Together? - Graham Charters

18 Page © 2016 IBM Corporation

Look before you leap

htt

ps:/

/ww

w.f

lickr.

com

/photo

s/g

gabern

ig/

htt

ps:/

/cre

ativecom

mons.o

rg/lic

enses/b

y/2

.0/

Page 19: Microservices & OSGi - Better Together? - Graham Charters

19 Page © 2016 IBM Corporation

Monolith-first

Martin Fowler:

“As I hear stories about teams using

a microservices architecture, I've

noticed a common pattern.

1. Almost all the successful

microservice stories have started

with a monolith that got too big

and was broken up

2. Almost all the cases where I've

heard of a system that was built

as a microservice system from

scratch, it has ended up in

serious trouble.”

http://martinfowler.com/bliki/MonolithFirst.html

Page 20: Microservices & OSGi - Better Together? - Graham Charters

20 Page © 2016 IBM Corporation

Design is still hard

http://www.codingthearchitecture.com/2014/10/01/modularity_and_testability.html

Technologies like Spring

Boot make creating and

deploying microservices

relatively straightforward,

but the design thinking

behind partitioning a

software system into

services is still as hard as

it's ever been.

http://www.codingthearchitecture.com/presentations/devnexus2016-modular-monoliths

Page 21: Microservices & OSGi - Better Together? - Graham Charters

21 Page © 2016 IBM Corporation

Boundaries Microservices’ main benefit, in my view, is

enabling parallel development by

establishing a hard-to-cross boundary

between different parts of your system.

By doing this, you make it hard – or at least

harder – to do the wrong thing: Namely,

connecting parts that shouldn’t be

connected, and coupling those that need to

be connected too tightly. In theory, you

don’t need microservices for this if you

simply have the discipline to follow clear

rules and establish clear boundaries

within your monolithic application; in

practice, I’ve found this to be the case only

very rarely.

http://martinfowler.com/articles/dont-start-monolith.html

Don’t start with a monolith … when your goal is a microservices architecture

Stefan Tilkov

Page 22: Microservices & OSGi - Better Together? - Graham Charters

22 Page © 2016 IBM Corporation

Boundaries “Often the true consequences of your

architectural decisions are only evident

several years after you made them. We

have seen projects where a good team,

with a strong desire for modularity, has

built a monolithic architecture that has

decayed over the years. Many people

believe that such decay is less likely with

microservices, since the service

boundaries are explicit and hard to

patch around.”

http://martinfowler.com/articles/microservices.html

Page 23: Microservices & OSGi - Better Together? - Graham Charters

23 Page © 2016 IBM Corporation

The modular monolith

If you can't build a

modular monolith,

what makes you

think microservices

are the answer?

http://www.codingthearchitecture.com/2014/07/06/distributed_big_balls_of_mud.html

Page 24: Microservices & OSGi - Better Together? - Graham Charters

24 Page © 2016 IBM Corporation

Getting to there from here…

https://creativecommons.org/licenses/by/2.0/

https://www.flickr.com/photos/pss/

Page 25: Microservices & OSGi - Better Together? - Graham Charters

25 Page © 2016 IBM Corporation

Key questions

What will help me create and

maintain a modular

monolith?

What’s the closest you can

get to the microservices

qualities without incurring all

of the associated cost?

http://www.codingthearchitecture.com/presentations/devnexus2016-modular-monoliths

Page 26: Microservices & OSGi - Better Together? - Graham Charters

26 Page © 2016 IBM Corporation

Refresher…

– Enables products to

be assembled from

Modules

– Modules callable

through Services

– Modules and their

Services have a

dynamic lifecycle

Bundle Bundle

Bundle

listen

provide use

Service

Page 27: Microservices & OSGi - Better Together? - Graham Charters

27 Page © 2016 IBM Corporation

The Modular Monolith

– Use OSGi to modularise your Product

– Not just Business as Usual - organize

around business capabilities,

modularize your data, etc.

– A number of approach have been

documented.

• Services-first

• Java EE -> OSGi

• Strangler Pattern

– These are equally applicable to OSGi

& Microservice discovery

E D

B

F

A

C

H

G

Page 28: Microservices & OSGi - Better Together? - Graham Charters

28 Page © 2016 IBM Corporation

Evolving to Microservices

– Identify Feature ‘Subsystems’

as individually deployable

units

– Continue to deploy to same

process

E D

B

F

A

C

H

G

Page 29: Microservices & OSGi - Better Together? - Graham Charters

29 Page © 2016 IBM Corporation

Isolate your Subsystems

– Make ‘boundary services’

remotable

– Enforce isolation using

Application Subsytems

– Handle service unavailability

– Continue to deploy to same

process

E D

B

F

A

C

H

G

G

B

Page 30: Microservices & OSGi - Better Together? - Graham Charters

30 Page © 2016 IBM Corporation

Deployment independently

– Deploy as independently

scalable microservices

– Automate deployment

– Prove out remoting, latency,

etc.

E D

B

F

A

C

H

G

G

B

Page 31: Microservices & OSGi - Better Together? - Graham Charters

31 Page © 2016 IBM Corporation

Modular Monolith+

Page 32: Microservices & OSGi - Better Together? - Graham Charters

32 Page © 2016 IBM Corporation

Modular Monolith+

Page 33: Microservices & OSGi - Better Together? - Graham Charters

33 Page © 2016 IBM Corporation

Remoting Services

– OSGi Remote Services &

Remote Services Admin

providers

– Or pick a JAX-RS

implementation

– Future: JAX-RS Whiteboard

(RFC 217)

RS Impl RS Impl

register

proxy

discover

register

endpoint

JAX-RS

endpoint

JAX-RS

proxy

https://github.com/osgi/design/tree/master/rfcs/rfc0217

Page 34: Microservices & OSGi - Better Together? - Graham Charters

34 Page © 2016 IBM Corporation

Technology choices

– MicroProfile 1.0 defines a technology set for Java EE

• JAX-RS, CDI, JSON-P

– What would the OSGi equivalent be?

• JAX-RS, Declarative Services, JSON-P

– Beyond the core

• Externalize configuration – Config Admin (think 12-factor)

Page 35: Microservices & OSGi - Better Together? - Graham Charters

35 Page © 2016 IBM Corporation

Summary

– Microservices are an important approach to producing highly-available,

maintainable applications

– Microservices are not for-free, introducing new costs, such as distribution

and operational complexity

– Modular monoliths are seen as an important stepping stone to being able to

produce Microservices

– OSGi is an ideal fit for producing modular monoliths, going well-beyond their

core characteristics

– The OSGi standards cover the core capabilities essential for producing first-

class Java-based microservices