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

More Related Content

PDF
Do We Need Containers Anyway?
PDF
Jetty Continuation - 이상민
DOC
Jetty Vs Tomcat
PDF
Tricks and Tips With NIO Using the Grizzly Framework
PDF
Great Java Application Server Debate
ODP
Servlet 3.1 Async I/O
PPTX
Php push notifications
PDF
HTTP/2 Comes to Java
Do We Need Containers Anyway?
Jetty Continuation - 이상민
Jetty Vs Tomcat
Tricks and Tips With NIO Using the Grizzly Framework
Great Java Application Server Debate
Servlet 3.1 Async I/O
Php push notifications
HTTP/2 Comes to Java

What's hot (20)

PPTX
HTML5 WebSocket Introduction
PPTX
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
PDF
Building Next Generation Real-Time Web Applications using Websockets
PDF
WebRTC + Socket.io: building a skype-like video chat with native javascript
PDF
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
KEY
Pushing the web — WebSockets
PDF
HTML5 WebSocket for the Real-Time Web and the Internet of Things
PPS
J web socket
PPTX
CollabSphere SC 103 : Domino on the Web : Yes, It's (Probably) Hackable
PPTX
Spring Boot & WebSocket
PPTX
PPTX
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
PDF
GWT Web Socket and data serialization
PPTX
WebSocket protocol
PPTX
Large scale web socket system with AWS and Web socket
PDF
HTML5 WebSockets
PDF
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
PPTX
Spring + WebSocket integration
PDF
Realtime with-websockets-2015
PDF
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
HTML5 WebSocket Introduction
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
Building Next Generation Real-Time Web Applications using Websockets
WebRTC + Socket.io: building a skype-like video chat with native javascript
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
Pushing the web — WebSockets
HTML5 WebSocket for the Real-Time Web and the Internet of Things
J web socket
CollabSphere SC 103 : Domino on the Web : Yes, It's (Probably) Hackable
Spring Boot & WebSocket
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
GWT Web Socket and data serialization
WebSocket protocol
Large scale web socket system with AWS and Web socket
HTML5 WebSockets
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
Spring + WebSocket integration
Realtime with-websockets-2015
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
Ad

Viewers also liked (20)

PPT
Jetty Introduction
PPTX
Classification of port and harbour ppt.pptx
PDF
Jetty TLS Troubleshooting
PPTX
DRUPAL Search API Solr
PPTX
Spring Boot Showcase
PPT
Privacy and visibility in the sensor society
PDF
Putting Hypermedia Back in REST with JAX-RS
PPTX
Jetty服务器架构及调优.v2 2011-5
PDF
BOOK_SPIRAL JETTY ACOMA MADRID BANDELIER KLAUS HU 2013/14
PPTX
Berthing structures
PPTX
Hadoop Interacting with HDFS
PDF
Indexing Text and HTML Files with Solr
PPT
Spillways2000 101110063804-phpapp02 - copy
PPTX
Breakwater, jetties and groins.
PDF
Spillways
PPT
Breakwaters
PPTX
Docks and their classification
PPT
Spillway
PPT
Horbour & Dock Engineerin
Jetty Introduction
Classification of port and harbour ppt.pptx
Jetty TLS Troubleshooting
DRUPAL Search API Solr
Spring Boot Showcase
Privacy and visibility in the sensor society
Putting Hypermedia Back in REST with JAX-RS
Jetty服务器架构及调优.v2 2011-5
BOOK_SPIRAL JETTY ACOMA MADRID BANDELIER KLAUS HU 2013/14
Berthing structures
Hadoop Interacting with HDFS
Indexing Text and HTML Files with Solr
Spillways2000 101110063804-phpapp02 - copy
Breakwater, jetties and groins.
Spillways
Breakwaters
Docks and their classification
Spillway
Horbour & Dock Engineerin
Ad

Similar to Jetty 9 – The Next Generation Servlet Container (20)

PDF
HTTP, WebSocket, SPDY: evoluzione dei protocolli web by Simone Bordet
PDF
Realizzare applicazioni Web con WebSocket, by Simone Bordet
PPTX
WebSockets On Fire
PDF
Cloud-Ready Web Messaging With CometD by S. Bordet
ODP
Cloud-Ready Web Messaging with CometD
PPT
Cometdの紹介
ODP
Introduction to Reactive Streams: Current & Future - Simone Bordet - Codemoti...
PDF
Improving performance by changing the rules from fast to SPDY
PDF
From Fast To SPDY
PPTX
Programming WebSockets with Glassfish and Grizzly
PDF
Dev con kolkata 2012 websockets
PPTX
SPDY - or maybe HTTP2.0
ODP
Comet / WebSocket Web Applications
PPT
Westhawk integration
PDF
Real-Time with Flowdock
PDF
Computer network (10)
KEY
The HTML5 WebSocket API
PPTX
V2 peter-lubbers-sf-jug-websocket
PDF
HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era
PPT
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
HTTP, WebSocket, SPDY: evoluzione dei protocolli web by Simone Bordet
Realizzare applicazioni Web con WebSocket, by Simone Bordet
WebSockets On Fire
Cloud-Ready Web Messaging With CometD by S. Bordet
Cloud-Ready Web Messaging with CometD
Cometdの紹介
Introduction to Reactive Streams: Current & Future - Simone Bordet - Codemoti...
Improving performance by changing the rules from fast to SPDY
From Fast To SPDY
Programming WebSockets with Glassfish and Grizzly
Dev con kolkata 2012 websockets
SPDY - or maybe HTTP2.0
Comet / WebSocket Web Applications
Westhawk integration
Real-Time with Flowdock
Computer network (10)
The HTML5 WebSocket API
V2 peter-lubbers-sf-jug-websocket
HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel

