Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Microservices –
Implementations not
only with Java
Eberhard Wolff
http://ewolff.com
@ewolff
Fellow
http://continuous-delivery-buch.de/ http://continuous-delivery-book.com/
http://microservices-buch.de/ http://microservices-book.com/
http://microservices-book.com/
primer.html
http://microservices-buch.de/
ueberblick.html
FREE!!!!
What are
Microservices?
> Modules providing interfaces
> Processes, Containers, virtual machines
> Standardized communicat...
What are
Microservices?
> Independent Continuous Delivery Pipeline including
tests
> Standardized Operations
(configuratio...
Microservices =
Extreme Decoupling
Operational
Complexity
Extreme
Decoupling
Micro
Service
Micro
Service
Link
Sync
Async
Synchronous REST
Microservices
Customer Order Catalog
REST
internal
HTTP
external
Synchronous Microservices
> Service Discovery:
IP / port?
> Load Balancing:
Resilience and independent scaling
> Routing:
...
Synchronous
Microservices with
Java, Spring Boot /
Cloud & the Netflix
Stack
https://github.com/
ewolff/microservice
Service Discovery
Eureka
Why Eureka for Service
Discovery?
> REST based service registry
> Supports replication
> Caches on the client
> Resilient
...
Eureka Client
> @EnableDiscoveryClient:
generic
> @EnableEurekaClient:
specific
> Dependency on
spring-cloud-starter-eurek...
Eureka Server
@EnableEurekaServer
@EnableAutoConfiguration
public class EurekaApplication {
public static void main(String...
Load Balancing
Ribbon
Client
Ribbon: Client Side
Load Balancing
> Decentralized Load Balancing
> No bottle neck
> Resilient
Load
Balancer
Server
Ribbon Example
private LoadBalancerClient loadBalancer;
…
ServiceInstance instance = loadBalancer.choose("CATALOG");
Strin...
Resilience
Timeout
> Do call in other thread pool
> Won’t block request handler
> Can implement timeout
Circuit Breaker
> Called system fails -> open
> Open -> do not forward call
> Forward calls after a time window
Hystrix
Configuration
> Failure Percentage
> Time window until open configurable
> Time window to reject requests
> …
> ht...
Hystrix &
Spring Cloud
> Annotation based approach
> Annotations of javanica libraries
> Simplifies Hystrix
> No commands
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
public class OrderApp {
public static void main(String...
@HystrixCommand(fallbackMethod = "getItemsCache",
commandProperties = { @HystrixProperty(name =
"circuitBreaker.requestVol...
Zuul
Routing
Routing
> One URL to the outside
> Internal: Many Microservices
> REST
> Or HTML GUI
> Hides internal structure (sort of)
...
Customer Order Catalog
Zuul
Proxy
Automatically maps route to server registered on Eureka
i.e. /customer/**
to CUSTOMER
No...
Netflix Stack
> Service Discovery: Eureka
> Load Balancing: Ribbon
> Routing: Zuul
> Resilience: Hystrix
> Non-Java micros...
Consul
> Service Discovery by Hashicorp
> DNS interface
> Platform independent
> Consul Template can fill out config file
...
https://github.com/
ewolff/microservice-consul
Kubernetes
https://github.com/
ewolff/microservice-
kubernetes
Kubernetes
> Docker container on a single machine:
Not resilient enough
> Kubernetes: Run Docker container in cluster
> …a...
Pods
> Kubernetes runs Pods
> Pods = 1..n Docker containers
> Shared volumes
> …and ports
Replica Sets
> Deployment creates replica set
> Replica sets ensure that a certain number of
Pods run
> ...for load balanc...
Services
> Services ensure access to the Pods
> DNS entry
> Cluster-wide unique IP address for internal
access
> External ...
Replica Set
Pod
Pod
Service
starts
DNS
Cluster IP
address
Load Balancer
Deployment
creates
Load Balancer
Kubernetes Cluster Server
Service 1
Service 2
Kubernetes Cluster Server
Service 1
Service 2Service
adds a lo...
Kubernetes
> Service Discovery: DNS
> Load Balancing: IP
> Routing: Load Balancer or Node Port
> Resilience: Hystrix? envo...
No code
dependencies on
Kubernetes!
UI Integration
UI Integration
> Very powerful
> Often overlooked
> UI should be part of a microservices
> Self-contained System emphasize...
Hyperlinks to navigate between
systems.
System 1 System 2
Transclusion of content served
by another application
System 1 System 2
https://www.innoq.com/
en/blog/transclusion/
Server-side integration
> Centralized aggregation
> Bottleneck (runtime/development time)
Browser
UI 1
UI 2
Frontend
Serve...
Server-side Integration:
Technologies
> ESI (Edge Side Include)
> E.g. Varnish cache
> SSI (Server Side Include)
> E.g. Ap...
ESI (Edge Side Includes)
...
<header>
... Logged in as: Ada Lovelace ...
</header>
...
<div>
... a lot of static content a...
ESI (Edge Side Includes)
...
<esi:include src="http://example.com/header" />
...
<div>
... a lot of static content and ima...
https://github.com/
ewolff/SCS-ESI
Client-side integration
Browser
UI 1
UI 2
Backend 1
Backend 2
Client-side Integration:
Code
$("a.embeddable").each(function(i, link) {
$("<div />").load(link.href, function(data, statu...
Transclusion
> Tighter coupling than links
> …but still very loose
> Common CSS
> (Avoid) common JavaScript
> Layout
> Loo...
https://github.com/
ewolff/SCS-jQuery
https://github.com/
ewolff/
crimson-assurance-demo
Conclusion
Operational
Complexity
Extreme
Decoupling
Conclusion:
Communication
> Netflix: Java focus, code dependencies
> Kubernetes: No code dependencies
> UI Integration mor...
Links
> List of microservices demos (sync, async, UI):
http://ewolff.com/microservices-demos.html
> REST vs. Messaging for...
EMail jugsaxony2017@ewolff.com to get:
Slides
+ Microservices Primer
+ Sample Microservices Book
+ Sample of Continuous De...
Microservices - not just with Java
Upcoming SlideShare
Loading in …5
×

Microservices - not just with Java

1,016 views

Published on

This presentation show several options how to implement microservices: the Netflix stack, Consul, and Kubernetes. Also integration options like REST and UI integration are covered.

Published in: Technology
  • $9.99 Getting started with microservices [From zero to production] Flash Sale 🌟 https://www.udemy.com/getting-started-with-microservices-from-zero-to-production/?couponCode=NEW2018DISCOUNT
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Microservices - not just with Java

  1. 1. Microservices – Implementations not only with Java Eberhard Wolff http://ewolff.com @ewolff Fellow
  2. 2. http://continuous-delivery-buch.de/ http://continuous-delivery-book.com/
  3. 3. http://microservices-buch.de/ http://microservices-book.com/
  4. 4. http://microservices-book.com/ primer.html http://microservices-buch.de/ ueberblick.html FREE!!!!
  5. 5. What are Microservices? > Modules providing interfaces > Processes, Containers, virtual machines > Standardized communication: Synchronous, asynchronous, or UI integration > Macro- and Micro-Architecture i.e. clearly defined common, and specific decisions
  6. 6. What are Microservices? > Independent Continuous Delivery Pipeline including tests > Standardized Operations (configuration, log analysis, tracing, monitoring, deployment) > Standards on the interface level e.g. not a specific log library > Resilient (compensate failure, crashes …) therefore separate processes, VM, Docker containers
  7. 7. Microservices = Extreme Decoupling
  8. 8. Operational Complexity Extreme Decoupling
  9. 9. Micro Service Micro Service Link Sync Async
  10. 10. Synchronous REST Microservices
  11. 11. Customer Order Catalog REST internal HTTP external
  12. 12. Synchronous Microservices > Service Discovery: IP / port? > Load Balancing: Resilience and independent scaling > Routing: Route external request to microservices > Resilience
  13. 13. Synchronous Microservices with Java, Spring Boot / Cloud & the Netflix Stack
  14. 14. https://github.com/ ewolff/microservice
  15. 15. Service Discovery Eureka
  16. 16. Why Eureka for Service Discovery? > REST based service registry > Supports replication > Caches on the client > Resilient > Fast > Foundation for other services
  17. 17. Eureka Client > @EnableDiscoveryClient: generic > @EnableEurekaClient: specific > Dependency on spring-cloud-starter-eureka > Automatically registers application
  18. 18. Eureka Server @EnableEurekaServer @EnableAutoConfiguration public class EurekaApplication { public static void main(String[] args) { SpringApplication.run(EurekaApplication.class, args); } } Add dependency to spring-cloud-starter-eureka-server
  19. 19. Load Balancing Ribbon
  20. 20. Client Ribbon: Client Side Load Balancing > Decentralized Load Balancing > No bottle neck > Resilient Load Balancer Server
  21. 21. Ribbon Example private LoadBalancerClient loadBalancer; … ServiceInstance instance = loadBalancer.choose("CATALOG"); String url = "http://" + instance.getHost() + ":” + instance.getPort() + "/catalog/"; Via Dependency Injection Eureka name Need dependency to spring-cloud-starter-ribbon
  22. 22. Resilience
  23. 23. Timeout > Do call in other thread pool > Won’t block request handler > Can implement timeout
  24. 24. Circuit Breaker > Called system fails -> open > Open -> do not forward call > Forward calls after a time window
  25. 25. Hystrix Configuration > Failure Percentage > Time window until open configurable > Time window to reject requests > … > https://github.com/Netflix/Hystrix/wiki/Con figuration
  26. 26. Hystrix & Spring Cloud > Annotation based approach > Annotations of javanica libraries > Simplifies Hystrix > No commands
  27. 27. @SpringBootApplication @EnableDiscoveryClient @EnableCircuitBreaker public class OrderApp { public static void main(String[] args) { SpringApplication.run(OrderApp.class, args); } } Enable Hystrix Need spring-cloud-starter-hystrix
  28. 28. @HystrixCommand(fallbackMethod = "getItemsCache", commandProperties = { @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "2") } ) public Collection<Item> findAll() { … this.itemsCache = pagedResources.getContent(); return itemsCache; } private Collection<Item> getItemsCache() { return itemsCache; } Fallback
  29. 29. Zuul Routing
  30. 30. Routing > One URL to the outside > Internal: Many Microservices > REST > Or HTML GUI > Hides internal structure (sort of) > Might add filters
  31. 31. Customer Order Catalog Zuul Proxy Automatically maps route to server registered on Eureka i.e. /customer/** to CUSTOMER No configuration
  32. 32. Netflix Stack > Service Discovery: Eureka > Load Balancing: Ribbon > Routing: Zuul > Resilience: Hystrix > Non-Java microservice: specific clients or sidecar
  33. 33. Consul > Service Discovery by Hashicorp > DNS interface > Platform independent > Consul Template can fill out config file templates > e.g. for load balancer > …unaware of service discovery
  34. 34. https://github.com/ ewolff/microservice-consul
  35. 35. Kubernetes
  36. 36. https://github.com/ ewolff/microservice- kubernetes
  37. 37. Kubernetes > Docker container on a single machine: Not resilient enough > Kubernetes: Run Docker container in cluster > …and much more!
  38. 38. Pods > Kubernetes runs Pods > Pods = 1..n Docker containers > Shared volumes > …and ports
  39. 39. Replica Sets > Deployment creates replica set > Replica sets ensure that a certain number of Pods run > ...for load balancing / fail over
  40. 40. Services > Services ensure access to the Pods > DNS entry > Cluster-wide unique IP address for internal access > External load balancer for external access
  41. 41. Replica Set Pod Pod Service starts DNS Cluster IP address Load Balancer Deployment creates
  42. 42. Load Balancer Kubernetes Cluster Server Service 1 Service 2 Kubernetes Cluster Server Service 1 Service 2Service adds a load balancer Load Balancer (e.g. Amazon Elastic Load Balancer)
  43. 43. Kubernetes > Service Discovery: DNS > Load Balancing: IP > Routing: Load Balancer or Node Port > Resilience: Hystrix? envoy proxy? > Can use any language
  44. 44. No code dependencies on Kubernetes!
  45. 45. UI Integration
  46. 46. UI Integration > Very powerful > Often overlooked > UI should be part of a microservices > Self-contained System emphasize UI > http://scs-architecture.org/
  47. 47. Hyperlinks to navigate between systems. System 1 System 2
  48. 48. Transclusion of content served by another application System 1 System 2
  49. 49. https://www.innoq.com/ en/blog/transclusion/
  50. 50. Server-side integration > Centralized aggregation > Bottleneck (runtime/development time) Browser UI 1 UI 2 Frontend Server Backend 1 Backend 2
  51. 51. Server-side Integration: Technologies > ESI (Edge Side Include) > E.g. Varnish cache > SSI (Server Side Include) > E.g. Apache httpd, Nginx
  52. 52. ESI (Edge Side Includes) ... <header> ... Logged in as: Ada Lovelace ... </header> ... <div> ... a lot of static content and images ... </div> ... <div> some dynamic content </div>
  53. 53. ESI (Edge Side Includes) ... <esi:include src="http://example.com/header" /> ... <div> ... a lot of static content and images ... </div> ... <esi:include src="http://example.com/dynamic" /> http://www.w3.org/TR/esi-lang
  54. 54. https://github.com/ ewolff/SCS-ESI
  55. 55. Client-side integration Browser UI 1 UI 2 Backend 1 Backend 2
  56. 56. Client-side Integration: Code $("a.embeddable").each(function(i, link) { $("<div />").load(link.href, function(data, status, xhr) { $(link).replaceWith(this); }); }); Replace <a href= " " class= "embeddable"> with content of document in a <div> (jQuery)
  57. 57. Transclusion > Tighter coupling than links > …but still very loose > Common CSS > (Avoid) common JavaScript > Layout > Look & Feel
  58. 58. https://github.com/ ewolff/SCS-jQuery
  59. 59. https://github.com/ ewolff/ crimson-assurance-demo
  60. 60. Conclusion
  61. 61. Operational Complexity Extreme Decoupling
  62. 62. Conclusion: Communication > Netflix: Java focus, code dependencies > Kubernetes: No code dependencies > UI Integration more decoupling
  63. 63. Links > List of microservices demos (sync, async, UI): http://ewolff.com/microservices-demos.html > REST vs. Messaging for Microservices https://www.slideshare.net/ewolff/rest-vs- messaging-for-microservices
  64. 64. EMail jugsaxony2017@ewolff.com to get: Slides + Microservices Primer + Sample Microservices Book + Sample of Continuous Delivery Book Powered by Amazon Lambda & Microservices

×