Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CodeMentor April 2015

CodeMentor April 2015

This was presented as a hangout session on codementor:

https://www.codementor.io/officehours/3965269104/codementor-office-hours-revolutionizing-ipc-with-nitesh-kant-of-netflix

This presentation introduces reactive IPC, it's core tenants and what value adds it brings vis-a-vis traditional IPC technologies.

Nitesh Kant

April 20, 2015
Tweet

More Decks by Nitesh Kant

Other Decks in Technology

Transcript

  1. Nitesh Kant - @NiteshKant - Software Engineer, Cloud Platform, Netflix

    Reactive IPC Revolutionize your Microservices
  2. Nitesh Kant Who Am I? ❖ Engineer, Cloud Platform, Netflix.

    ❖ Leading Reactive IPC @Netflix ❖ Core contributor, RxNetty* ❖ Contributor, Eureka** ❖ Suffers with OCD => API design * https://github.com/ReactiveX/RxNetty ** https://github.com/Netflix/eureka @NiteshKant
  3. IPC Any call made outside of your process to a

    remote machine or local, is an IPC call.
  4. Synchronous systems Consuming a resource (thread) per user request does

    bad things to you. http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html
  5. Synchronous systems Consuming a resource (thread) per user request does

    bad things to you. http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html You isolate yourself by introducing a queuing point.
  6. Synchronous systems Consuming a resource (thread) per user request does

    bad things to you. http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html You isolate yourself by introducing a queuing point. But then you are limited by the number of threads in the system.
  7. Asynchronous systems Multiple connections/requests multiplexed on a single thread (Eventloop).

    Eventloop (Inbound) Connection Connection Connection Connection Connection Eventloop (Outbound) Connection Connection Connection Connection Connection Application Code
  8. Asynchronous systems Multiple connections/requests multiplexed on a single thread (Eventloop).

    An Eventloop only does CPU work and does not block. Eventloop (Inbound) Connection Connection Connection Connection Connection Eventloop (Outbound) Connection Connection Connection Connection Connection Application Code
  9. Asynchronous systems Multiple connections/requests multiplexed on a single thread (Eventloop).

    An Eventloop only does CPU work and does not block. A single bad dependency/connection does not bring down the system. Eventloop (Inbound) Connection Connection Connection Connection Connection Eventloop (Outbound) Connection Connection Connection Connection Connection Application Code
  10. Asynchronous systems Multiple connections/requests multiplexed on a single thread (Eventloop).

    An Eventloop only does CPU work and does not block. As many Eventloops as CPUs. A single bad dependency/connection does not bring down the system. Eventloop (Inbound) Connection Connection Connection Connection Connection Eventloop (Outbound) Connection Connection Connection Connection Connection Application Code Eventloop (Inbound) Connection Connection Connection Connection Connection Eventloop (Outbound) Connection Connection Connection Connection Connection Eventloop (Inbound) Connection Connection Connection Connection Connection Eventloop (Outbound) Connection Connection Connection Connection Connection
  11. Movie Service User Service Service discovery Which are the instances

    of User Service? Instances I1, I2, I3 Any changes? Nope
  12. Movie Service User Service Service discovery Which are the instances

    of User Service? Instances I1, I2, I3 Any changes? Nope Any changes? I2 is dead
  13. Movie Service User Service Service discovery Which are the instances

    of User Service? Instances I1, I2, I3 Any changes? Nope Any changes? I2 is dead Somewhere here I2 died
  14. Movie Service User Service Service discovery Which are the instances

    of User Service? Instances I1, I2, I3 Any changes? Nope Any changes? I2 is dead Somewhere here I2 died
  15. Movie Service User Service Service discovery I am interested in

    User Service instances. Instances I1, I2, I3
  16. Movie Service User Service Service discovery I am interested in

    User Service instances. Instances I1, I2, I3 Any changes? Nope X
  17. Movie Service User Service Service discovery I am interested in

    User Service instances. Instances I1, I2, I3 I2 died
  18. Movie Service User Service Service discovery Which are the instances

    of User Service? Instances I1, I2, I3 Any changes? Nope Any changes? I2 is dead Somewhere here I2 died
  19. Service discovery IPC Reactive IPC Pull based discovery Push based

    discovery Implicit multi-stage delays Instantaneous updates
  20. Delivering Netflix Edge Service Personalized catalog service Ratings Service Video

    Metadata Service Bookmarks Service Disclaimer: This is an example and not an exact representation of the processing
  21. Edge Service Personalized catalog service Ratings Service Video Metadata Service

    Bookmarks Service Disclaimer: This is an example and not an exact representation of the processing
  22. Edge Service Personalized catalog service Ratings Service Video Metadata Service

    Bookmarks Service Disclaimer: This is an example and not an exact representation of the processing X User cancellation
  23. Edge Service Personalized catalog service Ratings Service Video Metadata Service

    Bookmarks Service Disclaimer: This is an example and not an exact representation of the processing X User cancellation X X X X
  24. Delivering Netflix Edge Service Video Metadata Service Disclaimer: This is

    an example and not an exact representation of the processing
  25. Edge Service Video Metadata Service Disclaimer: This is an example

    and not an exact representation of the processing Get 100 videos details (Batch API) Send Video details
  26. Edge Service Video Metadata Service Disclaimer: This is an example

    and not an exact representation of the processing Get 100 videos details (Batch API) Send Video details }X n
  27. Edge Service Video Metadata Service Disclaimer: This is an example

    and not an exact representation of the processing Get 100 videos details (Batch API) Send Video details }X n That’s too much of data!
  28. Edge Service Video Metadata Service Disclaimer: This is an example

    and not an exact representation of the processing Get 100 videos details (Batch API)
  29. Edge Service Video Metadata Service Disclaimer: This is an example

    and not an exact representation of the processing Get 100 videos details (Batch API) Request 5
  30. Edge Service Video Metadata Service Disclaimer: This is an example

    and not an exact representation of the processing Get 100 videos details (Batch API) Request 5 Send 5
  31. Edge Service Video Metadata Service Disclaimer: This is an example

    and not an exact representation of the processing Get 100 videos details (Batch API) Request 5 Send 5 Request 5 Send 5
  32. Edge Service Video Metadata Service Disclaimer: This is an example

    and not an exact representation of the processing Get 100 videos details (Batch API) Request 5 Send 5 Request 5 Send 5
  33. Client lib Failure detector Is Instance I1 healthy? Yep Still

    healthy? Nope Any client library Still healthy? Yep
  34. Client lib Failure detector Is Instance I1 healthy? Yep Still

    healthy? Nope Any client library Still healthy? Yep Somewhere here I1 died
  35. Client lib Failure detector Is Instance I1 healthy? Yep Still

    healthy? Nope Any client library Still healthy? Yep Somewhere here I1 died Errors & Retries
  36. Client lib Failure detector I am using I1, tell me

    when it dies Any client library
  37. Client lib Failure detector I am using I1, tell me

    when it dies I1 died Any client library
  38. Client lib Failure detector I am using I1, tell me

    when it dies I1 died Any client library Minimal Errors & Retries
  39. RxJava A library for composing asynchronous and event-based programs using

    observable sequences for the Java VM. http://github.com/ReactiveX/RxJava
  40. Delivering Netflix Edge Service Personalized catalog service Ratings Service Video

    Metadata Service Bookmarks Service Disclaimer: This is an example and not an exact representation of the processing
  41. return HttpServer.newServer(port) .start((req, resp) -> catalogClient.createGet("http://catalogservice/catalog") .switchMap(catalogResp -> resp.sendHeaders() .write(catalogResp.flatMap(catalog

    -> Catalog::videos) .flatMap(video -> Observable.zip(bookmarkClient.createGet("http://bookmarkservice/" + video.id()) .<Bookmark>flatMap(HttpClientResponse::getContent), ratingClient.createGet("http://ratingsservice/" + video.id()) .<Rating>flatMap(HttpClientResponse::getContent), metadataClient.createGet("http://metadataservice/" + video.id()) .<VideoMetadata>flatMap(HttpClientResponse::getContent), (b, r, m) -> combineVideoData(video, b, r, m))) ))); Delivering Netflix! Disclaimer: This is an example and not an exact representation of the processing
  42. return HttpServer.newServer(port) .start((req, resp) -> catalogClient.createGet("http://catalogservice/catalog") .switchMap(catalogResp -> resp.sendHeaders() .write(catalogResp.flatMap(catalog

    -> Catalog::videos) .flatMap(video -> Observable.zip(bookmarkClient.createGet("http://bookmarkservice/" + video.id()) .<Bookmark>flatMap(HttpClientResponse::getContent), ratingClient.createGet("http://ratingsservice/" + video.id()) .<Rating>flatMap(HttpClientResponse::getContent), metadataClient.createGet("http://metadataservice/" + video.id()) .<VideoMetadata>flatMap(HttpClientResponse::getContent), (b, r, m) -> combineVideoData(video, b, r, m))) ))); Delivering Netflix! Disclaimer: This is an example and not an exact representation of the processing
  43. return HttpServer.newServer(port) .start((req, resp) -> catalogClient.createGet("http://catalogservice/catalog") .switchMap(catalogResp -> resp.sendHeaders() .write(catalogResp.flatMap(catalog

    -> Catalog::videos) .flatMap(video -> Observable.zip(bookmarkClient.createGet("http://bookmarkservice/" + video.id()) .<Bookmark>flatMap(HttpClientResponse::getContent), ratingClient.createGet("http://ratingsservice/" + video.id()) .<Rating>flatMap(HttpClientResponse::getContent), metadataClient.createGet("http://metadataservice/" + video.id()) .<VideoMetadata>flatMap(HttpClientResponse::getContent), (b, r, m) -> combineVideoData(video, b, r, m))) ))); Delivering Netflix! Disclaimer: This is an example and not an exact representation of the processing
  44. return HttpServer.newServer(port) .start((req, resp) -> catalogClient.createGet("http://catalogservice/catalog") .switchMap(catalogResp -> resp.sendHeaders() .write(catalogResp.flatMap(catalog

    -> Catalog::videos) .flatMap(video -> Observable.zip(bookmarkClient.createGet("http://bookmarkservice/" + video.id()) .<Bookmark>flatMap(HttpClientResponse::getContent), ratingClient.createGet("http://ratingsservice/" + video.id()) .<Rating>flatMap(HttpClientResponse::getContent), metadataClient.createGet("http://metadataservice/" + video.id()) .<VideoMetadata>flatMap(HttpClientResponse::getContent), (b, r, m) -> combineVideoData(video, b, r, m))) ))); Delivering Netflix! Disclaimer: This is an example and not an exact representation of the processing
  45. return HttpServer.newServer(port) .start((req, resp) -> catalogClient.createGet("http://catalogservice/catalog") .switchMap(catalogResp -> resp.sendHeaders() .write(catalogResp.flatMap(catalog

    -> Catalog::videos) .flatMap(video -> Observable.zip(bookmarkClient.createGet("http://bookmarkservice/" + video.id()) .<Bookmark>flatMap(HttpClientResponse::getContent), ratingClient.createGet("http://ratingsservice/" + video.id()) .<Rating>flatMap(HttpClientResponse::getContent), metadataClient.createGet("http://metadataservice/" + video.id()) .<VideoMetadata>flatMap(HttpClientResponse::getContent), (b, r, m) -> combineVideoData(video, b, r, m))) ))); Delivering Netflix! Disclaimer: This is an example and not an exact representation of the processing
  46. return HttpServer.newServer(port) .start((req, resp) -> catalogClient.createGet("http://catalogservice/catalog") .switchMap(catalogResp -> resp.sendHeaders() .write(catalogResp.flatMap(catalog

    -> Catalog::videos) .flatMap(video -> Observable.zip(bookmarkClient.createGet("http://bookmarkservice/" + video.id()) .<Bookmark>flatMap(HttpClientResponse::getContent), ratingClient.createGet("http://ratingsservice/" + video.id()) .<Rating>flatMap(HttpClientResponse::getContent), metadataClient.createGet("http://metadataservice/" + video.id()) .<VideoMetadata>flatMap(HttpClientResponse::getContent), (b, r, m) -> combineVideoData(video, b, r, m))) ))); Delivering Netflix! Disclaimer: This is an example and not an exact representation of the processing
  47. return HttpServer.newServer(port) .start((req, resp) -> catalogClient.createGet("http://catalogservice/catalog") .switchMap(catalogResp -> resp.sendHeaders() .write(catalogResp.flatMap(catalog

    -> Catalog::videos) .flatMap(video -> Observable.zip(bookmarkClient.createGet("http://bookmarkservice/" + video.id()) .<Bookmark>flatMap(HttpClientResponse::getContent), ratingClient.createGet("http://ratingsservice/" + video.id()) .<Rating>flatMap(HttpClientResponse::getContent), metadataClient.createGet("http://metadataservice/" + video.id()) .<VideoMetadata>flatMap(HttpClientResponse::getContent), (b, r, m) -> combineVideoData(video, b, r, m))) ))); Delivering Netflix! Disclaimer: This is an example and not an exact representation of the processing
  48. Delivering Netflix Edge Service Observable Personalized catalog Service Ratings Service

    Video Metadata Service Observable Bookmarks Service Disclaimer: This is an example and not an exact representation of the processing Observable Observable Observable
  49. Client Server Unidirectional protocol (eg: HTTP/1) Observable Send response onNext

    Close connection unsubscribe Write Request Subscribe
  50. Client Server Send response onNext Send unsubscribe unsubscribe Write Request

    Subscribe Bidirectional protocol (eg: HTTP/2) Observable
  51. Your Services as an Observable.* * Courtesy: “Your Server as

    a function” - Marius Eriksen Reactive IPC
  52. Thank you! RxJava: https://github.com/ReactiveX/RxJava Reactive IPC: https://github.com/ReactiveX/RxNetty Service Discovery: https://github.com/Netflix/eureka/tree/2.x

    Load balancing: https://github.com/Netflix/ocelli Server as a function: http://monkey.org/~marius/funsrv.pdf Fallacies of distributed computing: en.wikipedia.org/wiki/ Fallacies_of_distributed_computing#The_fallacies Nitesh Kant @NiteshKant