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

Better performances with HTTP/2

Julien Viet
June 17, 2016
290

Better performances with HTTP/2

Julien Viet

June 17, 2016
Tweet

Transcript

  1. Latency vs Bandwidth impact on Page Load Time Page Load

    Time as bandwidth increases 1000 1550 2100 2650 3200 1Mbps 2Mbps 2Mbps 4Mbps 5Mbps 6Mbps 7Mbps 8Mbps 9Mbps 10Mbps Page Load Time as latency decrease 1000 1750 2500 3250 4000 200 ms 180 ms 160 ms 140 ms 120 ms 100 ms 80 ms 60 ms 40 ms 20 ms
  2. HTTP/2 origins HTTP is 20 years old HTTP bis started

    but Google prototyped SPDY Which became HTTP/2
  3. COMPR ESS headers headers headers headers headers headers headers headers

    headers headers headers headers headers headers headers headers headers headers
  4. Benchmark HTTP/1 vs HTTP/2 performances Client / frontend / backend

    servers Client -> Frontend : HTTP/1 or HTTP/2 Front -> Backend : HTTP/1 Backend has 20ms service time
  5. Benchmark Pace requests at a given rate Log ratio of

    requests performed/planned Log response time percentiles https://github.com/vietj/http2-bench
  6. Vert.x Polyglot Event driven Vert.x Core • core library for

    building a stack • embeddable (core 1MB) Vert.x stack • a coherent stack built on top of Vert.x Core
  7. Vert.x Core TCP / HTTP / UDP / DNS File

    Event Bus Deployment Cluster / HA
  8. –Johnny Appleseed “The reactor design pattern is an event handling

    pattern for handling service requests delivered concurrently to a service handler by one or more inputs. The service handler then demultiplexes the incoming requests and dispatches them synchronously to the associated request handlers.” - Wikipedia
  9. Non blocking server public static void main(String [] args) {

    Vertx vertx = Vertx.vertx(); HttpServer server = vertx.createHttpServer(); server.requestHandler(req -> { req.response() .putHeader(“Content-Type”, “text/plain”) .end(“Hello World”); }); server.listen(8080); }
  10. Non blocking client public static void main(String [] args) {

    HttpClient client = vertx.createHttpClient(); client.getNow(“http: //backend”, resp -> { int status = resp.status(); resp.bodyHandler(body -> { System.out.println(body.length()); }); }); }
  11. NB server+client server.requestHandler(req -> { HttpServerResponse resp = req.response(); client.getNow(“http:

    //backend”, clientResp -> { int code = clientResp.status() resp.setStatus(code); clientResp.bodyHandler(body -> { resp.end(body); }); }); });