four times microservices: rest, kubernetes, ui integration, async · 2017. 10. 17. · >...
TRANSCRIPT
![Page 1: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/1.jpg)
Four times Microservices:REST, Kubernetes,
UI Integration, AsyncEberhard Wolff
@ewolffhttp://ewolff.com
Fellow
![Page 2: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/2.jpg)
http://continuous-delivery-buch.de/ http://continuous-delivery-book.com/
![Page 3: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/3.jpg)
http://microservices-buch.de/ http://microservices-book.com/
![Page 4: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/4.jpg)
http://microservices-book.com/primer.html
http://microservices-buch.de/ueberblick.html
FREE!!!!
![Page 5: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/5.jpg)
What are Microservices?
> Modules providing interfaces
> Processes, Containers, virtual machines
![Page 6: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/6.jpg)
What are Microservices?
> Independent Continuous Delivery Pipelineincluding tests
> Standardized Operations(configuration, log analysis, tracing, monitoring, deployment)
> Resilient (compensate failure, crashes …)therefore separate processes, VM, Docker containers
![Page 7: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/7.jpg)
Microservices =Extreme Decoupling
![Page 8: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/8.jpg)
Operational Complexity
Extreme Decoupling
![Page 9: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/9.jpg)
MicroService
MicroService
Link
SyncAsync
![Page 10: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/10.jpg)
Synchronous REST Microservices
![Page 11: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/11.jpg)
Customer Order Catalog
RESTinternal
HTTPexternal
![Page 12: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/12.jpg)
Synchronous Microservices
> Service Discovery:IP / port?
> Load Balancing:Resilience and independent scaling
> Routing:Route external request to microservices
> Resilience
![Page 13: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/13.jpg)
Synchronous Microservices with Java, Spring Boot / Cloud & the Netflix
Stack
![Page 14: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/14.jpg)
https://github.com/ewolff/microservice
![Page 15: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/15.jpg)
Service DiscoveryEureka
![Page 16: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/16.jpg)
Why Eureka for Service Discovery?
> REST based service registry
> Supports replication
> Caches on the client
> Resilient
> Fast
> Foundation for other services
![Page 17: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/17.jpg)
Eureka Client
> @EnableDiscoveryClient:generic
> @EnableEurekaClient:specific
> Dependency onspring-cloud-starter-eureka
> Automatically registers application
![Page 18: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/18.jpg)
Eureka Server@EnableEurekaServer
@EnableAutoConfiguration
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}
Add dependency tospring-cloud-starter-eureka-server
![Page 19: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/19.jpg)
![Page 20: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/20.jpg)
Load BalancingRibbon
![Page 21: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/21.jpg)
Client
Ribbon: Client Side Load Balancing
> Decentralized Load Balancing
> No bottle neck
> Resilient
LoadBalancer
Server
![Page 22: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/22.jpg)
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
![Page 23: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/23.jpg)
Resilience
![Page 24: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/24.jpg)
Timeout
> Do call in other thread pool
> Won’t block request handler
> Can implement timeout
![Page 25: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/25.jpg)
Circuit Breaker
> Called system fails -> open
> Open -> do not forward call
> Forward calls after a time window
![Page 26: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/26.jpg)
Hystrix &Spring Cloud
> Annotation based approach
> Annotations of javanica libraries
> Simplifies Hystrix
> No commands
![Page 27: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/27.jpg)
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
public class OrderApp {
public static void main(String[] args) {
SpringApplication.run(OrderApp.class, args);
}
}
Enable Hystrix
Need spring-cloud-starter-hystrix
![Page 28: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/28.jpg)
@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
![Page 29: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/29.jpg)
ZuulRouting
![Page 30: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/30.jpg)
Routing> One URL to the outside
> Internal: Many Microservices
> REST
> Or HTML GUI
> Hides internal structure (sort of)
> Might add filters
![Page 31: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/31.jpg)
Customer Order Catalog
ZuulProxy
Automatically maps route to server registered on Eureka
i.e. /customer/**to CUSTOMER
No configuration
![Page 32: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/32.jpg)
Netflix Stack
> Service Discovery: Eureka
> Load Balancing: Ribbon
> Routing: Zuul
> Resilience: Hystrix
> Non-Java microservice:specific clients or sidecar
![Page 33: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/33.jpg)
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
![Page 34: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/34.jpg)
https://github.com/ewolff/microservice-consul
![Page 35: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/35.jpg)
Kubernetes
![Page 36: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/36.jpg)
https://github.com/ewolff/microservice-
kubernetes
![Page 37: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/37.jpg)
Kubernetes
> Docker container on a single machine:Not resilient enough
> Kubernetes: Run Docker container in cluster
> …and much more!
![Page 38: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/38.jpg)
Pods
> Kubernetes runs Pods
> Pods = 1..n Docker containers
> Shared volumes
> …and ports
![Page 39: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/39.jpg)
Replica Sets
> Deployment creates replica set
> Replica sets ensure that a certain number of Pods run
> ...for load balancing / fail over
![Page 40: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/40.jpg)
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
![Page 41: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/41.jpg)
Replica Set
Pod
Pod
Service
starts
DNS
Cluster IPaddress
Load BalancerDeployment
creates
![Page 42: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/42.jpg)
Load Balancer
Kubernetes Cluster Server
Service 1
Service 2
Kubernetes Cluster Server
Service 1
Service 2Serviceadds a load
balancer
Load Balancer(e.g. Amazon
ElasticLoad Balancer)
![Page 43: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/43.jpg)
Kubernetes
> Service Discovery: DNS
> Load Balancing: IP
> Routing: Load Balancer or Node Port
> Resilience: Hystrix? envoy proxy?
> Can use any language
![Page 44: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/44.jpg)
No code dependencies on
Kubernetes!
![Page 45: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/45.jpg)
UI Integration
![Page 46: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/46.jpg)
UI Integration
> Very powerful
> Often overlooked
> UI should be part of a microservices
> Self-contained System emphasize UI
> http://scs-architecture.org/
![Page 47: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/47.jpg)
Hyperlinks to navigate between systems.
System 1 System 2
![Page 48: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/48.jpg)
Transclusion of content served by another application
System 1 System 2
![Page 49: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/49.jpg)
https://www.innoq.com/en/blog/transclusion/
![Page 50: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/50.jpg)
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?
![Page 51: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/51.jpg)
Server-side integration
Browser
UI 1
UI 2
FrontendServer
Backend 1
Backend 2
![Page 52: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/52.jpg)
Server-side Integration: Technologies
> ESI (Edge Side Include)
> E.g. Varnish cache
> SSI (Server Side Include)
> E.g. Apache httpd, Nginx
![Page 53: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/53.jpg)
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>
![Page 54: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/54.jpg)
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
![Page 55: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/55.jpg)
https://github.com/ewolff/SCS-ESI
![Page 56: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/56.jpg)
Client-side integration
Browser
UI 1
UI 2
Backend 1
Backend 2
![Page 57: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/57.jpg)
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)
![Page 58: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/58.jpg)
https://github.com/ewolff/SCS-jQuery
![Page 59: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/59.jpg)
https://github.com/ewolff/crimson-insurance-demo
![Page 60: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/60.jpg)
Asynchronous Microservices
![Page 61: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/61.jpg)
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.
![Page 62: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/62.jpg)
Asynchronous: Benefits
> Deals with unreliable systems
> Can guarantee delivery
> Good fit for events
> …and Bounded Context / DDD
![Page 63: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/63.jpg)
Order
Invoice
Delivery
![Page 64: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/64.jpg)
Kafka
![Page 65: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/65.jpg)
https://github.com/ewolff/microservice-kafka
![Page 66: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/66.jpg)
Kafka API
> Producer API
> Consumer API
> Streams API (transformation)
![Page 67: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/67.jpg)
Kafka Records
> Key
> Value
> Timestamp
> No headers
> Stored forever (!)
RecordKey
ValueTimestamp
![Page 68: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/68.jpg)
Kafka Topics
> Named
> Topics have partitions
> Order guaranteed per partition
> Consumer commits offset per partition
> Consumer group: One consumer per partition
Topic
Partition
Record
Record
Record
![Page 69: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/69.jpg)
Topic
Partition
Record
Record
Record
Producer
Offset
Offset committed per consumer
Offset
Partition
Record
Record
Record
Partition
Record
Record
Record
![Page 70: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/70.jpg)
Log Compaction
> Remove all but the latest record with a given key
> Idea: Old events not relevant
> …if new events override
> Efficient storage in the long run
Partition
Recordid=42
Recordid=23
Recordid=42
![Page 71: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/71.jpg)
Kafka Replication
> N Replicas (configurable)
> In-sync replicas (configurable):write successful if all written
![Page 72: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/72.jpg)
Asynchronous Microservices
> Service Discovery:via topic
> Load Balancing:via partitions / consumer groups
> Routing:./.
> Resilienceservice fails – latency increases
![Page 73: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/73.jpg)
Kafka Conclusion
> Provides access to old events
> Guaranteed order per key
> (Log compaction also per key)
> Consumer groups send records to one consumer
> Additional (complex) infrastructure
![Page 74: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/74.jpg)
REST & ATOM
![Page 75: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/75.jpg)
https://github.com/ewolff/microservice-atom
![Page 76: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/76.jpg)
Atom
> Data format
> …for feeds, blogs, podcasts etc
> Access through HTTP
> Idea: Provide a feeds of events / orders
![Page 77: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/77.jpg)
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Order</title>
<link rel="self"href="http://localhost:8080/feed" />
<author><name>Big Money Inc.</name> </author>
<subtitle>List of all orders</subtitle>
<id>https://github.com/ewolff/microservice-atom/order</id>
<updated>2017-04-20T15:28:50Z</updated>
<entry> ... </entry>
</feed>
![Page 78: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/78.jpg)
<entry>
<title>Order 1</title>
<id>https://github.com/ewolff/microservice-atom/order/1</id>
<updated>2017-04-20T15:27:58Z</updated>
<content type="application/json“src="http://localhost:8080/order/1" />
<summary>This is the order 1</summary>
</entry>
![Page 79: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/79.jpg)
Atom Feed
> Some unneeded information
> …but not a lot
> Mostly links to details
> ...and timestamps
> Can use content negotiation to provide different data formats or details
![Page 80: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/80.jpg)
Subscribing to Feed
> Poll the feed (HTTP GET)
> Client decides when to process new events
> …but very inefficient
> Lots of unchanged data
![Page 81: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/81.jpg)
HTTP Caching
> Client GETs feed
> Server send data
> + Last-Modified header
> Client sends get
> + If-Modified-Since header
> Server: 304 (Not modified)
> …or new data
![Page 82: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/82.jpg)
REST can be asynchronous.
![Page 83: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/83.jpg)
Atom
> Service Discovery:REST
> Load Balancing:REST
> Routing:./.
> Resiliencefailures just increase latency
![Page 84: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/84.jpg)
Atom Conclusion
> Can provides access to old events if they are stored anyway.
> One consumer: idempotency
> No additional infrastructure
![Page 85: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/85.jpg)
Conclusion
![Page 86: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/86.jpg)
Operational Complexity
Extreme Decoupling
![Page 87: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/87.jpg)
Conclusion: Communication
> Netflix: Java focus, code dependencies
> Kubernetes: No code dependencies
> UI Integration: more decoupling
> Asynchronous deals with challenges in distributed systems
![Page 88: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/88.jpg)
Links
> List of microservices demos (sync, async, UI):http://ewolff.com/microservices-demos.html
> REST vs. Messaging for Microserviceshttps://www.slideshare.net/ewolff/rest-vs-messaging-for-microservices
![Page 89: Four times Microservices: REST, Kubernetes, UI Integration, Async · 2017. 10. 17. · > Routing: Route external request to microservices > Resilience. Synchronous Microservices with](https://reader036.vdocument.in/reader036/viewer/2022062604/5fbed50358e1b8107877ad3d/html5/thumbnails/89.jpg)
EMail [email protected] to get:
Slides+ Microservices Primer+ Sample Microservices Book+ Sample of Continuous Delivery Book
Powered by Amazon Lambda & Microservices