Lean Microservices with OSGi - Christian Schneider

27
Lean microservices on OSGi By Christian Schneider Open Source Architect at Talend [email protected] @schneider_chris

Transcript of Lean Microservices with OSGi - Christian Schneider

Page 1: Lean Microservices with OSGi - Christian Schneider

Lean microserviceson OSGi

By Christian SchneiderOpen Source Architect at Talend

[email protected]@schneider_chris

Page 2: Lean Microservices with OSGi - Christian Schneider

Participate in Demo

Connect to irc network freenode

Channel #osgichat

Page 3: Lean Microservices with OSGi - Christian Schneider

Microservices...way of designing software applications as suites of independently deployable services.... organization around business capability, automated deployment, intelligence in the endpoints, and decentralized control of languages and data. - Martin Fowler

● Create application out of independently deployable services● Verticals around business capabilities● Decentralized data● Automated deployment● 1 service per process● Lightweight communications between services (typically REST)

Page 4: Lean Microservices with OSGi - Christian Schneider

Spring boot● Framework for micro service development based on spring● Easy to start. Paste snippets of “starter” dependencies into pom● Convention over configuration● Good docker and cloud support

Page 5: Lean Microservices with OSGi - Christian Schneider

The Dark side of microservices

Page 6: Lean Microservices with OSGi - Christian Schneider

No, no, no. Quicker, easier, more seductive...

Are microservices stronger than OSGi?

Page 7: Lean Microservices with OSGi - Christian Schneider

Dependencies between microservices

Page 8: Lean Microservices with OSGi - Christian Schneider

OperationsContainer vessel - Application Server

Page 9: Lean Microservices with OSGi - Christian Schneider

Microservices operation - Theory

Page 10: Lean Microservices with OSGi - Christian Schneider

Microservices operation - Practice

Page 11: Lean Microservices with OSGi - Christian Schneider

Microservices can not cure bad design

Page 12: Lean Microservices with OSGi - Christian Schneider

Microservices with spring-boot…What is wrong with it?

● Lots of dependencies already at design time

● Microservices always must communicate remotely

● Proprietary Annotations / API● No flexibility in packaging

1 Microservice = 1 Deployment Unit = 1 Process

Page 13: Lean Microservices with OSGi - Christian Schneider

A small spring boot project

● Pollutes the classpath● Difficult to establish rules which APIs to use

90dependencies

20 MBjar file

Page 14: Lean Microservices with OSGi - Christian Schneider

Why is OSGi different?

● Coding against APIs and specs

● Self describing modules (bundles)

● OSGi services to communicate between bundles

● Semantic versioning

● Remote Service Admin for Remote calls and REST

● Flexible packaging

Page 15: Lean Microservices with OSGi - Christian Schneider

Semantic Versioning

● MAJOR version - incompatible API changes,● MINOR version - added functionality in a backwards-compatible manner● BUGFIX version - backwards-compatible bug fixes

Mind the difference between API and SPI.

Page 16: Lean Microservices with OSGi - Christian Schneider

Remote Service Admin

● Exports and imports OSGi services● Service Properties to mark for export and configure transports, …● Highly customizable (Policies, Transports, Serialization, Discovery)

Page 17: Lean Microservices with OSGi - Christian Schneider

Rest services with RSA

● Just JAX-RS annotations on interface

REST Endpoint User bundleHTTP

OSGi service

CXF Transport for Aries RSA

Creates

TopologyManager

Detects

Selectstransport

Page 18: Lean Microservices with OSGi - Christian Schneider

Lets see it in practice

Small chat application

● Modules talk to each other using an OSGi ChatListener interface described in API bundle

● IRC connector using camel● Shell integration using gogo● Tinkerforge Display and Motion

detector● Optional Remoting using Aries

RSA

Page 19: Lean Microservices with OSGi - Christian Schneider

Chat APIChat shell integrationTinkerforge LCD displayIRC Connector

IRC

All in one

● 1 Process● 6MB runnable jar● No remote calls inside application● Still modular as bundles only coupled

through API and OSGi service

Page 20: Lean Microservices with OSGi - Christian Schneider

Container vessel - OSGi deployment in one process

Page 21: Lean Microservices with OSGi - Christian Schneider

Chat APIIRC ConnectorAries RSA

IRC

Microservice Deployment

Chat APITinkerforge LCD and motion detectAries RSA

Chat APIChat shell integrationAries RSA

Zookeeper

Page 22: Lean Microservices with OSGi - Christian Schneider

Microservice Deployment

● Same bundles as before● As many deployment units as needed● Each deployment unit can scale● Runnable jars or docker containers● Cloud native if needed● Aries RSA overhead 300 KB + 800 KB zookeeper lib● Remote calls or local calls as needed● Many options for remotings (tcp, fastbin, SOAP, REST, JMS)

Page 23: Lean Microservices with OSGi - Christian Schneider

But beware of the same management issues as any other micro services

Page 24: Lean Microservices with OSGi - Christian Schneider

Demo time

Page 25: Lean Microservices with OSGi - Christian Schneider

OSGi can scale from very small to very large

But no simple cure for the operational problems of microservices

Page 26: Lean Microservices with OSGi - Christian Schneider

Unsure if you actually need a microservice architecture?● Develop your application using modular bundles● Stay on single process as long as possible● Decide about the packaging and deployment as late as

possible● Deploy only as fine granular as needed