Microservices
with Spring Cloud
Who are we?
Daniel Eichten Paul Vassu
What are Microservices?
– Wikipedia
“Microservices are a more concrete and modern
interpretation of service-oriented architectures (SOA) used to
build distributed software systems. Like in SOA, services in a
microservice architecture are processes that communicate
with each other over the network in order to fulfill a goal.
Also, like in SOA, these services use technology agnostic
protocols. Microservices architectural style is a first
realisation of SOA that has happened after the introduction
of DevOps and this is becoming the standard for building
continuously deployed systems.”
“Microservices are fulfilling the SOA promise!”
– us
By Webysther Nunes - Own work, CC BY-SA 4.0https://commons.wikimedia.org/w/index.php?curid=39594469
http://martinfowler.com/articles/microservices.html
https://www.thoughtworks.com/profiles/sam-newman
Microservices
• Small
• Focused
• Doing One Thing Well
“Microservices are small, autonomous services that work
together.” – Sam Newman
• Technology heterogenic
• Resilient
• Scalable
• Easy to deploy
BUT
Downsides
• Increased complexity
through distribution
• Dependency of Services
• Handling of breaking
changes
• Operational overhead
• Testing effort
• Distributed transactions
Do or don’t …
http://pcwallart.com/master-yoda-star-wars-wallpaper-2.html
Yoda
… there is no try!?
https://pixabay.com/en/darth-vader-star-wars-geek-1207142/
Spring Boot
• Convention-over-Configuration
• Creates Standalone Applications
• Embedded Container
• Autoconfiguration
• No XML SitUps
• No Yak Shaving
Hello Weather!
HTML+
jQuery
DB
App
OpenWeather
Controllers
Services
Repository Client
DB REST-API
HTML JS (jQuery)
Why Monoliths are bad!
• Changeability / Flexibility
• Maintainability
• Scalability
• Resilience
• Framework/Tech-Stack Lock-in
So, where to start?!?
HTML+
jQuery
DB
OpenWeather
Resource
Services
HTML+
jQuery
DB
OpenWeather
Resource
Services
Gateway
Spring Cloud [Netflix]
• Proxy/Router – Zuul
• Service Registry and Discovery — Eureka
• Cirtcuit Breaker — Hystrix
• (Client Side) Load Balancing — Ribbon
• Configuration Management — Archaius
Say hello to Zuul!
Works, but not nice!
Static routes
• are hard to maintain
• have to be updated when service instance
changes
• do not offer load balancing between multiple
instances
• do not cater for service failures
HTML+
jQuery
DB
OpenWeatherResource
Services
Gateway
Registry
HTML+
jQuery
DB
OpenWeatherResource
Services
Gateway
Registry
Services
Please welcome Eureka!
The services are still mixing
members with weather.
DB
OpenWeather
ServicesGateway
DB
OpenWeather
Services
Gateway
Services
DB
OpenWeather
Gateway
members
weather
demo
What’s next?
Distributed Tracing
HTML+
jQuery
DB
OpenWeather
Resource
Gateway
Registry
members
weather
Zipkin
Greetings Zipkin
Circuit Breaker
Why?
Gateway
A B C D E
F G H I J
Request
Request H
Request
Request
Request
Request
Request
Why?
99.5% uptime( )1010 components: ≈ 95% — 1 hour down / day
99.5% uptime( )2020 components: ≈ 90% — 2.5 hour down / day
99.5% uptime( )3030 components: ≈ 86% — 3+ hour down / day
How?
• Fail fast, fail silent, rapidly recover
• Stop cascading issues
• Fallback gracefully (where possible)
• Enable Monitoring, Alerting
HTML+
jQuery
DB
OpenWeather
Resource
Gateway
Registry
members
weather
turbine
hystrix
dashboard
Hej Hystrix/Turbine
One more thing
A few
s
Polyglotism
• different languages
• different frameworks
• different datastores
• Eureka very specific for AWS  😕
• Eureka Client lib Java only 😩
What about .net?
• Nancy – Microservice Framework
• Polly – Circuit Breaker
• a lot to come with ASP.Net Core
11/13 chapters done
release in Fall 2016
Eureka
@EnableDiscoveryClient
• distributed Key-Value-Store
• REST Interface
• DNS Interface #
• Multi Datacenter
• Client libs for Go, Python, PHP,
Scala, Java, Erlang, Ruby, node.js
and C#
• Replaces Eureka, Config Server,
Cloud Bus
• distributed Key-Value-Store
• REST Interface
• DNS Interface with SkyDNS
• very lightweight
• easy to use
• Client libs for Go, Python, Java,
Scala, node.js, Ruby, C, C++, C#,
Clojure, Erlang, PHP, Haskell, R,
…
• Replaces Eureka, Config Server
• distributed Key-Value-Store
• build in Java originally to do Leader Election for Hadoop
Clusters
• very mature and stable / huge community
• Client libs for Java, C#, PHP, Ruby, node.js, …
• Curator by Netflix makes things easier
• Replaces Eureka, Config Server and brings Leader Election,
e.g. for Scheduled tasks in a whole cluster.
Zookeeper
What else?
• Spring Cloud Task – AWS 𝜆-like API
• Spring Cloud Security – OAuth2 Infrastructure
• Spring Cloud Bus – Messaging between all
components using Redis, AMQP, RabbitMQ, …
• Spring Cloud Stream – Message driven
Microservices using Redis, Kafka, RabbitMQ, …
?
Daniel Eichten
daniel.eichten@adidas-group.com
@danieleichten
Paul Vassu
paul.vassu@adidas-group.com
http://www.slideshare.net/DanielEichten/microservices-with-spring-cloud-63291299
https://github.com/deichten/dwx-spring-cloud
https://github.com/deichten/dwx-spring-cloud-config

Microservices with Spring Cloud