Post on 04-Jul-2015
description
transcript
… 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
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/)
— 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.”
“MICROSERVICES”
YOU KEEP USING THAT WORD. I DO NOT THINK IT MEANS WHAT YOU THINK IT MEANS.
— 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.”
Service
api
api api
Consumer Provider
API
“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
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
Isolation is a Continuum
ISOLATION Stronger →← Weaker
CO
ST
JavaClasspath
OSGiServices
OS ProcessDocker
VM
PhysicalBox
DataCentre
local minima(sweet spots)
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
Scaling
Horizontal
Process
Process
Process
Horizontal
Process Process Process
When to Scale?
• Q: “Should I expose this as a service for scaleability?”
• Agilist Answer: “No… YAGNI*”
*You Aren’t Gonna Need It
When to Scale (OSGi Style)
Provider Consumer
Provider Consumer
Config Switch
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.
Demo
Orchestrating
What Should I Run??
Where Should I Run It??
Where Is Everybody??
Local Discovery (Easy)
Process
Process
Process
Remote Discovery (Hrrrmm)
Process Process?
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)
OSGi RSA Discovery
• Advertise / Discover using Pluggable Impls
• E.g.: Bonjour, SLP, DDS, Gossip, ZooKeeper…
• Dynamic Availability / Presence
• Plug and Play!
Even for Non-Services…
RESTProvider Consumer
Endpointuri=http://<host>:<port>/<alias>
HTTP Comunication
Even for Non-Java Services
MosquittoPackager Consumer
Endpointuri=mqtt://<host>:<port>
MQTTMosquitto (MQTT)Process
… and Non-Java Consumers
RESTProvider
NGinxPackager
uri=http://<host>:<port>/<alias>
NGinxProcess
RESTProvider
RESTProvider
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)
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”.
Demo
Technology Used
• Paremus RSA — implementation of OSGi Remote Services Admin specification
• Paremus Packager — open source API
• Paremus Service Fabric — secret sauce ;-)
Questions?