four times microservices rest kubernetes ui integration
play

Four times Microservices: REST, Kubernetes, UI Integration, Async - PowerPoint PPT Presentation

Four times Microservices: REST, Kubernetes, UI Integration, Async Eberhard Wolff @ewolff http://ewolff.com Fellow http://continuous-delivery-buch.de/ http://continuous-delivery-book.com/ http://microservices-buch.de/


  1. Four times Microservices: REST, Kubernetes, UI Integration, Async Eberhard Wolff @ewolff http://ewolff.com Fellow

  2. http://continuous-delivery-buch.de/ http://continuous-delivery-book.com/

  3. http://microservices-buch.de/ http://microservices-book.com/

  4. FREE!!!! http://microservices-buch.de/ http://microservices-book.com/ ueberblick.html primer.html

  5. What are Microservices? > Modules providing interfaces > Processes, Containers, virtual machines

  6. What are Microservices? > Independent Continuous Delivery Pipeline including tests > Standardized Operations (configuration, log analysis, tracing, monitoring, deployment) > Resilient (compensate failure, crashes …) therefore separate processes, VM, Docker containers

  7. Microservices = Extreme Decoupling

  8. Operational Extreme Complexity Decoupling

  9. Link Micro Micro Service Service Sync Async

  10. Synchronous REST Microservices

  11. external HTTP internal REST Customer Order Catalog

  12. Synchronous Microservices > Service Discovery: IP / port? > Load Balancing: Resilience and independent scaling > Routing: Route external request to microservices > Resilience

  13. Synchronous Microservices with Java, Spring Boot / Cloud & the Netflix Stack

  14. https://github.com/ ewolff/microservice

  15. Service Discovery Eureka

  16. Why Eureka for Service Discovery? > REST based service registry > Supports replication > Caches on the client > Resilient > Fast > Foundation for other services

  17. Eureka Client > @EnableDiscoveryClient: generic > @EnableEurekaClient: specific > Dependency on spring-cloud-starter-eureka > Automatically registers application

  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. Load Balancing Ribbon

  20. Ribbon: Client Side Load Balancing Server Load Client Balancer > Decentralized Load Balancing > No bottle neck > Resilient

  21. Ribbon Example Via Dependency Injection private LoadBalancerClient loadBalancer; Eureka name … ServiceInstance instance = loadBalancer.choose("CATALOG"); String url = "http://" + instance.getHost() + ":” + instance.getPort() + "/catalog/"; Need dependency to spring-cloud-starter-ribbon

  22. Resilience

  23. Timeout > Do call in other thread pool > Won’t block request handler > Can implement timeout

  24. Circuit Breaker > Called system fails -> open > Open -> do not forward call > Forward calls after a time window

  25. Hystrix & Spring Cloud > Annotation based approach > Annotations of javanica libraries > Simplifies Hystrix > No commands

  26. Enable Hystrix @SpringBootApplication @EnableDiscoveryClient @EnableCircuitBreaker public public class class OrderApp OrderApp { public public static static void void main(String[] main(String[] args args) { ) { SpringApplication.run(OrderApp. class class, , args args); ); } } Need spring-cloud-starter-hystrix

  27. Fallback @HystrixCommand(fallbackMethod = "getItemsCache", commandProperties = { @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "2") } ) public public Collection<Item> Collection<Item> findAll findAll() { () { … this this.itemsCache itemsCache = = pagedResources pagedResources.getContent .getContent(); (); return return itemsCache itemsCache; } private private Collection<Item> Collection<Item> getItemsCache getItemsCache() { () { return return itemsCache itemsCache; }

  28. Zuul Routing

  29. Routing > One URL to the outside > Internal: Many Microservices > REST > Or HTML GUI > Hides internal structure (sort of) > Might add filters

  30. Automatically maps route to server registered on Eureka i.e. /customer/** Zuul to CUSTOMER Proxy No configuration Customer Order Catalog

  31. Netflix Stack > Service Discovery: Eureka > Load Balancing: Ribbon > Routing: Zuul > Resilience: Hystrix > Non-Java microservice: specific clients or sidecar

  32. 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

  33. https://github.com/ ewolff/microservice-consul

  34. Kubernetes

  35. https://github.com/ ewolff/microservice- kubernetes

  36. Kubernetes > Docker container on a single machine: Not resilient enough > Kubernetes: Run Docker container in cluster > …and much more!

  37. Pods > Kubernetes runs Pods > Pods = 1..n Docker containers > Shared volumes > …and ports

  38. Replica Sets > Deployment creates replica set > Replica sets ensure that a certain number of Pods run > ...for load balancing / fail over

  39. Services > Services ensure access to the Pods > DNS entry > Cluster-wide unique IP address for internal access > Node port … > … or external load balancer for external access

  40. Pod starts Service Replica Set DNS creates Cluster IP address Pod Deployment Load Balancer

  41. Load Balancer Service 1 Service 2 Load Balancer Kubernetes Cluster Server (e.g. Amazon Elastic Load Balancer) Service 1 Service Service 2 adds a load Kubernetes Cluster Server balancer

  42. Kubernetes > Service Discovery: DNS > Load Balancing: IP > Routing: Load Balancer or Node Port > Resilience: Hystrix? envoy proxy? > Can use any language

  43. No code dependencies on Kubernetes!

  44. UI Integration

  45. UI Integration > Very powerful > Often overlooked > UI should be part of a microservices > Self-contained System emphasize UI > http://scs-architecture.org/

  46. System 1 System 2 Hyperlinks to navigate between systems.

  47. System 1 System 2 Transclusion of content served by another application

  48. https://www.innoq.com/ en/blog/transclusion/

  49. UI Integration > Extremely decoupled > Here is a link: http://ewolff.com > No need to know anything else about the system > What about more complex transclusion?

  50. Server-side integration Browser Backend 1 UI 1 Frontend Server UI 2 Backend 2

  51. Server-side Integration: Technologies > ESI (Edge Side Include) > E.g. Varnish cache > SSI (Server Side Include) > E.g. Apache httpd, Nginx

  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. 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. https://github.com/ ewolff/SCS-ESI

  55. Client-side integration Browser UI 1 Backend 1 UI 2 Backend 2

  56. Client-side Integration: Code Replace <a href= " " class= "embeddable"> with content of document in a <div> (jQuery) $("a.embeddable").each( fun tion (i, link) { functi $("<div />").load(link.href, fun functi tion (data, status, xhr) { $(link).replaceWith( thi this ); }); });

  57. https://github.com/ ewolff/SCS-jQuery

  58. https://github.com/ ewolff/crimson- insurance-demo

  59. Asynchronous Microservices

  60. Asynchronous > Do not talk to other microservices > ...and wait for a reply > …while processing a request. > Either don‘t wait for a reply > ...or don‘t communicate while processing a request.

  61. Asynchronous: Benefits > Deals with unreliable systems > Can guarantee delivery > Good fit for events > …and Bounded Context / DDD

  62. Invoice Order Delivery

  63. Kafka

  64. https://github.com/ ewolff/microservice-kafka

  65. Kafka API > Producer API > Consumer API > Streams API (transformation)

  66. Kafka Records > Key Record Key > Value Value > Timestamp Timestamp > No headers > Stored forever (!)

  67. Kafka Topics > Named Record > Topics have partitions Record > Order guaranteed per partition Record > Consumer commits offset per partition Partition > Consumer group: One consumer Topic per partition

  68. Offset committed per consumer Record Offset Record Record Record Offset Record Record Record Record Record Partition Partition Partition Topic Producer

  69. Log Compaction Record > Remove all but the latest record id=42 with a given key Record > Idea: Old events not relevant id=23 > …if new events override Record id=42 > Efficient storage in the long run Partition

Recommend


More recommend