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

[PHP Stockholm] HTTP/2 Lightning Talk

[PHP Stockholm] HTTP/2 Lightning Talk

A 5 minute or less introduction to HTTP/2 and why you should be using it.

Davey Shafik

May 11, 2016
Tweet

More Decks by Davey Shafik

Other Decks in Programming

Transcript

  1. D AV E Y S H A F I K

    • Developer • Author • Open Source Contributor • Release Manager for PHP 7.1 • @dshafik
  2. h tt p : / /d e v e l

    o p e r. a ka m a i .co m
  3. B R O W S E R S U P

    P O RT • Chrome + Chrome Mobile • Firefox • IE 11 on Windows 10 • MS Edge • Safari (El Capitan/iOS 9) • Opera
  4. A L L B R O W S E RS

    R E Q U I R E T LS FO R H T T P/ 2 CC-BY: Jason Baker
  5. W H AT I S H T T P/ 2

    ? CC-BY: Marco Bellucci
  6. B I N A R Y I N ST E

    A D O F T E XT CC-BY: brett jordan
  7. F U L LY M U LT I P L

    E X E D CC-BY: vadikunc I N S T E A D O F O R D E R E D A N D B L O C K I N G
  8. C A N US E O N E CO N

    N E CT I O N 
 FO R PA R A L L E L R E Q U E STS CC-BY: Alosh Bennett
  9. US E S H E A D E R CO

    M P R E SS I O N CC-BY-SA: Magnus Hagdorn R E D U C E S O V E R H E A D
  10. S E R V E R P U S H

    I S S U P E R CO O L ( N O R E A L LY ) CC-BY-SA: Takeshi
  11. S E R V E R P U S H

    • Allows the server to proactively push assets like stylesheets and images to the client without them needing to parse the HTML page and make subsequent requests • Done by pushing the assets into the client cache, avoiding the roundtrip necessary to pull them up once the client makes the request
  12. W H AT D O E S H T T

    P/ 2 M E A N F O R M Y A P P L I C AT I O N ?
  13. T R A N S PA R E N T

    CC-BY-SA: Patty H A N D L E D B Y N G I N X / A PA C H E
  14. H T T P/ 1 . X S U C

    K S CC-BY: Flóra Soós
  15. H T T P/ 1 . X S U C

    K S • Minify + Concat JavaScript and CSS • Inlining small JavaScript and CSS • Using image sprites • Using data: URIs • Domain sharding
  16. T H E S E T H I N G

    S A R E A L L " C L E V E R " H AC K S CC-BY: Matt Biddulph
  17. $url = 'https://http2.akamai.com/demo/tile-%d.png'; for ($i = 0; $i <= $numRequests;

    $i++) { $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, $i); curl_exec($ch); curl_close($ch); }
  18. $url = 'https://http2.akamai.com/demo/tile-%d.png'; for ($i = 0; $i <= $numRequests;

    $i++) { $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, $i); curl_exec($ch); curl_close($ch); }
  19. $url = 'https://http2.akamai.com/demo/tile-%d.png'; for ($i = 0; $i <= $numRequests;

    $i++) { $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, $i); curl_exec($ch); curl_close($ch); }
  20. $url = 'https://http2.akamai.com/demo/tile-%d.png'; for ($i = 0; $i <= $numRequests;

    $i++) { $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, $i); curl_exec($ch); curl_close($ch); }
  21. $url = 'https://http2.akamai.com/demo/tile-%d.png'; for ($i = 0; $i <= $numRequests;

    $i++) { $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, $i); curl_exec($ch); curl_close($ch); }
  22. 4 7 . 6 7 
 s e co n

    d s CC-BY: Hernán Piñera
  23. H T T P/ 2 : SY N C H

    R O N O US $url = 'https://http2.akamai.com/demo/tile-%d.png'; for ($i = 0; $i <= $numRequests; $i++) { $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, $i); curl_setopt($ch, CURLOPT_HTTP_VERSION, HTTP_VERSION_2_0); curl_exec($ch); curl_close($ch); }
  24. H T T P/ 2 : SY N C H

    R O N O US $url = 'https://http2.akamai.com/demo/tile-%d.png'; for ($i = 0; $i <= $numRequests; $i++) { $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, $i); curl_setopt($ch, CURLOPT_HTTP_VERSION, HTTP_VERSION_2_0); curl_exec($ch); curl_close($ch); }
  25. 6 2 . 1 9 
 s e co n

    d s CC-BY-NC: Scott Beckner
  26. $mh = curl_multi_init();
 $url = 'https://http2.akamai.com/demo/tile-%d.png';
 for ($i = 0;

    $i <= $numRequests; $i++) { $handles[] = $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, ‘%d'); curl_multi_add_handle($mh, $ch); } H T T P/ 1 . 1 : CO N CU R R E N T
  27. $mh = curl_multi_init();
 $url = 'https://http2.akamai.com/demo/tile-%d.png';
 for ($i = 0;

    $i <= $numRequests; $i++) { $handles[] = $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, ‘%d'); curl_multi_add_handle($mh, $ch); } H T T P/ 1 . 1 : CO N CU R R E N T
  28. $mh = curl_multi_init();
 $url = 'https://http2.akamai.com/demo/tile-%d.png';
 for ($i = 0;

    $i <= $numRequests; $i++) { $handles[] = $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, ‘%d'); curl_multi_add_handle($mh, $ch); } H T T P/ 1 . 1 : CO N CU R R E N T
  29. $mh = curl_multi_init();
 $url = 'https://http2.akamai.com/demo/tile-%d.png';
 for ($i = 0;

    $i <= $numRequests; $i++) { $handles[] = $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, ‘%d'); curl_multi_add_handle($mh, $ch); } H T T P/ 1 . 1 : CO N CU R R E N T
  30. H T T P/ 1 . 1 : CO N

    CU R R E N T ( CO N T. ) do { $exec = curl_multi_exec($mh, $running); } while ($exec == CURLM_CALL_MULTI_PERFORM); while ($running && $exec == CURLM_OK) { $ready = curl_multi_select($mh); if ($ready != -1) { do { $exec = curl_multi_exec($mh, $running);
 } while ($exec == CURLM_CALL_MULTI_PERFORM); } }
  31. $url = 'https://http2.akamai.com/demo/tile-%d.png';
 for ($i = 0; $i <= $numRequests;

    $i++) { $handles[] = $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, ‘%d'); curl_multi_add_handle($mh, $ch); } H T T P/ 2 : M U LT I P L E X E D $mh = curl_multi_init();
  32. $url = 'https://http2.akamai.com/demo/tile-%d.png';
 for ($i = 0; $i <= $numRequests;

    $i++) { $handles[] = $ch = curl_init(); $conf[CURLOPT_URL] = sprintf($url, ‘%d'); curl_multi_add_handle($mh, $ch); } H T T P/ 2 : M U LT I P L E X E D curl_multi_setopt($mh,
 CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX ); $mh = curl_multi_init();
  33. H T T P/ 2 : M U LT I

    P L E X E D ( CO N T. ) do { $exec = curl_multi_exec($mh, $running); } while ($exec == CURLM_CALL_MULTI_PERFORM); while ($running && $exec == CURLM_OK) { $ready = curl_multi_select($mh); if ($ready != -1) { do { $exec = curl_multi_exec($mh, $running);
 } while ($exec == CURLM_CALL_MULTI_PERFORM); } }
  34. 2 . 1 4 
 s e co n d

    s CC-BY: motoracereports
  35. H U G E P E R FO R M

    A N C E W I N S
  36. H T T P / 2 I S A W

    E S O M E ! CC-BY-SA: Steven Gerner
  37. F E E D B A C K & Q

    U E S T I O N S Twitter: Email: Slides: @dshafik [email protected] http://daveyshafik.com/slides