Slide 1

Slide 1 text

as wire Protocol? RSocket

Slide 2

Slide 2 text

• Software Engineer focused on distributed systems development, adopting Reactive Manifesto and Reactive Programming techniques • Open source geek, active contributor of Project Reactor / RSocket • Author of the book "Reactive Programming in Spring 5” • Achieved 4-times better performance by tuning Reactor for RSocket Project About Me @OlehDokuka

Slide 3

Slide 3 text

Safe Harbor Everything you will hear is not related to any upcoming futures of storage protocols Everything that I’m going to say is nothing more than experiments or my OWN vision

Slide 4

Slide 4 text

Today’s Outline Wire Protocols Problematics RSocket

Slide 5

Slide 5 text

What is wire protocol? so

Slide 6

Slide 6 text

the mechanism for transmitting data from point a to point b

Slide 7

Slide 7 text

Existing Wire Protocol • MongoDb Wire Protocol • Postgresql Wire Protocol • Kafka Wire Protocol • … • …

Slide 8

Slide 8 text

WHY? Everyone did that

Slide 9

Slide 9 text

Reasons • Historically happened (in case of SQL Datas stores) • Kafka: HTTP libraries in many languages to be surprisingly shabby • Because I can (MongoDB)

Slide 10

Slide 10 text

MongoDB Wire Protocol

Slide 11

Slide 11 text

Mongo: Handshake Authentication Client Server TCP Error Success

Slide 12

Slide 12 text

Mongo: Messaging Message Client Server TCP Message

Slide 13

Slide 13 text

is a simple request-response style protocol MongoDB Wire Protocol

Slide 14

Slide 14 text

Mongo: Message Format 0 0 1 1 0 1 0 1 1 0 1 0 1 0 0 1 0 0 0 1 1 0 1 1 1 1 1 1 0 1 0 1 1 0 0 0 Logical Message Headers Message struct MsgHeader { int32 messageLength; int32 requestID; int32 responseTo; 
 int32 opCode; } struct MsgHeader { int32 messageLength; int32 requestID; int32 responseTo; 
 int32 opCode; } struct MsgHeader { int32 messageLength; int32 requestID; int32 responseTo; 
 int32 opCode; }

Slide 15

Slide 15 text

Mongo: Multiplexing Client Server TCP Message Message Message Message Message Message

Slide 16

Slide 16 text

