• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Jetty 9 – The Next Generation Servlet Container
 

Jetty 9 – The Next Generation Servlet Container

on

  • 1,342 views

Jetty has always been known to be a technology leader in several areas—from Jetty Continuations (later standardized as Servlet 3 asynchronous servlets) to WebSocket to SPDY—delivering exceptional ...

Jetty has always been known to be a technology leader in several areas—from Jetty Continuations (later standardized as Servlet 3 asynchronous servlets) to WebSocket to SPDY—delivering exceptional production performance.
Jetty 9 is not only a great production server but provides features such as the Jetty Maven plug-in and embedded Jetty that help you in application development and integration testing. This session covers Jetty 9’s scalability, stability, performance, and features such as the new HTTP client and how to configure Jetty for optimal production performance.

Statistics

Views

Total Views
1,342
Views on SlideShare
1,279
Embed Views
63

Actions

Likes
0
Downloads
21
Comments
0

3 Embeds 63

http://milano.codemotionworld.com 61
http://plus.url.google.com 1
http://milan2013.codemotionworld.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Jetty 9 – The Next Generation Servlet Container Jetty 9 – The Next Generation Servlet Container Presentation Transcript

    • Jetty 9 The Next-Generation Servlet Engine Simone Bordet sbordet@intalio.com
    • Simone Bordet  Simone Bordet  sbordet@intalio.com  @simonebordet  Open Source Contributor  Jetty, CometD, MX4J, Foxtrot, LiveTribe, JBoss, Larex  Lead Architect at Intalio/Webtide  Jetty's SPDY and HTTP client maintainer  CometD project leader  Web messaging framework  JVM tuning expert Simone Bordet sbordet@intalio.com
    • Agenda  Jetty Introduction  Web History and Evolution  Web Protocols  Jetty Features & Performance  The future: HTTP 2.0 Simone Bordet sbordet@intalio.com
    • Jetty  The Jetty Servlet Container  Implemented the Servlet Specification since 1.0  Jetty 7 → Servlet 2.5  Jetty 8, 9 → Servlet 3.0  Jetty 9.1 → Servlet 3.1  Mostly known for its component-based architecture  Very easy to embed  Very easy to use for automated tests  Great for production too ! Simone Bordet sbordet@intalio.com
    • History & Evolution Simone Bordet sbordet@intalio.com
    • w3c.org 1996 HTTP 1.0 protocol designed to serve these pages: 1 HTML File, 600 Bytes Simone Bordet sbordet@intalio.com
    • Evolution – I/O  Technologies evolved over the years  Scalability limited by blocking I/O  Advent of NIO (asynchronous I/O)  Servers became more scalable, C10K now possible  Jetty 6 – one of the first NIO Servlet containers  Jetty innovates: Jetty Continuations  Portable way to suspend/resume requests  Jetty spun off the CometD project at http://cometd.org  Scalable Web Messaging Framework  Servlet 3.0 incorporated Jetty Continuations concepts  Servlet 3.1 expands to asynchronous I/O Simone Bordet sbordet@intalio.com
    • Evolution – CPU  Multicore CPUs everywhere  JDK enhanced with atomic primitives  Rethink locking for “mechanical sympathy”  Jetty 9 core rewrite taking that in account  Keep thread context switching at minimum  Reduce/Eliminate false sharing  Use concurrent data structures  Avoid synchronized in favor of atomic state machines  Jetty 9.1 is 30+% faster than Jetty 8  And implements more features Simone Bordet sbordet@intalio.com
    • w3c.org 2013 1 HTML, 33.5 KiB - 4 CSS, 12 KiB – 2 JS 31 KiB - 27 Images, 61.5 KiB 34 Resources, 138 KiB Simone Bordet sbordet@intalio.com
    • cnn.com 2013 172 Resources, 1.2 MiB Simone Bordet sbordet@intalio.com
    • Web Explosion  The Web Exploded  Assumptions, protocols and technologies valid in 1996 are still our best choice ? WE CAN DO BETTER ! Simone Bordet sbordet@intalio.com
    • HTTP Limits  HTTP is an old protocol  Not bidirectional  No multiplexing  No resource correlation  Today's Web content forces too many hacks  Comet techniques to fake bidirectionality  Browsers to open multiple connections   Due to HTTP's lack of multiplexing TCP slow start gets in the way  Domain sharding imposes additional overhead on servers  Would like to use pipelining, but cannot  Does not work reliably Simone Bordet sbordet@intalio.com
    • WebSocket Simone Bordet sbordet@intalio.com
    • WebSocket  Effort Initiated by Browser Vendors to  Bidirectional low latency communications  Replace Comet HTTP “hacks”  Implement rich web applications within the browser  Standardized  IETF – RFC 6455 wire protocol  W3C – HTML 5 Javascript API  JCP – JSR 356 Java API  Jetty 7 was one of the first Servlet containers to support WebSocket (2009)  Jetty 9.1 supports JSR 356 Simone Bordet sbordet@intalio.com
    • WebSocket Upgrade  Runs on port 80 (or 443 for wss)  Uses HTTP/1.1 Upgrade mechanism REQUEST GET / HTTP/1.1 Host: localhost:8080 Origin: http://localhost:8080 Connection: Upgrade Upgrade: websocket Sec-WebSocket-Key: SbdIETLKHQ1TNBLeZFZS0g== Sec-WebSocket-Version: 13 RESPONSE HTTP/1.1 101 Switching Protocols Connection: Upgrade Upgrade: websocket Sec-WebSocket-Accept: y4yXRUolfnFfo3Jc5HFqRHNgx2A= Simone Bordet sbordet@intalio.com
    • HTTP Performance  Jetty-7.6, CometD-2.4, chat application  HTTP Simone Bordet sbordet@intalio.com
    • WebSocket Performance  Jetty-7.6, CometD-2.4, chat application  WebSocket Simone Bordet sbordet@intalio.com
    • WebSocket Deployment  Browsers  Java Servers  Firefox 11 (Android 15)  Jetty 7, Jetty 8, Jetty 9  Internet Explorer 10 PP5  Jetty 9.1 (JSR 356)  Chrome 16 (Android 18)  Glassfish  Safari 6 (iOS 6)  Resin 4  Opera 12.1 (Mini N/A)  Tomcat 7 (alpha)  Blackberry 7.0  Tomcat 8 (JSR 356)  Jetty Client 7, 8, 9 73% browser coverage (mobile too) (http://caniuse.com/websockets) Simone Bordet sbordet@intalio.com
    • SPDY Simone Bordet sbordet@intalio.com
    • SPDY is LIVE!  SPDY is a live experiment to improve HTTP  Addresses HTTP 1.1 limits  Designed to be faster and better than HTTP  Already widely deployed!  Google, Twitter, Facebook, WordPress, Webtide, etc.  Chrome & Firefox & IE 11  The SPDY protocol replaces HTTP on the wire  But it's transparent for applications Simone Bordet sbordet@intalio.com
    • SPDY & Jetty  Jetty 7 & Jetty 8  SPDY added by mocking HTTP wire protocol  Multiplexing requires mock protocol per channel  Jetty 9  Re-architected to separate wire protocol from semantics  HTTP semantics shared between HTTP, SPDY & FastCGI  HTTP, SPDY, WebSocket, TLS 1st class citizens  Use SPDY now!  ZERO changes to your existing web applications  Your use case can make Jetty, SPDY & HTTP 2.0 better Simone Bordet sbordet@intalio.com
    • SPDY Protocol Initiation  SPDY uses TLS (aka SSL) connection on port 443  TLS extended with Next Protocol Negotiation  New framing protocol over TLS  Intermediaries don't know it is not HTTP wrapped in TLS  Transports existing HTTP Semantics (GET, POST, HEAD etc)  Client and Server application don't know it is not HTTP Simone Bordet sbordet@intalio.com
    • SPDY Multiplexing  Multiplexing is built-in SYN_STREAM SYN_REPLY SYN_STREAM SYN_REPLY SYN_REPLY DATA DATA SYN_STREAM SYN_REPLY Simone Bordet sbordet@intalio.com
    • SPDY Multiplexing  Multiplexing  Allows to make better use of TCP connections  Reduces TCP slow start  Uses less resources on the server  Responses may be sent out of order  Without waiting for slow responses  Key point: reducing round trip waits  Caused by limited connections and lack of multiplexing Simone Bordet sbordet@intalio.com
    • SPDY Push  SPDY Push  Server pushes secondary resources that are associated to a primary resource  Works in collaboration with browser's cache for a better user experience  Jetty is one of the first SPDY servers that provides automated push functionalities  Totally transparent for applications  Based on the “Referrer” header  To associate primary and secondary resources  Using “If-Modified-Since” header to avoid unnecessary pushes Simone Bordet sbordet@intalio.com
    • SPDY Push HTTP/1.1 index.html application.js style.css image1.png Push Cache SPDY/3 + PUSH Simone Bordet sbordet@intalio.com index.html appliction.js style.css Image1.png
    • SPDY Clients  Desktop  Mobile  Firefox 13  Android Browser 4.1  Chrome 4  Chrome for Android 18.0  Opera 12.1  Firefox Android 15.0  Jetty Client 7, 8, 9 55% browser coverage (mobile too) (http://caniuse.com/spdy) Simone Bordet sbordet@intalio.com
    • DEMO Simone Bordet sbordet@intalio.com
    • Jetty 9.1 Simone Bordet sbordet@intalio.com
    • Jetty 9.1  Polyglot (HTTP, WebSocket, SPDY, FastCGI)  Servlet 3.1 ready  Great as a production server too  Not a monolithic server  Pick only the modules you need  Tons of configuration possibilities  Easy to customize  “Jetty was one of the first servers to ...”  Early adopters find the edge features they want in Jetty  Late adopters benefit of the experience Jetty gathered Simone Bordet sbordet@intalio.com
    • Jetty 9.1 Performance  Great performance  Easy to push it to 70k or more requests/s  These are Servlet requests not just http ones  Easy to get it to 250k connections  Servlet 3.1 on par with Servlet 3.0  But with less threads  Intalio/Webtide commercial support Simone Bordet sbordet@intalio.com
    • Servlet 3.1 public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { AsyncContext asyncContext = request.startAsync(request, response); asyncContext.setTimeout(0); ReadListener reader = new AsyncReader(asyncContext); ServletInputStream input = request.getInputStream(); input.setReadListener(reader); } Simone Bordet sbordet@intalio.com
    • Servlet 3.1 public class AsyncReader implements ReadListener { private final AsyncContext asyncContext; ... public void onDataAvailable() throws IOException { ServletInputStream input = asyncContext.getRequest().getInputStream(); ... } public void onAllDataRead() throws IOException { ... } } Simone Bordet sbordet@intalio.com
    • Servlet 3.1 public class AsyncWriter implements WriteListener { private final AsyncContext asyncContext; ... public void onWritePossible() throws IOException { ServletOutputStream output = asyncContext.getResponse().getOutputStream(); ... if (finishedWriting) asyncContext.complete() } } Simone Bordet sbordet@intalio.com
    • Servlet 3.1 Echo Servlet Blocking I/O public class SyncServlet extends HttpServlet { protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { byte[] buffer = new byte[BUFFER_SIZE]; while (true) { int read = request.getInputStream().read(buffer, 0, BUFFER_SIZE); if (read < 0) break; response.getOutputStream().write(buffer, 0, read); } } } Echo Servlet Async I/O public static class AsyncServlet extends HttpServlet { @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { AsyncContext asyncContext = request.startAsync(request, response); asyncContext.setTimeout(0); Echoer echoer = new Echoer(asyncContext); request.getInputStream().setReadListener(echoer); response.getOutputStream().setWriteListener(echoer); } private class Echoer implements ReadListener, WriteListener { private final byte[] buffer = new byte[BUFFER_SIZE]; private final AsyncContext asyncContext; private final ServletInputStream input; private final ServletOutputStream output; private boolean complete; private Echoer(AsyncContext asyncContext) throws IOException { this.asyncContext = asyncContext; this.input = asyncContext.getRequest().getInputStream(); this.output = asyncContext.getResponse().getOutputStream(); } @Override public void onDataAvailable() throws IOException { while (input.isReady()) { int read = input.read(buffer); output.write(buffer, 0, read); if (!output.isReady()) return; } if (input.isFinished()) { complete = true; asyncContext.complete(); } } @Override public void onAllDataRead() throws IOException { } @Override public void onWritePossible() throws IOException { if (input.isFinished()) { if (!complete) asyncContext.complete(); } else { onDataAvailable(); } } @Override public void onError(Throwable failure) { failure.printStackTrace(); } } } Simone Bordet sbordet@intalio.com
    • Jetty 9.1  Jetty HttpClient  High Performance HttpClient with fluent API  70% faster than Jetty 8's HttpClient  Pluggable transports (HttpClient can speak SPDY)  HTTP Proxy  SPDY Proxy  Jetty FastCGI  Jetty can serve PHP / Python / Ruby / etc. Simone Bordet sbordet@intalio.com
    • HTTP 2.0  HTTP 2.0 work has started  IETF HTTPbis working group rechartered  Two proposals received:  Google - SPDY as the basis  Microsoft – WebSocket framing with HTTP semantics  SPDY Adopted as the starting point  Unlikely to require TLS or NPN  Will define precise interactions with proxies  Early draft available  http://tools.ietf.org/html/draft-ietf-httpbis-http2-06 Simone Bordet sbordet@intalio.com
    • Conclusions Simone Bordet sbordet@intalio.com
    • Conclusions  The Web is evolving  Web Protocols are evolving  Servers must keep the pace with new Web Protocols  Try WebSocket today  Production ready  Try SPDY today  Check your application is ready for the future  Check the future is ready for your application Simone Bordet sbordet@intalio.com
    • Questions & Answers Simone Bordet sbordet@intalio.com