More from Codemotion (20)

PDF
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
PDF
Pompili - From hero to_zero: The FatalNoise neverending story
PPTX
Pastore - Commodore 65 - La storia
PPTX
Pennisi - Essere Richard Altwasser
PPTX
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
PPTX
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
PPTX
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
PPTX
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
PDF
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
PDF
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
PDF
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
PDF
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
PDF
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
PDF
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
PPTX
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
PPTX
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
PDF
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
PDF
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
PDF
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
PDF
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Pompili - From hero to_zero: The FatalNoise neverending story
Pastore - Commodore 65 - La storia
Pennisi - Essere Richard Altwasser
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019

Recently uploaded (20)

PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
CloudStack 4.21: First Look Webinar slides
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
The various Industrial Revolutions .pptx
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PPTX
Microsoft Excel 365/2024 Beginner's training
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Getting started with AI Agents and Multi-Agent Systems
PPTX
2018-HIPAA-Renewal-Training for executives
PDF
Five Habits of High-Impact Board Members
PPTX
Chapter 5: Probability Theory and Statistics
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
The influence of sentiment analysis in enhancing early warning system model f...
Benefits of Physical activity for teenagers.pptx
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
CloudStack 4.21: First Look Webinar slides
A proposed approach for plagiarism detection in Myanmar Unicode text
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Enhancing emotion recognition model for a student engagement use case through...
A comparative study of natural language inference in Swahili using monolingua...
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
The various Industrial Revolutions .pptx
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Microsoft Excel 365/2024 Beginner's training
Custom Battery Pack Design Considerations for Performance and Safety
UiPath Agentic Automation session 1: RPA to Agents
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Getting started with AI Agents and Multi-Agent Systems
2018-HIPAA-Renewal-Training for executives
Five Habits of High-Impact Board Members
Chapter 5: Probability Theory and Statistics

Jetty 9 – The Next Generation Servlet Container

  • 2. Simone Bordet  Simone Bordet  [email protected]  @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 [email protected]
  • 3. Agenda  Jetty Introduction  Web History and Evolution  Web Protocols  Jetty Features & Performance  The future: HTTP 2.0 Simone Bordet [email protected]
  • 4. 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 [email protected]
  • 6. w3c.org 1996 HTTP 1.0 protocol designed to serve these pages: 1 HTML File, 600 Bytes Simone Bordet [email protected]
  • 7. 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 [email protected]
  • 8. 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 [email protected]
  • 9. 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 [email protected]
  • 11. Web Explosion  The Web Exploded  Assumptions, protocols and technologies valid in 1996 are still our best choice ? WE CAN DO BETTER ! Simone Bordet [email protected]
  • 12. 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 [email protected]
  • 14. 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 [email protected]
  • 15. 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 [email protected]
  • 16. HTTP Performance  Jetty-7.6, CometD-2.4, chat application  HTTP Simone Bordet [email protected]
  • 17. WebSocket Performance  Jetty-7.6, CometD-2.4, chat application  WebSocket Simone Bordet [email protected]
  • 18. 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 [email protected]
  • 20. 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 [email protected]
  • 21. 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 [email protected]
  • 22. 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 [email protected]
  • 23. SPDY Multiplexing  Multiplexing is built-in SYN_STREAM SYN_REPLY SYN_STREAM SYN_REPLY SYN_REPLY DATA DATA SYN_STREAM SYN_REPLY Simone Bordet [email protected]
  • 24. 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 [email protected]
  • 25. 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 [email protected]
  • 26. SPDY Push HTTP/1.1 index.html application.js style.css image1.png Push Cache SPDY/3 + PUSH Simone Bordet [email protected] index.html appliction.js style.css Image1.png
  • 27. 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 [email protected]
  • 30. 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 [email protected]
  • 31. 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 [email protected]
  • 32. 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 [email protected]
  • 33. 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 [email protected]
  • 34. 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 [email protected]
  • 35. 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 [email protected]
  • 36. 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 [email protected]
  • 37. 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 [email protected]
  • 39. 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 [email protected]