Post on 10-Mar-2018
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty @ Eclipse
live.eclipse.org webinar
Greg Wilkins <gregw@webtide.com>
CTO WebtideProject Lead Jetty @ eclipse RT Project Lead Jetty @ codehaus
Project Lead cometd @ dojo foundation
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty @ Eclipse Webinar� Overview of Jetty Project & History
� Drill down on some key features
� Project status
� Some (hopefully) cool demos
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
What is Jetty ?� Core Components
− HTTP Server
− HTTP Client
− Servlet Container
� Plus Components
− JNDI
− JAAS, JASPI
− Utility Servlets (proxy, QoS, CGI, Gzip, etc. )�
− Cometd, Oort
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty History� 1995 Developed on Java 0.9
− as embedded HTTP server for issue tracking system
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty History�1995 Developed on Java 0.9
�1997 Renamed Jetty
− implemented alpha servlet API
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty History�1995 Developed on Java 0.9
�1997 Renamed Jetty
�1998 Jetty 2.0
− HTTP/1.1 support
− @ sourceforge
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty History�1995 Developed on Java 0.9
�1997 Renamed Jetty
�1998 Jetty 2
�2005 Jetty 6
− @ codehaus
− Focus on web 2.0 scalability
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty History�1995 Developed on Java 0.9
�1997 Renamed Jetty
�1998 Jetty 2
�2005 Jetty 6
�2009 Jetty 7
− @ eclipse foundation
− Part of eclipse RT
− Repackaged for better OSGi bundles
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty History�1995 Developed on Java 0.9
�1997 Renamed Jetty
�1998 Jetty 2
�2005 Jetty 6
�2009 Jetty 7
�2010 Jetty 8
− Servlet 3.0
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty Features� HTTP and Servlet components:
− Embeddable
− Small Footprint
− Scalable
− Asynchronous
� Many integrations
− Equinox
− Maven
− Grails
− etc.
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty is a NOT a Application Server
JVM
Application Server
Application
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty is a Component
JVM
Application
Jetty://
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty is a Component� Jetty as a Component:
− Equinox HTTP Service
− Eclipse IDE
− GWT
− Grails
− Yahoo/Zimbra
− Hadoop
− camel
− etc.
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty can power Application Server
JVM
Application Container
Application
Jetty://
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty powered Application Servers� Jetty Plus, Jetty Hightide
� Sybase EA server
� Geronimo
� Jboss
� Jonas
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty's Small Footprint� Minimal Dependencies!
javax.xml 0.000 MB
POJOs 0.020 MB
o.e.jetty.log 0.006 MB
-------------
0.026 MB
� Pooling
� Smart Buffering
− Own UTF-8 handling
� Avoided Dependencies!
xercesImpl 1.0MB
Spring 1.9MB
Log4j 0.4MB
---------
3.3MB !!!
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Small footprint� Jetty client/server on phones
− I-jetty Google Android
− Me-jetty J2ME CLDC
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Small footprint allows large scaling� Jetty in Hadoop
− World record sort of 1 terabyte in 209s on 910 nodes
− Yahoo has > 13000 hadoop nodes
� Jetty in Google AppEngine
− Foot print is important in large clouds
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Why Async HTTP/Servlets?�For Async IO ???
− To avoid blocking while:
� reading request ???
� writing response ???
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Why Async HTTP/Servlets?�For Async IO ???
− To avoid blocking while:
� reading request
� writing response
− Requests mostly small
� Single packet – no blocking
� Multiple packets hard to handle in application
− Partial XML elements or UTF-8 characters???
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Why Async HTTP/Servlets?�For Async IO ???
− To avoid blocking while:
� reading request
� writing response
− Requests mostly small
� Single packet – no blocking
� Multiple packets hard to handle in application
− Partial XML elements or UTF-8 characters???
− Responses can be large
� But difficult to handle in the application
− What do do if application does a partial write? Loop and try again!
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Why Async HTTP/Servlets?�For Async IO ???
− To avoid blocking while:
� reading request
� writing response
− Requests mostly small
� Single packet – no blocking
� Multiple packets hard to handle in application
− Partial XML elements or UTF-8 characters???
− Responses can be large
� But difficult to handle in the application
− What do do if application does a partial write? Loop and try again!
�Async Jetty is NOT about async IO!
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Why Async HTTP/Servlets?�HTTP Servlets frequently wait for:
− Resources (eg JDBC connection)
− Events (eg Chat)
− Responses (eg webservices)
�HTTP Clients wait for
− Connections
− Responses
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Waiting for Resources. eg JDBC� Slow resource may cause thread starvation:
− 1000 request / sec
− 500 threads in server pool
− 10% requests use JDBC connection (25 in pool)
� If DB becomes blocked:
− 5 seconds to consume ALL 500 threads!
� If DB becomes slow (500ms):
− 10 seconds to consume ALL 500 threads!
− The 90% of non DB requests blocked by 10% !!!
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
QoSFiltertry {
if (request.getDispatcherType()!=DispatcherType.ASYNC) {
accepted=_passes.tryAcquire(_waitMs,TimeUnit.MILLISECONDS);
if (!accepted){
request.startAsync();
int priority = getPriority(request);
_queue[priority].add(request);
return;
}
} else {
_passes.acquire();
accepted=true;
}
if(accepted)�
chain.doFilter(request,response);
}
finally {
if (accepted) {
for (int p=_queue.length;p-->0;) {
ServletRequest req=_queue[p].poll();
if (req!=null) {
req.getAsyncContext.dispatch();
break;
}
}
_passes.release();
}
}
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Waiting for Events� Ajax Comet
− aka Ajax Push, Long Polling, Forever Frame
� New class of web-2.0 applications
− Ajax Chat (the hello world of comet)�
− Live stock prices
− Gaming
− Collaborative editing
− Social Networking
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Waiting for Events�eg Comet web chat
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Waiting for Events�eg Comet web chat
Servlet
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Comet – Performance
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Asynchronous WS – async client!
Webapp
doGet
doGet
startAsync WS call
dispatch
Server
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Why Async Servlets?� Because there are REAL use-cases:
− Waiting for resources
− Waiting for events
− Waiting for responses
� Jetty provides:
− Async HTTP Server
� can suspend/resume requests
− Async HTTP Client
� callbacks on status, headers and content
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
More Jetty Demonstrations� Jetty maven plugin
� Jetty comet load generator
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty @ eclipse: Why?� Good for Jetty
− Improved process
− New ideas & requirements
− Community: Work closely with OSGi etc.
− Publicity
� Good for eclipse
− Validate process
− New ideas & requirements (Eg HTTP Service)�
− Community: large user base to eclipse RT
− Publicity
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty @ eclipse: What?� Core components:package org.eclipse.jetty.util;
package org.eclipse.jetty.io;
package org.eclipse.jetty.http;
package org.eclipse.jetty.server;
package org.eclipse.jetty.client;
package org.eclipse.jetty.security;
package org.eclipse.jetty.servlet;
package org.eclipse.jetty.xml;
package org.eclipse.jetty.webapp;
package org.eclipse.jetty.jmx;
package org.eclipse.jetty.jndi;
� Available as
− maven artifacts
− OSGi bundles
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty @ eclipse: What not?� Components @ codehaus
− JSP integration � May move later when glassfish/apache Jasper IP cleared
− 3rd Party integrations� Maven, Spring, Terracotta, ant, grizzly
− Hightide Application Server� Bundles atomikos, activemq, etc.
− Examples needing 3rd party libs� Ebay async webservice
� Other components relocated
− Cometd to Dojo Foundation
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty @ eclipse: When?� It's Happened!
− Project in incubation
� http://www.eclipse.org/jetty/
− Initial code contribution in svn now!
� http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/
� Jetty-7 : Q2 2009
− Servlet 2.5
− Improvements to equinox HTTP Service
� Jetty-8 : Q1 2010
− Servlet 3.0
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
OSGi HTTP Improvements� HTTP Service is old
− No filters
− Poor context support
− Many non-standard work arounds
� Aim to provide:
− full HTTP/Servlet capabilities to OSGi bundles
− RFC 66 support
� We are mostly OSGi novices
− Looking for suggestions and help
(c)opyright webtide 2006. Some rights reserved. http://creativecommons.org/licenses/by-nc-sa/2.5/
Jetty @ eclipse
Thanks!