Reactive microservice end to end from RxJava to the wire with gRPC

Slides:



Advertisements
Similar presentations
Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist.
Advertisements

Opensocial Flash/Flex Client Library Project:
RPC Robert Grimm New York University Remote Procedure Calls.
Implementing Remote Procedure Calls Andrew Birrell and Bruce Nelson Presented by Kai Cong.
Distributed Systems Lecture # 3. Administrivia Projects –Design and Implement a distributed file system Paper Discussions –Discuss papers as case studies.
Rensselaer Polytechnic Institute CSCI-4220 – Network Programming David Goldschmidt, Ph.D.
1 LiveViz – What is it? Charm++ library Visualization tool Inspect your program’s current state Client runs on any machine (java) You code the image generation.
Programming Network Servers Topic 6, Chapters 21, 22 Network Programming Kansas State University at Salina.
What Is New and Noteworthy in Jersey Miroslav Fuksa, Jakub Podlešák Software Developers Oracle, Application Server Group October 1, 2014 Copyright ©
Reactive Extensions Ye olde introduction and walk-through, with plenty o’ code.
Extending ArcGIS for Server
Leveraging ArcGIS Online Elevation and Hydrology Services
Virtual techdays INDIA │ august 2010 Deep Dive into WCF 4.0 Features Sarath S S V S │ Program Manager, BING, Microsoft India R&D.
Chat Room App Logan Linn Network Application Design Fall 2010.
FCM Workflow using GCM.
ASP.NET SignalR SoftUni Team Technical Trainers Software University
Thinking reactive. Who is speaking? Software developer at Seavus Member of JugMK coffee - code - pizza - repeat.
Node.Js 1. 2 Contents About Node.Js Web requirement latest trends Introduction Simple web server creation in Node.Js Dynamic Web pages Dynamic web page.
SOAP RMI Aleksander Slominski, Madhusudhan Govindaraju, Randall Bramley, Dennis Gannon Indiana University Extreme! Lab A New-Old Programming Model for.
Example of how to send SMS message with a VB.Net application In this presentation you can learn the method of sending SMS messages with a Vb.Net application.
Java Distributed Computing
A little more App Inventor and Mind the GAP!
Export Services Deep Dive
Real-Time GIS Leveraging Stream Services
Device Service SDK Deep Dive
Websocket Application
Advanced Topics in Distributed and Reactive Programming
ASP.NET SignalR SoftUni Team C# MVC Frameworks Technical Trainers
Fibers – blocking is cheap in a Parallel Universe jPrime Stefan Minev
Advanced Topics in Concurrency and Reactive Programming: The Observable Contract Majeed Kassis.
Java Distributed Computing
Tango Administrative Tools
Operating Systems (CS 340 D)
Trustin Lee Introduction to MINA Trustin Lee
A Deeper Look Into Reactive Streams with Akka Streams 1.0
Remote Method Invocation
Building High Performance Microservices with Apache Thrift
Building real-time web apps with WebSockets using IIS, ASP.NET and WCF
Node.Js Server Side Javascript
Java Socket Programming and Java RMI CS
Network and Distributed Programming in Java
MVC in ASP.NET Core: The new kid on the block
Take your microservices to the next level with gRPC
Parallel Programming in Contemporary Programming Languages (Part 2)
Advanced Topics in Distributed and Reactive Programming
Advanced Topics in Concurrency and Reactive Programming: ReactiveX
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Interpreter Style Examples
Getting Started With the JavaScript API
Connecting, Managing, Observing, and Securing Services
Reactive Android Development
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSCI-1680 RPC and Data Representation
Remote Procedure Call (invocation) RPC
autodiscoverable microservices with vertx3
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
INTRODUCTION TO By Stepan Vardanyan.
Creating a Distributed System with Remote Procedure Calls and Web Services Ch.5 B.Ramamurthy 2/17/2019 B.Ramamurthy.
CSE 451: Operating Systems Spring 2012 Module 22 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
J2EE Lecture 13: JMS and WebSocket
Leveraging ArcGIS Online Elevation and Hydrology Services
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Advanced Topics in Functional and Reactive Programming
Chapter 13: I/O Systems.
Java Socket Programming and Java RMI CSE 291
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Talking Between Services with gRPC
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Reactive microservice end to end from RxJava to the wire with gRPC project i've been working on - reactive grpc Ryan Michela @ Salesforce

Let’s poll the room Istio day earlier in week gRPC

Let’s poll the room RxJava

Let’s poll the room gRPC RxJava

ME About me gRPC RxJava Microservices practitioner A bit about myself - Salesforce service mesh gRPC RxJava Microservices practitioner Reactive programming enthusiast

What’s in this talk The story of reactive-grpc An overview of gRPC and RxJava Some great demos A deep dive into backpressure and flow control An even better demo

Where did Reactive-gRPC come from? 20 year old monolith to Microservices Bespoke REST APIs Apache Thrift gRPC + Mesh

