scaling and orchestrating microservices with osgi - n bartlett

31
… OR: How to Write a Session Title That Will Get Your Talk Accepted at Any Conference Scaling and Orchestrating Microservices with OSGi Neil Bartlett — Paremus Ltd

Upload: mfrancis

Post on 04-Jul-2015

307 views

Category:

Technology


2 download

DESCRIPTION

OSGi Community Event 2014

TRANSCRIPT

Page 1: Scaling and Orchestrating Microservices with OSGi - N Bartlett

… OR: How to Write a Session Title That Will Get

Your Talk Accepted at Any Conference

Scaling and Orchestrating Microservices with OSGi

Neil Bartlett — Paremus Ltd

Page 2: Scaling and Orchestrating Microservices with OSGi - N Bartlett

OSGi is From the Future

• Runtime resolve/assemble since 2005

• Software component repositories since 2003

• Continuous delivery since 1999

• Microservices since 1998

image credit: Sam Howzit (flickr.com/photos/aloha75/)

Page 3: Scaling and Orchestrating Microservices with OSGi - N Bartlett

— Martin Fowler, March 2014

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

“The term ‘microservice’ was discussed at a workshop of

software architects near Venice in May, 2011 to describe what

the participants saw as a common architectural style that many of them had been recently

exploring.”

Page 4: Scaling and Orchestrating Microservices with OSGi - N Bartlett

“MICROSERVICES”

YOU KEEP USING THAT WORD. I DO NOT THINK IT MEANS WHAT YOU THINK IT MEANS.

Page 5: Scaling and Orchestrating Microservices with OSGi - N Bartlett

— Peter Kriens, March 2010

http://blog.osgi.org/2010/03/services.html

“What I am promoting is the idea of µServices, the

concepts of an OSGi service as a design primitive.”

Page 6: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Service

api

api api

Consumer Provider

API

Page 7: Scaling and Orchestrating Microservices with OSGi - N Bartlett

“Fowler” Microservices OSGi Services

“an approach to developing a single application as a suite of small services" ✔

“each running in its own process” ✘

“communicating with lightweight mechanisms” ✔

“built around business capabilities” ✔“independently deployable by fully automated deployment

machinery” ✔

“bare mininum of centralized management of these services” ✔

“may be written in different programming languages” ✔*“use different data storage technologies” ✔

* JVM languages only, for now

Page 8: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Why Separate Processes?

• “One main reason … is that services are independently deployable.” … like OSGi Bundles

• “you can expect many single service changes to only require that service to be redeployed.” … like OSGi Bundles

• “Another consequence of using services as components is a more explicit component interface.” … like OSGi Services

• “Often it's only documentation and discipline that prevents clients breaking a component's encapsulation.” … whereas OSGi enforces encapsulation

Page 9: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Isolation is a Continuum

ISOLATION Stronger →← Weaker

CO

ST

JavaClasspath

OSGiServices

OS ProcessDocker

VM

PhysicalBox

DataCentre

local minima(sweet spots)

Page 10: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Java

OSGi

Process

Docker

VM

Physical Box

Data Centre

Services and Reuse

Crash Isolation, Alternate Langs

CPU/Mem Quotas

Alternate OS

Power Fail, Whole OS Crash

Disaster Resilience

Page 11: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Scaling

Page 12: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Horizontal

Process

Process

Process

Page 13: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Horizontal

Process Process Process

Page 14: Scaling and Orchestrating Microservices with OSGi - N Bartlett

When to Scale?

• Q: “Should I expose this as a service for scaleability?”

• Agilist Answer: “No… YAGNI*”

*You Aren’t Gonna Need It

Page 15: Scaling and Orchestrating Microservices with OSGi - N Bartlett

When to Scale (OSGi Style)

Provider Consumer

Provider Consumer

Config Switch

Page 16: Scaling and Orchestrating Microservices with OSGi - N Bartlett

OSGi Remote Services

• Services can be selected for remoting post facto.

• Small code change or pure config change.

• Respond to rapidly changing demand.

• TGTBT? In practice, devs should at least factor in the possibility of remoting.

Page 17: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Demo

Page 18: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Orchestrating

Page 19: Scaling and Orchestrating Microservices with OSGi - N Bartlett

What Should I Run??

Where Should I Run It??

Where Is Everybody??

Page 20: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Local Discovery (Easy)

Process

Process

Process

Page 21: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Remote Discovery (Hrrrmm)

Process Process?

Page 22: Scaling and Orchestrating Microservices with OSGi - N Bartlett

State of the Art

• Install X on this box, install Y on that box, etc…

• Tell X where Y is (static config)

• Tell Y where X is (static config)

Page 23: Scaling and Orchestrating Microservices with OSGi - N Bartlett

OSGi RSA Discovery

• Advertise / Discover using Pluggable Impls

• E.g.: Bonjour, SLP, DDS, Gossip, ZooKeeper…

• Dynamic Availability / Presence

• Plug and Play!

Page 24: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Even for Non-Services…

RESTProvider Consumer

Endpointuri=http://<host>:<port>/<alias>

HTTP Comunication

Page 25: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Even for Non-Java Services

MosquittoPackager Consumer

Endpointuri=mqtt://<host>:<port>

MQTTMosquitto (MQTT)Process

Page 26: Scaling and Orchestrating Microservices with OSGi - N Bartlett

… and Non-Java Consumers

RESTProvider

NGinxPackager

uri=http://<host>:<port>/<alias>

NGinxProcess

RESTProvider

RESTProvider

Page 27: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Oh, and Docker

See: OSGi Alliance IoT Demo and Hackathon

MosquittoPackager Consumer

uri=mqtt://<host>:<port>

MQTT

Mosquitto (MQTT)

Container

Prosyst mPRMPackager

Prosyst mPRMContainer

uri=mprm://<host>:<port>version=5.3.0

mPRM (custom HTTP)

Page 28: Scaling and Orchestrating Microservices with OSGi - N Bartlett

What, Where, How Many?

• OSGi Capabilities and Requirements — a generic software pattern.

• Use to describe native executables, Docker images…

• Machine capabilities define “where”

• Policy defines “how many”.

Page 29: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Demo

Page 30: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Technology Used

• Paremus RSA — implementation of OSGi Remote Services Admin specification

• Paremus Packager — open source API

• Paremus Service Fabric — secret sauce ;-)

Page 31: Scaling and Orchestrating Microservices with OSGi - N Bartlett

Questions?