Date post: | 11-Jan-2017 |
Category: |
Technology |
Upload: | reza-rahman |
View: | 17,501 times |
Download: | 2 times |
Others Talk, We Listen.
HTTP/2 and What it Means for the Java EE EcosystemReza RahmanSenior [email protected]@reza_rahman
CapTech
Full-service US national IT consulting firm that focuses on client best interests, trust, servant leadership, culture, professionalism and technical excellence.
#28 in Vault's Consulting Top 50#3 Best Consulting Internship#9 Best Overall Internship
#1 in Meeting Client’s Needs#7 Best Firm to Work For#1 in Career Development
Ranked for the 7th Consecutive Year
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Why HTTP/2?
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
The Web of the Past
Why HTTP/2?
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
The Web Today
HTTP Pipelining/Head-of-Line Blocking
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
style1.cssstyle2.css
Client Server
index.html
index.html
style1.cssstyle2.cssscript1.js
.
.
.
script2.js
.
.
.
script1.jsscript2.js
Socket Abuse/Max Connections
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Client Server
Client Server
Client Server
Client Server
Client Server
Client Server
HTTP 1.1 Hacks
• File concatenation and image sprites• Domain sharding• Inlined assets
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
HTTP/2
• HTTP/2 is new transport layer underneath HTTP/1.1• Same request/response model• No new methods• No new headers• No new URLs or ports
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
At the Network Layer
HTTP/2
• Sockets scarce resource• Only one open per server
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
At the Socket Layer
Socket Abuse/Max Connections
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Client Server
Client Server
Client Server
Client Server
Client Server
Client Server
Sockets in HTTP/2
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Client Server
HTTP/2 Big Ticket Features
• Request/response multiplexing• Binary framing• Stream prioritization• Server push• Header compression• HTTP/2 upgrade
• ALPN• 101 Switching Protocols
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
HTTP/2 Request/Response Multiplexing
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
HTTP/2 Request/Response Multiplexing
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
HTTP/2 Header Compression
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
HTTP/2 Stream Prioritization
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
A
B C
4 12
A
B CD
4 16 12
A
B C
D
4 12
16
HTTP/2 Server Push
• Eliminates need for resource in-lining.• Lets server populate browser’s cache in advance.
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
HTTP/2 Upgrade from HTTP/1.1
• Not secure• Use port 80• Use existing 101 Switching Protocols from HTTP/1.1
• Secure• Application Layer Protocol Negotiation (ALPN)
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
http://www.http2demo.io
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Servlet 4 Abstracts All This
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Servlet 4
• Servlet well positioned to enable HTTP/2• Low-level protocol changes absorbed transparently• Allow frameworks to effectively leverage server push
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Challenges Exposing HTTP/2 Features in Servlet
• Existing API designed for one request == one response.• HTTP/2 destroys this assumption.• It will be challenging to do justice to the new reality of one request == one or more responses.
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
HTTP/2 Features Exposed in Servlet
• Request/response multiplexing• Binary framing• Stream prioritization• Server push• Header compression• HTTP/2 upgrade
• ALPN• 101 Switching Protocols
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Servlet 4 New Features
• HTTP/2 required• Server push
• Push resource to client for a given URL and headers.• Really useful for frameworks that build on Servlet, such as JSF• Builder API
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
javax.servlet.http.PushBuilder
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Server Push via Builder API
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Server Push in JSF
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
public class FacesServlet implements Servlet { public void service(ServletRequest req, ServletResponse resp) throws IOException, ServletException { //... HttpServletRequest request = (HttpServletRequest) req; try { ResourceHandler handler = context.getApplication().getResourceHandler(); if (handler.isResourceRequest(context)) { handler.handleResourceRequest(context); } else { lifecycle.attachWindow(context); lifecycle.execute(context); lifecycle.render(context); } } }
Server Push in JSF
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
public class ExternalContextImpl extends ExternalContext { //... public String encodeResourceURL(String url) { if (null == url) { String message = MessageUtils.getExceptionMessageString (MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "url"); throw new NullPointerException(message); } ((HttpServletRequest) request).getPushBuilder().path(url).push(); return ((HttpServletResponse) response).encodeURL(url); } //...}
Current Status
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
• Minimal early draft released, further progress basically stalled.
Java EE Guardians
https://groups.google.com/group/javaee-guardians@javaee_guardian
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Resources
• http2 explained• https://daniel.haxx.se/http2/
• Servlet 4 Specification• https://servlet-spec.java.net
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.
Copyright © 2015 CapTech Ventures, Inc. All rights reserved.