Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
Java EE Next - BeJUG JavaOne Afterglow 2016
Next
Download to read offline and view in fullscreen.

2

Share

Download to read offline

HTTP/2 comes to Java (Dec. 2015 version)

Download to read offline

Latest iteration of my HTTP/2 deck, presented at JCConf (Taipei-Taiwan) end of 2015

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

HTTP/2 comes to Java (Dec. 2015 version)

  1. 1. HTTP/2&comes&to&Java!& JCConf&Taiwan&2015 David&Delabassee& @delabassee& Oracle Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved.* 1
  2. 2. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee
  3. 3. Safe*Harbor*Statement The* following* is* intended* to* outline* our* general* product* direction.* It* is* intended* for* information* purposes* only,* and* may* not* be* incorporated* into* any* contract.* It* is* not* a* commitment*to*deliver*any*material,*code,*or*functionality,*and*should*not*be*relied*upon* in*making*purchasing*decisions.*The*development,*release,*and*timing*of*any*features*or* functionality*described*for*Oracle’s*products*remains*at*the*sole*discretion*of*Oracle. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 3
  4. 4. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Agenda Why*HTTP/2?* HTTP/2* HTTP/2*and*Java*EE* HTTP/2*and*Java*SE* Summary
  5. 5. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Agenda Why*HTTP/2?* HTTP/2* HTTP/2*and*Java*SE* HTTP/2*and*Java*EE* Summary
  6. 6. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 6 @delabassee Data*Never*Sleeps*2.0 https://www.domo.com/learn/dataRneverRsleepsR2
  7. 7. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 7 @delabassee HTTP*1.x 1991* 1996* 1999* 2009* 2015* HTTP/0.9* HTTP/1.0* HTTP/1.1* SPDY* HTTP/2.0*
  8. 8. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 8 @delabassee
  9. 9. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 9 @delabassee
  10. 10. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 10 @delabassee
  11. 11. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 11 @delabassee
  12. 12. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 13 @delabassee Today index.html style1.css style2.css .& .& .& script1.js script9.js pic1.jpg pic8.jpg .& .& .& photo1.png photo2.png .& .& .&
  13. 13. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 14 @delabassee google.fr*(1st)* • 3*HTTP*Requests* • 21.355*bytes* - 1*HTML* - 1*image* - 1*.js Top*.FR*examples lefigaro.fr*(15th)* • 140*HTTP*Requests* • 2.736.562*bytes* - 1*HTML* - 130*images* - 6*.js* - 2*.css*
  14. 14. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 15 @delabassee • If*a*page*takes*longer*than*4*sec*to*load,*1/4*people*abandons*that*page*(1)* • 57%*of*consumers*will*abandon*a*page*that*takes*longer*than*3*sec*to*load*(2)* • Page*load*slowdown*of*1*sec*could*cost*Amazon*$1.6*billion*in*sales*a*year*(1)* • Slowing*search*results*by*0.4*sec,*Google*could*lose*8*million*searches*per*day*(1) Latency*Vs.*Conversion*Rate Time&is&Money! (1)*http://www.fastcompany.com/1825005/howRoneRsecondRcouldRcostRamazonR16RbillionRsales* (2)*RadView*Spring*2015*State*of*the*Union:*Ecommerce*Page*Speed*&*Web*Performance
  15. 15. @delabasseeCopyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. HTTP*1.1 HeadCofCLine&blocking 16 Client Server index.html index.html style1.css* script.js* ... style1.css* script.js* ...
  16. 16. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 17 @delabassee HTTP*1.1
  17. 17. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 18 @delabassee File*Concatenation*and*Image*Sprites • Modern*web*page*consists*of*+90*resources*fetched*from*15*distinct* hosts*(http://httparchive.org)* • TCP*Efficiency*Improves*with*Larger*Files* • Shoving*more*than*one*logical*file*into*one*physical*file
  18. 18. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 19 @delabassee File*Concatenation*and*Image*Sprites
  19. 19. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 20 @delabassee HTTP*1.1 Workaround&C&Domain&Sharding
  20. 20. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 21 @delabassee Asset*inlining …* <img"src="data:image/gif;base64,R0lGODlhEAAOexs3eeALMAAOazToeHh0tLS/ 7LZv0jvb29tf3Ubge8WSLrhf3kdbW1mxsjkhfkjfhGHhcjGDSHJUYgJvhgtyrHgfGfHy t56HGfGH56ge8WSLf6GGHhfkjfhhfkjfhpBREzxvt6QAA4lsjkhfkjfhdxwqBnuIoYty GhBKoOjJj6GGHvvhdsbxus38GV3pBREzxvt6QAA4lsjkhfkjfhdxwqBnuIoYtyGhBKoO jJj6GGHvvhdsbxus38GV3vvhdsbxusbasbPmfyH5BAAAjAAAALAAfhGHhcjAAAAQAA4l sjkhfkjfhGHhcjGDSHJUYgJvhgtyrHgfhfkjfhpBREzxvt6QAA4lsjkhfkjfhdxwqBnu IoYtyGhBKoOjJj6GGHvvhdsbxus38GV3GfHyt56HGfGH56ge8WsjkhfkjfhGHhcjGDSH JUYgJvhgtyrHgfGfHyt56HGfGH56gebxus38G8WSLf6GGHvvhdsbxusbaSLf6GGHvvhd sbxusbaOiQA4lsjkhfkjf4lsjkhfkjf4lsjbxus38GkhfkjfhfkjfhpBREzxvt6QAA4l sjkhfkjfhdxwqBnuIoYtyGhBKoOjJj6GGHvvhdsbxus38GV3DcPjjBceXsplojj…”"/>" …
  21. 21. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 22 @delabassee • HTTP*uses*TCP*poorly* - HTTP:*short*and*bursty*flows*Vs.*TCP:*optimized*for*longRlived*flows* • Solutions* - Sprites* - Domain*sharding* - Assets*Inlining* - File*concatenations* - … HTTP/1.1*circa*1999 Problems&Vs&Solutions 1991& 1996& 1999& 2009& 2015& HTTP/0.9& HTTP/1.0& HTTP/1.1& SPDY& HTTP/2.0&
  22. 22. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Agenda Why*HTTP/2?* HTTP/2* HTTP/2*and*Java*SE* HTTP/2*and*Java*EE* Summary
  23. 23. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee HTTP/2 • Jan*2015* • Feb*2015* • May*2015 24 Enabled*by*default*in*FireFox*(35)*and*Chrome*(40)* IESG*approved*HTTP/2* HTTP/2*in*10%*of*all*HTTP*responses*(FireFox)* HTTP/2*used*in*18%*of*global*traffic*(Google)* RFC*7540**“Hypertext*Transfer*Protocol*Version*2”* RFC*7541**“HPACK:*Header*Compression*for*HTTP/2”**
  24. 24. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 25 @delabassee Browsers*support …&as&of&November&2015 http://caniuse.com/http2*
  25. 25. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved.* @delabassee26 HTTP/2*Features • Binary*Framing*over*single*TCP*connection* • Request/Response*multiplexing* • Stream*Prioritization* • Server*Push* • Upgrade*from*HTTP*1.1* • Header*Compression* • Preserve*HTTP*semantic
  26. 26. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved.* @delabassee26 HTTP/2*Features • Binary*Framing*over*single*TCP*connection* • Request/Response*multiplexing* • Stream*Prioritization* • Server*Push* • Upgrade*from*HTTP*1.1* • Header*Compression* • Preserve*HTTP*semantic
  27. 27. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 27 @delabassee HTTP/2 • Fully*biRdirectional* – Connection
 A*TCP*socket* – Message*
 A*logical*HTTP*message,*such*as*a*request*or*a*response** – Stream
 A*biRdirectional*“channel”*within*a*connection,*carry*one*or*more*message* – Frame
 The*smallest*unit*of*communication*in*HTTP/2 Lets&you&do&more&things&with&a&single&TCP&connection
  28. 28. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 28 @delabassee HTTP/2 Connections,&Streams,&Messages,&Frames
  29. 29. @delabasseeCopyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. Binary*Frames • Frames* - HEADERS,*DATA,*PRIORITY,*RST_STREAM,*SETTINGS,*PUSH_PROMISE,*PING,* GOAWAY,*WINDOW_UPDATE,*CONTINUATION* - Prioritisation,*Flow*Control,*Server*Push,*…** • Single*TCP*Connection 29 POST*/upload*HTTP/1.1* Host:*www.test.com* ContentRType:*application/json* ContentRLength:*15* {“name”:“duke”} HTTP&1.1 HTTP/2 HEADERS&frame DATA&frame
  30. 30. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 30 @delabassee HTTP/2*Binary*Framing GET*/index.html*HTTP/1.1
 Host:*example.com
 Accept:*text/html Example&1 HEADERS
 ****+*END_STREAM
 ****+*END_HEADERS
 ********:method:*GET
 ********:scheme:*http
 ********:path:*/index.html
 ********:authority:*example.org
 ********accept:*text/html
  31. 31. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 31 @delabassee HTTP/2*Binary*Framing HTTP/1.1*200*OK
 ContentRLength:*84
 ContentRType:*text/html
 
 <!doctype*html>* <head>* <meta*charset=utfR8>* </head>* <body>Hello*World</body>* </html> Example&2 HEADERS
 ****R*END_STREAM
 ****+*END_HEADERS
 ********:status:*200
 ********contentRlength:*84
 ********contentRtype:*text/html
 
 DATA
 ****+*END_STREAM
 <!doctype*html>…
  32. 32. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 32 @delabassee Multiplexing
  33. 33. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 33 @delabassee Stream*Prioritization • Stream*Dependency*in*HEADERS*Frame* • PRIORITY*frame*type* • An*additional*40*bytes* - Stream*id*(31)* - Weight*(8):*[1,*256]** - Exclusive*bit*(1)* • Only*an*advice
  34. 34. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee#HTTP/2 Server*Push /index.html***stream*1* /style.css********stream*2* /logo.gif*********stream*4 Client Server stream&1& HEADERS stream&1& DATA stream&2&&&& PROMISE stream&4& PROMISE • No*JavaScript*API!
  35. 35. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 35 @delabassee Header*Compression HPack
  36. 36. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 36 @delabassee Upgrade*from*HTTP*1.1 • HTTP* - Port*80* - HTTP*Upgrade*to*“h2c”*(101*Switching*Protocol)* • HTTPS*(*)* - Application*Layer*Protocol*Negotiation*(ALPN)* - Next*Protocol*Negotiation*(NPN)* (*)*TLS*is*not*mandatory
  37. 37. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee37 &Demo?
  38. 38. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Agenda Why*HTTP/2?* HTTP/2* HTTP/2*and*Java*SE* HTTP/2*and*Java*EE* Summary
  39. 39. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Java*9*Support*for*HTTP/2 • JEP*110* - http://openjdk.java.net/jeps/110* • Supports*both*HTTP*1.1*and*2* • Easy*to*use*API* • Covers*only*the*most*common*use*cases* • Synchronous*&*Asynchronous 39#HTTP/2
  40. 40. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Java*9 HttpClient"client"="HttpClient.create()" " """"""""""""""""""""""""""".sslContext(ctx)" " """"""""""""""""""""""""""".followRedirects(HttpRedirect.ALWAYS)" """""""""""""""""""""""""""""".executorService(…)" " """"""""""""""""""""""""""".build();" HttpRequest.Builder"builder"="client.request(new"URI(target))" """""""""""""""""""""""""""""""""""".body(noBody());" HttpResponse"response"="builder.GET().send();" //"do"something"with"the"response…" 40
  41. 41. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Java*9 //"HttpRequest"builder"from"the"default"HttpClient" HttpResponse"response"="HttpRequest.create(new"URI("http://www.abc.be"))" """"""""""""""""""""""""""""""""""".send(HttpRequest.noBody());" String"responseBody"="response.body(HttpResponse.asString());" response"="HttpRequest.create(new"URI("http://www.abc.be"))" """""""""""""""""""""".body(fromString("param1=Abc"))" """""""""""""""""""""".post()A AAAAAAAAAAAAAAAAAAAAAA.send();" … 41
  42. 42. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Java*9 HttpClient"cl"="HttpClient.create()" """""""""""""""""""""""""".proxy("http",proxAd).proxy("https","proxAd)" """""""""""""""""""""""""".sslContext(ctx)" """""""""""""""""""""""""".build();" CompletableFuture<String>"compFut"="cl.request(uri)" " " " " " " " " "".body(noBody())" " """"""""""""""""""""""".GET()" " """"""""""""""""""""""".sendAsync()" """""""""""""""""""""""""".thenCompose((HttpResponse"response)"l>"{" """"""""""""""""""""""""""""""""""return"response.bodyAsync(asString());" """"""""""""""""""""""""""});" String"body"="compFut.get(5,"TimeUnit.SECONDS);" … 42
  43. 43. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Agenda Why*HTTP/2?* HTTP/2* HTTP/2*and*Java*SE* HTTP/2*and*Java*EE* Summary
  44. 44. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 44 @delabassee • Request/Response*multiplexing* • Binary*Framing* • Stream*Prioritization* • Server*Push* • Header*Compression* • Upgrade*from*HTTP*1.1* – ALPN* – 101*Switching*Protocols HTTP/2
  45. 45. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 45 @delabassee • Request/Response*Multiplexing* • Binary*Framing* • Stream*Prioritization* • Server*Push* • Header*Compression* • Upgrade*from*HTTP*1.1* – ALPN* – 101*Switching*Protocols Features&to&be&Exposed&in&the&Servlet&API Servlet*4
  46. 46. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 46 @delabassee • Push*resource*to*client*for*a*given*url*and*headers* • May*add*callback*for*completion*or*error*of*a*push* • Not*a*replacement*for*WebSocket Servlet*4.0*R*Server*Push
  47. 47. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. PushBuilderAbuilder = baseRequest.getPushBuilder(); builder.addHeader(“X-Pusher", …); builder.path(aResource) .etag(associated._etag) .lastModified(associated._lastModified) .push(); 47 Server*Push
  48. 48. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Agenda Why*HTTP/2?* HTTP/2* HTTP/2*and*Java*SE* HTTP/2*and*Java*EE* Summary
  49. 49. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee HTTP/2 • Address*the*Limitations*of*HTTP*1.x* - Improve*ressources*utilization,*performance,*reduce*latency* • “Compatible”*with*HTTP*1.1* - Retain*HTTP*1.1*semantics* - Define*interaction*with*HTTP*1.1* - Undo*your*HTTP*1.1*tricks!!* • “TLS0not0mandatory” 49 Hypertext&Transfer&Protocol&version&2&&&HPACK
  50. 50. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee HTTP/2*and*Java • JEP*110*brings*HTTP/2*to*Java*SE* • Servlet*4.0*brings*HTTP/2*to*Java*EE* - Expose*key*features*to*the*API* • Server*Push* • HTTP*1.1*upgrade* • Timing*TBC! 50 Plans
  51. 51. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee51 &
  52. 52. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. @delabassee Resources*(and*credits) • http://http2.github.io* • http://chimera.labs.oreilly.com/books/1230000000545/ch12.html* • https://java.net/projects/servletRspec/* • http://glassfish.org/adoptajsr* • http://openjdk.java.net/jeps/110 52
  53. 53. Copyright*©*2015,*Oracle*and/or*its*affiliates.*All*rights*reserved. 53
  • ChenLiu23

    Jun. 19, 2016
  • frantikchoi

    Jan. 4, 2016

Latest iteration of my HTTP/2 deck, presented at JCConf (Taipei-Taiwan) end of 2015

Views

Total views

649

On Slideshare

0

From embeds

0

Number of embeds

23

Actions

Downloads

11

Shares

0

Comments

0

Likes

2

×