What is gRPC? High-performance, open source, RPC framework Protobuf and HTTP/2 Big features Contract-first microservices Polyglot code generation Unary and bi-directional streaming https://grpc.io/ Built in the public RPC vs Rest

What is RxJava? API for asynchronous programming with observable streams Everything is a stream (Observable) Combine, filter, transform Subscribe (Observer) http://reactivex.io/ RxJava treats everything as a stream

What is RxJava? JavaFxObservable.eventsOf(scene, MouseEvent.CLICK) API for asynchronous programming with observable streams Everything is a stream (Observable) Combine, filter, transform Subscribe (Observer) JavaFxObservable.eventsOf(scene, MouseEvent.CLICK) .debounde(1, TimeUnit.SECONDS) .map(event -> new RobotCommand(event)) .subscribe(command -> robot.do(command));

1+1=3 https://imgur.com/gallery/c7NJRa2

Protobuf compiler plugin + new stubs Reactive gRPC gRPC RxJava Protobuf compiler plugin + new stubs

Questions so far?

Hello World demo - What will we see? Only gRPC Reactive gRPC Protobuf IDL Protoc code generator Single<T> and Flowable<T> Simple gRPC service Reactive-gRPC throw in

Demo summary Hello.proto defines operations and data structures Protoc compiler generates java stubs from proto during build Client and server build on generated stubs Reactive-gRPC generates RxJava stubs, extends protoc compiler RxJava makes writing streaming services easy

Questions so far?

Backpressure How downstream consumers signal to producers to slow down Classic episode of I love Lucy? https://cheezburger.com/7944963840

Three Backpressure Strategies Reactive gRPC

Producer? Consumer?

HTTP/2 backpressure and flow control Stream-based flow control – per stream and per connection Initial flow control window size 65,535 bytes Producer stops when window closes Consumer asks for more bytes by sending a WINDOW_UPDATE frame Flow Control Window Producer Flow Control Window Consumer BYTES WINDOW_UPDATE

gRPC backpressure and flow control Message-based flow control over HTTP/2 Producer OnReadyHandler produces and serializes proto messages until HTTP/2 flow control window is exhausted or there are no more messages to send WINDOW_UPDATE frames from consumer re-trigger OnReadyHandler Producer OnReady Handler onNext(message) Ready? HTTP/2 Flow Control Window BYTES Flow Control Window WINDOW_UPDATE

gRPC backpressure and flow control Message-based flow control over HTTP/2 Consumer Consumer calls request() gRPC deserializes messages and calls onNext() gRPC sends WINDOW_UPDATE frames to receive more bytes Producer OnReady Handler onNext(message) Consumer onNext(message) Ready? HTTP/2 Flow Control Window BYTES Flow Control Window request() WINDOW_UPDATE

RxJava backpressure and flow control Message-based flow control over Java method invocations Consumer calls request() Producer calls onNext() Intermediate operators propagate both calls Producer Observable Operator Map Operator Reduce Consumer Observer request() request() request() onNext() onNext() onNext()

Reactive-gRPC backpressure and flow control Message-based flow control over RxJava over gRPC over HTTP/2 RxJava Observable Observer onNext() request() Operator Operator onNext() request() gRPC OnReady Handler onNext() Consumer onNext() Ready? HTTP/2 Flow Control Window Flow Control Window request()

Reactive-gRPC backpressure and flow control Message-based flow control over RxJava over gRPC over HTTP/2 RxJava Observable Observer onNext() onNext() request() request() Operator Operator onNext() onNext() request() request() gRPC OnReady Handler onNext() Consumer onNext() Ready? HTTP/2 Flow Control Window Flow Control Window request() https://imgur.com/gallery/kW0tzFN

Questions so far?

Backpressure demo – What will we see? Slow consumer Fast producer

Demo summary Fast producer Slow consumer Producer outpaces consumer Producer slows down Backpressure is free (for you)

Questions so far?

Applied Reactive-gRPC demo – What will we see? IRC-like Chat Command line JavaFX Desktop Android Mobile

Applied Reactive-gRPC demo – What will we see? ChatMessage ➜ Empty Empty ➜ stream ChatMessage Server

Demo summary Reactive-gRPC make chat server trivial to write Three different clients, nearly identical code Command line JavaFX Android

To Conclude gRPC makes microservices easy .proto IDL Code generation RxJava is a different way of thinking Streams of events Function composition Reactive-gRPC bridges both technologies

Async by default Why Reactive-gRPC? First: Reactive programming built from the ground up for async processing

Unified programming model Why Reactive-gRPC? Unified programming model Second: Sync and Async work the same

Simplified programming model Why Reactive-gRPC? Simplified programming model Third: Less callback hell More code clarity

Consistent programming model Why Reactive-gRPC? Consistent programming model Finally: Serivces Desktop Mobile

Thank you! Questions? Resources https://grpc.io/ http://reactivex.io/ https://github.com/salesforce/reactive-grpc 👆Demo code Now open up to questions Questions?