modular architectures using micro services
DESCRIPTION
When building and maintaining large applications in a world that is rapidly evolving, keeping up with changing requirements and non-functionals over time is a huge challenge. Architecting your application in a modular way and loosely coupling modules using micro services provides you with a nicely decoupled system that still works very efficiently. Designing, evolving and versioning a micro service architecture is not easy, and over time, several design patterns and best practices have evolved that help you. Code examples can be found here: https://bitbucket.org/marrs/javaone-2014-microservicesTRANSCRIPT
![Page 1: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/1.jpg)
Modular Architectures using Micro Services
![Page 2: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/2.jpg)
About Me
Director at Luminis Technologies Member at the Apache Software Foundation
@m4rr5
Marcel Offermans
![Page 3: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/3.jpg)
Agenda• Modular Architectures
• Micro Services
• OSGi in 60 seconds
• Amdatu
• Demo
![Page 4: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/4.jpg)
Modular Architectures
![Page 5: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/5.jpg)
The case for modularity
![Page 6: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/6.jpg)
Maintainability
![Page 7: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/7.jpg)
Adaptability
![Page 8: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/8.jpg)
Quest for Reuse
Copy / Paste
![Page 9: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/9.jpg)
Object OrientedQuest for Reuse
![Page 10: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/10.jpg)
Component Based
Quest for Reuse
![Page 11: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/11.jpg)
Micro Services
![Page 12: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/12.jpg)
The term "Microservice Architecture" has sprung up over the last few years to describe a particular way
of designing software applications as suites of independently deployable services. While there is no precise definition of this architectural style, there are certain common characteristics around organization around business capability, automated deployment,
intelligence in the endpoints, and decentralized control of languages and data.
Source: http://martinfowler.com/articles/microservices.html
![Page 13: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/13.jpg)
Business Capabilities
• Should be leading when splitting an application into components
• Different from more traditional technology driven “layering” (UI, application logic, database)
Conway’s Law: Any organization that designs a system will produce a design whose structure is a
copy of the organization's communication structure. !
Melvyn Conway, 1967
![Page 14: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/14.jpg)
Component owns Data• Each service manages its own data
• Can lead to polyglot persistence
• Leverage Domain-Driven Design: bounded context often maps naturally to components
• Use transaction-less coordination between services: build for eventual consistency and have a reversal process to deal with mistakes
![Page 15: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/15.jpg)
Products
• Make the team responsible for the whole life cycle of a product or component
• Brings developers closer to the customers
Amazon:”You build it, you run it!”
![Page 16: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/16.jpg)
Services• Provide a public, versioned contract for a
component
• Have their own life cycle, so they can be separately deployed
• Hide all implementation details
![Page 17: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/17.jpg)
Dumb Pipes
• HTTP request/response
• lightweight messaging
![Page 18: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/18.jpg)
Decentralized• Services decouple and abstract away components,
leaving us free to choose implementation languages
• Less focus on formal standards, more on proven, open source technology
![Page 19: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/19.jpg)
Automated Deployment
• Continuous Integration
• Continuous Deployment
![Page 20: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/20.jpg)
Design for Change• How to break a system into components? Consider
rate of change, high cohesion, low coupling, …
• Version your services, and make them tolerant to change
• Stay flexible!The only constant is change.
![Page 21: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/21.jpg)
Design for Failure• Applications need to be able to deal with failures
• Services can always fail or become unavailable
• Monitoring is an important aspect
Netflix: Chaos Monkey to introduce random instance failures
Michael Jordan: I’ve missed more than 9000 shots in my career. I’ve lost almost 300 games. 26 times, I’ve
been trusted to take the game winning shot and missed. I’ve failed over and over and over again in
my life. And that is why I succeed.
![Page 22: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/22.jpg)
OSGi in 60 seconds
![Page 23: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/23.jpg)
What is OSGi?• Provides components that can be easily deployed
and versioned
• Hides implementation details and leverages a service registry that allows components to publish and consume services
• It’s the de-facto module system for Java: proven technology, works on all Java versions, usable from embedded to enterprise
![Page 24: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/24.jpg)
META-INF/MANIFEST.MFstore/Store.classstore/Key.classstore/fs/StoreImpl.classstore/fs/FileSystem.classstore/fs/StreamUtil.classstore/fs/osgi/Activator.classlib/fsutil.jar
META-INF/MANIFEST.MF Bundle-SymbolicName: store.fsBundle-Version: 1.0.2
Bundle-Classpath: ., lib/fsutil.jar
Bundle-Activator: store.fs.osgi.Activator
Export-Package: store;version="2.5"Import-Package: org.foo.log;version="[1, 2)"
OSGi
![Page 25: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/25.jpg)
META-INF/MANIFEST.MFstore/Store.classstore/Key.classstore/fs/StoreImpl.classstore/fs/FileSystem.classstore/fs/StreamUtil.classstore/fs/osgi/Activator.classlib/fsutil.jarstore/fs/osgi/Activator.class
META-INF/MANIFEST.MF Bundle-SymbolicName: store.fsBundle-Version: 1.0.2
Bundle-Classpath: ., lib/fsutil.jar
Bundle-Activator: store.fs.osgi.Activator
Export-Package: store;version="2.5"Import-Package: org.foo.log;version="[1, 2)"
class Activator implements BundleActivator { ServiceRegistration sr; public void start(BundleContext bc) { sr = bc.registerService(Store.class.getName(), new StoreImpl(), null); } public void stop(BundleContext bc) { sr.unregister(); }}
Bundle-Activator: store.fs.osgi.Activator
OSGi
![Page 26: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/26.jpg)
META-INF/MANIFEST.MFstore/Store.classstore/Key.classstore/fs/StoreImpl.classstore/fs/FileSystem.classstore/fs/StreamUtil.classstore/fs/osgi/Activator.classlib/fsutil.jarstore/fs/osgi/Activator.class
META-INF/MANIFEST.MF Bundle-SymbolicName: store.fsBundle-Version: 1.0.2
Bundle-Classpath: ., lib/fsutil.jar
Bundle-Activator: store.fs.osgi.Activator
Export-Package: store;version="2.5"Import-Package: org.foo.log;version="[1, 2)"
class Activator implements BundleActivator { ServiceRegistration sr; public void start(BundleContext bc) { sr = bc.registerService(Store.class.getName(), new StoreImpl(), null); } public void stop(BundleContext bc) { sr.unregister(); }}
Bundle-Activator: store.fs.osgi.Activator
OSGi
![Page 27: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/27.jpg)
META-INF/MANIFEST.MFstore/Store.classstore/Key.classstore/fs/StoreImpl.classstore/fs/FileSystem.classstore/fs/StreamUtil.classstore/fs/osgi/Activator.classlib/fsutil.jar
store/Store.classstore/Key.class
store/fs/osgi/Activator.class
META-INF/MANIFEST.MF Bundle-SymbolicName: store.fsBundle-Version: 1.0.2
Bundle-Classpath: ., lib/fsutil.jar
Bundle-Activator: store.fs.osgi.Activator
Export-Package: store;version="2.5"Import-Package: org.foo.log;version="[1, 2)"
class Activator implements BundleActivator { ServiceRegistration sr; public void start(BundleContext bc) { sr = bc.registerService(Store.class.getName(), new StoreImpl(), null); } public void stop(BundleContext bc) { sr.unregister(); }}
Export-Package: store;version="2.5"
store;version="2.5"resolver
bundles
Bundle-Activator: store.fs.osgi.Activator
OSGi
![Page 28: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/28.jpg)
META-INF/MANIFEST.MFstore/Store.classstore/Key.classstore/fs/StoreImpl.classstore/fs/FileSystem.classstore/fs/StreamUtil.classstore/fs/osgi/Activator.classlib/fsutil.jar
store/Store.classstore/Key.class
store/fs/osgi/Activator.class
META-INF/MANIFEST.MF Bundle-SymbolicName: store.fsBundle-Version: 1.0.2
Bundle-Classpath: ., lib/fsutil.jar
Bundle-Activator: store.fs.osgi.Activator
Export-Package: store;version="2.5"Import-Package: org.foo.log;version="[1, 2)"
class Activator implements BundleActivator { ServiceRegistration sr; public void start(BundleContext bc) { sr = bc.registerService(Store.class.getName(), new StoreImpl(), null); } public void stop(BundleContext bc) { sr.unregister(); }}
Export-Package: store;version="2.5"Import-Package: org.foo.log;version="[1,2)"
META-INF/MANIFEST.MForg/foo/log/Log.classorg/foo/log/syslog/SysLogImpl.classorg/foo/log/syslog/Activator.class
store;version="2.5"
org.foo.log;version="1.3"resolver
bundles
Bundle-Activator: store.fs.osgi.Activator
OSGi
![Page 29: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/29.jpg)
META-INF/MANIFEST.MFstore/Store.classstore/Key.classstore/fs/StoreImpl.classstore/fs/FileSystem.classstore/fs/StreamUtil.classstore/fs/osgi/Activator.classlib/fsutil.jar
store/Store.classstore/Key.class
store/fs/osgi/Activator.class
META-INF/MANIFEST.MF Bundle-SymbolicName: store.fsBundle-Version: 1.0.2
Bundle-Classpath: ., lib/fsutil.jar
Bundle-Activator: store.fs.osgi.Activator
Export-Package: store;version="2.5"Import-Package: org.foo.log;version="[1, 2)"
class Activator implements BundleActivator { ServiceRegistration sr; public void start(BundleContext bc) { sr = bc.registerService(Store.class.getName(), new StoreImpl(), null); } public void stop(BundleContext bc) { sr.unregister(); }}
Export-Package: store;version="2.5"Import-Package: org.foo.log;version="[1,2)"
META-INF/MANIFEST.MForg/foo/log/Log.classorg/foo/log/syslog/SysLogImpl.classorg/foo/log/syslog/Activator.class
store;version="2.5"
org.foo.log;version="1.3"resolver
service registry
bundles
sr = bc.registerService(Store.class.getName(), new StoreImpl(), null);
store.Store { service.id = 1 }
Bundle-Activator: store.fs.osgi.Activator
OSGi
![Page 30: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/30.jpg)
Remoting
java virtual machine
OSGi framework
bund
le
bund
le
bund
le
service registry
java virtual machine
OSGi framework
bund
le
bund
le
service registry
java virtual machine
OSGi framework
bund
le
bund
le
bund
le
service registry
bund
le
![Page 31: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/31.jpg)
Amdatu
![Page 32: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/32.jpg)
What is Amdatu?Amdatu is an open source community effort focussed on
bringing OSGi to the cloud. It contains components to create RESTful, scalable and distributed web applications that use
NoSQL data stores, transparent multi-tenancy and much more.
![Page 33: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/33.jpg)
Development Model• Modular design based on OSGi
• Fast deployment using Bndtools
• Git fork/merge based workflow
• Extensive Atlassian tool support
• Apache ACE integrated with build servers
• Gradle based build
![Page 34: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/34.jpg)
Demo
![Page 35: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/35.jpg)
Wrapping Up
![Page 36: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/36.jpg)
We’ve…• …explored modularity and micro services
• …introduced OSGi and Amdatu
• …seen how to develop and run a modular application
• …seen how OSGi allows you to be flexible in how you group and deploy components
![Page 37: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/37.jpg)
Eclipse OSGi plugin!http://bndtools.org/ !
Provisioning Server!http://ace.apache.org/!
That’s us!http://luminis-technologies.com/
Demo code!https://bitbucket.org/marrs/javaone-2014-microservices/
Cloud OSGi services!http://www.amdatu.org/
![Page 38: Modular Architectures using Micro Services](https://reader034.vdocuments.us/reader034/viewer/2022051609/5478c6075906b571048b45ae/html5/thumbnails/38.jpg)
TakkGrazie
Thank!you
Obrigado
MahaloDankeDank U
Merci
Gracias