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

Better performances on the server side with HTTP/2

Better performances on the server side with HTTP/2

The HTTP/2 protocol is the latest evolution of the HTTP protocol. It addresses the problems caused by the HTTP/TCP impedance mismatch. Client side web applications have been working around these problems for years. They rely on techniques like resource minification/concatenation, CSS spriting, in order to reduce page load time and improve the user experience. But HTTP/2 is a game changer on the server side too, enabling increased concurrency.

The presentation starts with a very quick recap of the HTTP/2 protocol. Then we will examine the impact of HTTP/2 on the server side. In order to do this, we will use the results of a frontend server to backend server benchmark, comparing a blocking approach with a reactive one based on Eclipse Vert.x. We will demonstrate how particularly well adapted the Vert.x concurrency model is to serve HTTP/2 applications. Eventually, we will introduce Vert.x and its ecosystem of reactive modules for the JVM.

Thomas Segismont

November 24, 2017
Tweet

More Decks by Thomas Segismont

Other Decks in Technology

Transcript

  1. Who am I? • tsegismont @ GitHub / Twitter /

    Gmail / Freenode • Vert.x core team since August 2016 • At Red Hat since November 2012 (RHQ and Hawkular)
  2. HTTP1/TCP impedance mismatch • 3-way handshake • Congestion control •

    Slow start • Congestion window => Optimized for long-lived connections Websites: a lot of small-medium sized resources
  3. HTTP/1 Optimization techniques • Persistent connections • Multiple connections •

    Domain sharding • CDN • Browser caching • Compression / minification and concatenation
  4. HTTP/2 • A better TCP transport for actual HTTP request

    and responses • Same HTTP semantics • RFC7540 : Hypertext Protocol version 2 • RFC7541 : Header Compression for HTTP/2
  5. HTTP/2 • H2 – TLS/SSL – Mandatory for browsers –

    ALPN extension to negotiate HTTP/1 or HTTP/2 • H2C – Clear – Via HTTP/1 upgrade or directly
  6. Framed protocol • Defines a set of frames encoded in

    binary on a single connection – Settings – Headers – Data – Flow control – Push, Priority, Ping – Reset
  7. Settings frames • First frame exchanged by client and server

    – Max concurrency – Max frame size – … etc
  8. GET /index.html HTTP/1.1\r\n Host: www.free.fr\r\n User-Agent: Mozilla/5.0\r\n Accept-Encoding: text/html\r\n Accept-Language:

    en-US\r\n \r\n 00003501250000000300 0000000f824488355217 caf3a69a3f874189f1e3 c2f2d852af2d9f7a88d0 7f66a281b0dae0508749 7ca589d34d1f51842d4b 70dd Request headers 2x smaller length type flags stream_id
  9. Subsequent request headers 4x smaller GET /products.html HTTP/1.1\r\n Host: www.free.fr\r\n

    User-Agent: Mozilla/5.0\r\n Accept-Encoding: text/html\r\n Accept-Language: en-US\r\n \r\n 00001701250000000500 0000000f82448aaec3c9 691285e74d347f87c2c1 c0bf
  10. Response headers + data HTTP/1.1 200 OK\r\n Content-Type: text/html\r\n Cache-Control:

    max-age=86400\r\n Content-Length: 37\r\n \r\n <html><body>Hello World </body></html> 00001f01240000000300 0000000f885f87497ca5 89d34d1f588aa47e561c c581e71a003f5c023337 0000250001000000033c 68746d6c3e3c626f6479 3e48656c6c6f20576f72 6c643c2f626f64793e3c 2f68746d6c3e length type flags stream_id
  11. Constraints • 1ms ping • 1G < bandwidth < 10G

    • 1ms < service time < 200ms • 200b < body size < 2kb
  12. 0 100 200 300 400 500 600 700 800 0

    200 400 600 800 HTTP/1 - 8 connections planned (req / sec) performed (req/sec)
  13. 0 100 200 300 400 500 600 700 800 900

    1000 1100 1200 0 300 600 900 1200 HTTP/1 - 8 connections HTTP/2 - 1 connection / max_concurrent_streams 20 planned (req / sec) performed (req / sec)
  14. 0 1000 2000 3000 4000 5000 0 1250 2500 3750

    5000 HTTP/2 thread pool planned (req / sec) performed (req / sec)
  15. HTTP/2 with Vert.x • Client / Server • h2 /

    h2c • HTTP Request / response API • HTTP/2 specific features for extensions
  16. 0 1000 2000 3000 4000 5000 0 1250 2500 3750

    5000 HTTP/2 thread pool HTTP/2 non blocking planned (req / sec) performed (req / sec)
  17. Conclusion • Unleash concurrency with HTTP/2 • Keep the good

    old HTTP/1 semantics • Non blocking is a key factor for high concurrency • Vert.x is a great fit for HTTP/2 – Reactive ecosystem – Easy to scale