Mongo: Message Types struct OP_QUERY { MsgHeader header; int32 flags; cstring fullCollectionName ; // "dbname.collectionname" int32 numberToSkip; // number of documents to skip int32 numberToReturn; // number of documents to return // in the first OP_REPLY batch document query; // query object. See below for details. [ document returnFieldsSelector; ] } struct OP_QUERY { MsgHeader header; int32 flags; cstring fullCollectionName ; // "dbname.collectionname" int32 numberToSkip; // number of documents to skip int32 numberToReturn; // number of documents to return // in the first OP_REPLY batch document query; // query object. See below for details. [ document returnFieldsSelector; ] } struct OP_QUERY { MsgHeader header; int32 flags; cstring fullCollectionName ; // "dbname.collectionname" int32 numberToSkip; // number of documents to skip int32 numberToReturn; // number of documents to return // in the first OP_REPLY batch document query; // query object. See below for details. [ document returnFieldsSelector; ] } struct OP_GET_MORE { MsgHeader header; int32 ZERO; cstring fullCollectionName; int32 numberToReturn; int64 cursorID; } struct OP_GET_MORE { MsgHeader header; int32 ZERO; cstring fullCollectionName; int32 numberToReturn; int64 cursorID; }

Slide 17

Slide 17 text

Mongo: Backpressure by Fetching Client Server TCP Cursor Query More More 2 1 3

Slide 18

Slide 18 text

Mongo 4.+: Message Types struct OP_MSG { MsgHeader header; uint32 flagBits; Sections[] sections; optional checksum; } struct OP_MSG { MsgHeader header; uint32 flagBits; Sections[] sections; optional checksum; }

Slide 19

Slide 19 text

Mongo: Streaming Client Server TCP Cursor Query 2 1 3

Slide 20

Slide 20 text

Mongo: Message Cancelling struct OP_KILL_CURSORS { MsgHeader header; int32 ZERO; int32 numberOfCursorIDs; int64* cursorIDs; }

Slide 21

Slide 21 text

is a simple request-response style protocol MongoDB Wire Protocol is a simple request-response style protocol is a simple request-response style protocol

Slide 22

Slide 22 text

Kafka Wire Protocol

Slide 23

Slide 23 text

Kafka: Message Types Request Header v0 => request_api_key request_api_version correlation_id request_api_key => INT16 request_api_version => INT16 correlation_id => INT32 Fetch Request (Version: 0) => replica_id max_wait_time min_bytes [topics] … … Fetch Response (Version: 0) => [responses] responses => topic [partition_responses] topic => STRING partition_responses => partition_header record_set partition_header => partition error_code high_watermark partition => INT32 error_code => INT16 high_watermark => INT64 record_set => RECORDS

Slide 24

Slide 24 text

Kafka: Throttling Mechanism Produce Request (Version: 0) => acks timeout [topic_data] acks => INT16 timeout => INT32 topic_data => topic [data] topic => STRING data => partition record_set partition => INT32 record_set => RECORDS Produce Response (Version: 1) => [responses] throttle_time_ms responses => topic [partition_responses] topic => STRING partition_responses => partition error_code base_offset partition => INT32 error_code => INT16 base_offset => INT64 throttle_time_ms => INT32 Produce Response (Version: 1) => [responses] throttle_time_ms responses => topic [partition_responses] topic => STRING partition_responses => partition error_code base_offset partition => INT32 error_code => INT16 base_offset => INT64 throttle_time_ms => INT32

Slide 25

Slide 25 text

Kafka: Some downsides

Slide 26

Slide 26 text

is a complex protocol Kafka Wire Protocol is a complex protocol

Slide 27

Slide 27 text

PostgreSql Wire Protocol

Slide 28

Slide 28 text

Postgresql: Summary • No multiplexing • Similar mechanisms for messaging as in Kafka and Mongo • It is own message binary format

Slide 29

Slide 29 text

is a simple request-response style protocol Postgresql Wire Protocol

Slide 30

Slide 30 text

Problems Summary • Wire Protocols are VERY Similar • Most of them are not ready to proper streaming and other todays requirements

Slide 31

Slide 31 text

In Vacuum Wire Protocol

Slide 32

Slide 32 text

Everyone Do: Handshake Storage Selection Authentication Client Server TCP

Slide 33

Slide 33 text

Everyone Do: Data Exchange Command Client Server Result TCP

Slide 34

Slide 34 text

Everyone Do: Client <- Server Backpressure Command Client Server Result TCP More Result More Result

Slide 35

Slide 35 text

Every Wants: Client -> Server Backpressure Client Server TCP Throttling

Slide 36

Slide 36 text

Some Do: Multiplexing Client Server TCP

Slide 37

Slide 37 text

Every Wish: Streaming Client Server TCP Query 2 1 3

Slide 38

Slide 38 text

Every Wish: Transport Variety Client Server TCP / UDP / QUIC / WebSocket

Slide 39

Slide 39 text

Problems Summary • Wire Protocols are VERY Similar • Most of them are not ready to proper streaming and other todays requirements • Most-likely all of them will reinvent the same again in the future

Slide 40

Slide 40 text

What if everyone use

Slide 41

Slide 41 text

What is • Open Source Layer 5/6 communication protocol • Reactive streams semantics • Application-level flow control • Supports both RPC and event-based messaging • Up to 10x faster than HTTP/1.1, using 90% less resources Built by leaders in microservices and cloud computing

Slide 42

Slide 42 text

42 Binary Messaging

Slide 43

Slide 43 text

43 Binary Messaging RSocket RSocket Connection

Slide 44

Slide 44 text

44 Binary Messaging RSocket RSocket Connection

Slide 45

Slide 45 text

45 Binary Messaging RSocket RSocket Connection

Slide 46

Slide 46 text

Binary Messaging 0 0 1 1 0 1 0 1 1 0 1 0 1 0 0 1 0 0 0 1 1 0 1 1 1 1 1 1 0 1 0 1 1 0 0 0 Logical Message Metadata Data • Data - allows any message format (including custom binary protocol) with no size limitations • Metadata - stands for headers / meta- info • Composite Metadata Extension - provides a way to provide Tracing / Monitoring / Routing / MimeType / Anything Cloud Applications needs today

Slide 47

Slide 47 text

47 Performance via Multiplexing

Slide 48

Slide 48 text

STREAM BLUE STREAM YELLOW STREAM RED 48 Project Reactor / RxJava / Any RS Performance via Multiplexing

Slide 49

Slide 49 text

49 WebSocket TCP QUIC Aeron Flexibility via Transport Agnostic • Message’s Framing / Logical Streams identity / all infrastructural information are provided on top if necessary • User may use any Reliable Transport

Slide 50

Slide 50 text

50 10 9 Resilience via Reactive Streams Spec

Slide 51

Slide 51 text

51 Resilience via Leasing STREAM BLUE STREAM YELLOW STREAM RED STREAM BLUE STREAM YELLOW STREAM RED Requester Requester STREAM BLUE STREAM YELLOW STREAM RED Responder Requester

Slide 52

Slide 52 text

52 Resilience via Leasing Responder Requester Requests Count : 10 
 Duration : next 10 secs STREAM BLUE STREAM YELLOW STREAM RED Requests Count : 9 
 Duration : next 10 secs Requests Count : 8 
 Duration : next 10 secs Requests Count : 7 
 Duration : next 10 secs Requests Count : 7 
 Duration : next 9 secs Requests Count : 7 
 Duration : next 8 secs Requests Count : 7 
 Duration : next 7 secs Requests Count : 7 
 Duration : next 0 secs Requests Count : 10 
 Duration : next 10 secs

Slide 53

Slide 53 text

Resilience Advanced • Server sales capacity to its clients • Natural Rate Limiting • Built-in Circuit Breaker

Slide 54

Slide 54 text

• Request - Response • Request - Stream • Request - Channel 
 (aka Stream - Stream)
 
 • Fire - and - Forget 
 (flush out and that is it) Wide Communication Patterns

Slide 55

Slide 55 text

Wide Communication Patterns • Clients is required to establish connection • Real Peer-To-Peer • Both sides are equal and can or cannot implements mentioned communication >>> CLIENT REQUEST STREAM >>> <<< SERVER REQUEST STREAM <<< SERVER CLIENT PEER PEER

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

Summary • Using RSocket you do not have to reinvent wheel • Interoperability between RSocket based protocols

Slide 58

Slide 58 text

So, if everyone use

Slide 59

Slide 59 text

Client Server RSocket Message Message Message Message Message 2 1 3 reqiest(5) 2 1 3

Slide 60

Slide 60 text

Wait I do the same in my web 
 application every day

Slide 61

Slide 61 text

We all are Building wire protocols

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

You can use RSocket too And yes!

Slide 64

Slide 64 text

64 User Experience • RSocket-RPC (via Protobuf Generators) for all supported languages • RSocket-IPC (plain inter-process communication) • RSocket-GraphQL • Spring-Boot-Starter-RSocket (Spring-Messaging integration)

Slide 65

Slide 65 text

Service A ??? RSocket Setup Frame Metadata Push

Slide 66

Slide 66 text

Introducing Broker Specification + Broker Spec

Slide 67

Slide 67 text

Computer A Computer B Application Transport Internet Internet Internet Internet Network Access Network Access Network Access Network Access Router #1 Router #2 Application Transport Components of TCP/IP Communication

Slide 68

Slide 68 text

API Abstraction Client Library API Abstraction Client Library Service A Service B Broker #1 Broker #2 Components of RSocket Communication Netifi Broker Netifi Broker

Slide 69

Slide 69 text

But this future we overview in another speech

Slide 70

Slide 70 text

Summary • RSocket is a powerful binary Protocol • In can Simplify communication between A and B • All the date stores just expose its own API • ALL the database vendors can benefit from using RSocket

Slide 71

Slide 71 text

What to do next? • http://rsocket.io - official web-page • https://bit.ly/2Fku9VC - video channel • https://community.reactive.foundation/ - community forum @OlehDokuka