can we do better than http json
play

Can we do better than HTTP/JSON? Open Source Leadership Summit, Feb - PowerPoint PPT Presentation

Can we do better than HTTP/JSON? Open Source Leadership Summit, Feb 2017 Varun Talwar @varungyan Confidential + Proprietary Why is JSON so popular? 1. Simple 2. Self describing 3. Easy to debug 4. Easy to process in languages 5.


  1. Can we do better than HTTP/JSON? Open Source Leadership Summit, Feb 2017 Varun Talwar @varungyan Confidential + Proprietary

  2. Why is JSON so popular? 1. Simple 2. Self describing 3. Easy to debug 4. Easy to process in languages 5. Browser tooling 6. Less verbose than XML Lacks 1. Extend as needed 2. Performance 3. Storage size Confidential + Proprietary

  3. The Fallacies of Distributed Computing The network is reliable Topology doesn't change Latency is zero There is one administrator Bandwidth is infinite Transport cost is zero The network is secure The network is homogeneous Confidential + Proprietary https://blogs.oracle.com/jag/resource/Fallacies.html

  4. Yes, we can An open, performant, resilient and universal way to connect and operate distributed systems and provide a framework to make much smarter clients and servers Confidential + Proprietary

  5. Making Google frameworks available in Open Borg Kubernetes Stubby Confidential + Proprietary

  6. Microservices at Google ~ O(10 10 ) RPCs per second. Images by Connie Confidential + Proprietary Zhou

  7. Open source on Github for C, C++, Java, Node.js, Python, Ruby, Go, C#, PHP, Objective-C Confidential + Proprietary

  8. What is gRPC? HTTP/2 and Protocol Buffer based RPC framework ● Evolution of Stubby; being adopted at Google as next gen framework ● Open, Secure, Performant, Multiplatform ● Multiplatform Idiomatic APIs in popular languages (C++, Go, Java, C#, Node.js, Ruby, ● PHP, Python) Supports mobile devices (Android Java, iOS Obj-C) ● Linux, Windows, Mac OS X ● Confidential + Proprietary

  9. Where is the project today? ● 1.1 with stable APIs ● Joining CNCF soon :-) ● Well documented with an active community ● Reliable with continuous running tests ○ Deployable in your environment Measured with an open performance ● dashboard ○ Deployable in your environment Well adopted inside and outside ● Google Confidential + Proprietary

  10. Some early adopters Microservices: in data centres Client Server communication/Internal APIs Streaming telemetry from network devices Mobile Apps Confidential + Proprietary

  11. PROTOBUF & HTTP/2 Confidential + Proprietary

  12. Protocol Buffers are ● Efficient ○ Binary protocol; much faster serialization 3-10x smaller and 20-100x faster than XML [1] ○ 1.5-3x smaller and 1.5-3x faster than JSON [2] ○ ● With Simple IDL ● Strong typing -> avoids errors earlier & can enforce strict contracts ● Allows to extend/grow -> API evolution ● Used for logging, storage, and talking to other servers Confidential + Proprietary

  13. How does it look? $ cat student.proto Run-time Compiler // Definition of a Student object 0101101000111 syntax = "proto2"; 0101101000111 option cc_api_version = 2; .proto option java_api_version = 2; Binary / text .cc, .py, .java, .js, .go package social; message Student { required int32 unique_id = 1; required string first_name = 2; ... optional double gpa = 8; optional string nickname = 9 [default = "bob"]; repeated int32 friend_id = 10; } Confidential + Proprietary

  14. How we roll at Google Confidential + Proprietary

  15. HTTP/1.x vs HTTP/2 http://http2.golang.org/gophertiles http://www.http2demo.io/ Confidential + Proprietary

  16. History of HTTP 1991 1993 1995 1997 1999 2001 2003 2005 2007 2009 2011 2013 2015 2017 HTTP/0.9 HTTP/1.0 HTTP/1.1 ? Confidential + Proprietary

  17. History of HTTP 1991 1993 1995 1997 1999 2001 2003 2005 2007 2009 2011 2013 2015 2017 HTTP/0.9 HTTP/1.0 HTTP/1.1 SPDY HTTP/2.0 Confidential + Proprietary

  18. HTTP/2 HTTP/2 is extending, not replacing, the previous HTTP standards. The application semantics of HTTP are the same:: • HTTP header fields • HTTP Methods • Request-response • Status codes • URIs HTTP/2 modifies how the data is formatted (framed) and transported between the client and server. Confidential + Proprietary

  19. Binary Framing Stream 1 HEADERS :method: GET Request :path: /kyiv HTTP/2 breaks down the :version: HTTP/2 :scheme: https HTTP protocol communication into an HEADERS DATA :status: 200 exchange of Response :version: HTTP/2 <payload> TCP :server: nginx/1.10.1 binary-encoded frames , ... which are then mapped to messages that belong to a Stream 2 stream , and all of which are multiplexed within a single TCP connection . Stream N Confidential + Proprietary

  20. HTTP/2 in One Slide HTTP/1.x • Single TCP connection. POST: /upload HTTP/1.1 • No Head-of-line blocking. Host: www.javaday.org.ua Application (HTTP/2) Content-Type: application/json • Binary framing layer. Binary Framing Content-Length: 27 • Request –> Stream. Session (TLS) [optional] {“msg”: “Welcome to 2017!”} • Header Compression. Transport(TCP) Network (IP) HTTP/2 HEADERS Frame DATA Frame Confidential + Proprietary

  21. KEY DESIGN PRINCIPLES Confidential + Proprietary

  22. gRPC Principles & Requirements Coverage & Simplicity The stack should be available on every popular development platform and easy for someone to build for their platform of choice. It should be viable on CPU & memory limited devices. http://www.grpc.io/blog/principles Google Cloud Platform

  23. gRPC Speaks Your Language Service definitions and client libraries Platforms supported ● Java ● MacOS ● Go ● Linux ● C/C++ ● Windows ● C# ● Android ● Node.js ● iOS ● PHP ● Ruby ● Python ● Objective-C Confidential + Proprietary

  24. Interoperability gRPC Service gRPC Stub gRPC GoLang Service Service gRPC Stub Java Service gRPC gRPC Stub Service gRPC gRPC Stub Service gRPC Python Stub C++ Service Service Confidential + Proprietary

  25. Easy to get started Confidential + Proprietary

  26. gRPC Principles & Requirements General Purpose and Performant The stack should be applicable to a broad class of use-cases while sacrificing little when compared to a use-case specific stack http://www.grpc.io/blog/principles Google Cloud Platform

  27. gRPC vs JSON/HTTP for Google Cloud Pub/Sub 3x increase in throughput 11x difference per CPU Publishing 50KB messages at More impressive than the maximum throughput from a almost 3x increase in single n1-highcpu-16 GPE VM throughput, is that it took only instance, using 9 gRPC channels. 1/4 of the CPU resources. Source Blog of Cloud Pubsub Confidential + Proprietary

  28. Some external perf comparisons Confidential + Proprietary

  29. gRPC Principles & Requirements Pluggable Large distributed systems need security, health-checking, load-balancing and failover, monitoring, tracing, logging, and so on. Implementations should provide extensions points to allow for plugging in these features and, where useful, default implementations. http://www.grpc.io/blog/principles Google Cloud Platform

  30. Interceptors Client Server interceptors interceptors Request Client Server Response Confidential + Proprietary

  31. gRPC Principles & Requirements Payload Agnostic Different services need to use different message types and encodings such as protocol buffers, json, xml, thrift; the protocol and implementations must allow for this. Similarly the need for payload compression varies by use-case and payload type: the protocol should allow for pluggable compression mechanisms. http://www.grpc.io/blog/principles Google Cloud Platform

  32. gRPC Principles & Requirements Flow Control Computing power and network capacity are often unbalanced between client and server. Flow control allows for better buffer management as well as providing protection from DOS by an overlay active peer. http://www.grpc.io/blog/principles Google Cloud Platform

  33. gRPC Principles & Requirements Network Control Operations can be expensive and long lived. Cancellation allows servers to reclaim resources when clients are well-behaved. Deadlines let servers know what is the expected time of response and behave accordingly. http://www.grpc.io/blog/principles Google Cloud Platform

  34. gRPC Principles & Requirements Streaming Storage systems rely on streaming and flow control to express large data sets. Other services like voice to text or stock tickers rely on streaming to represent temporally related message sequences. http://www.grpc.io/blog/principles Google Cloud Platform

  35. gRPC Service Definitions Unary Server streaming Client streaming BiDi streaming Unary RPCs where the The client sends a The client send a Both sides send a client sends a single request to the server sequence of messages sequence of messages request to the server and gets a stream to to the server using a using a read-write and gets a single read a sequence of provided stream. stream. The two response back, just like messages back. streams operate Once the client has a normal function call. independently. The The client reads from finished writing the order of messages in the returned stream messages, it waits for each stream is until there are no more the server to read them preserved. messages. and return its response. Confidential + Proprietary

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend