Jetty History Jetty の歴史 founded by Greg Wilkins in 1995 1995 年に Greg Wilkins が設立 one of first Java applications 最初の Java のアプリケーションの 1 つ constant set of core developers 恒久的にコアな開発者の対応 Version Home Java HTTP Servlet JSP Status 8.x Eclipse/Codehaus 1.6 HTTP/1.1 RFC2616 3.0 2.2 Experimental 7.x Eclipse/Codehaus 1.5 HTTP/1.1 RFC2616 2.5 2.1 Stabilising 6.x Codehaus 1.4-1.5 HTTP/1.1 RFC2616 2.5 2.0/2.1 Stable 5.x Sourceforge 1.2-1.5 HTTP/1.1 RFC2616 2.4 2.0 Mature 4.x Sourceforge 1.2 HTTP/1.1 RFC2616 2.3 1.2 Ancient 3.x Sourceforge 1.2 HTTP/1.1 RFC2616 2.2 1.1 Fossilised 2.x Mortbay 1.1 HTTP/1.0 RFC1945 2.1 1.0 Legendary 1.x Mortbay 1.0 HTTP/1.0 RFC1945 Mythical
3.
What is JettyJetty とは何か ? HTTP server & servlet container HTTP サーバーとサーブレットのコンテナー Application server (High tide distribution) アプリケーションサーバー(大量に分布) Cometd server Cometd サーバー OSGi web service OSGi 準拠の Web サービス Async HTTP service (client and server) 非同期 HTTP サービス(クライアントとサーバー)
4.
Jetty is aNOT a Application Server Jetty はアプリケーションサーバーではありません JVM Application Application Server
Jetty can powerApplication Server Jetty はアプリケーションサーバー のみ として も 稼働できます JVM Application Jetty:// Application Container
7.
Jetty Inside Jetty 内部 Millions of installations 何百万人がインストール Powering hundreds of thousands of websites 数十万の Web サイトで提供 From constrained environments: 制限がある環境から: Mobile phones (i-jetty), set top boxes To middleware: ミドルウェアまで: Applications: GWT, ActiveMQ, Nexus Application Servers: Jetty-Hightide, Geronimo, Jonas, Jboss, SybaseEA OSGi Infrastructures: Eclipse Equinox, Apache Felix, PAX Cloud: Intalio|Cloud, Google AppEngine, Gigaspaces To massively parallel environments: 大量の並列環境まで: Hadoop (holds record for sorting terrabyte of data) Jetty is such a good component it‘s generally invisible Jetty は一般的に目に見えない良いコンポーネントです。
Features 特徴 “It just works!” 稼働します! Feature 特徴 Benefit 利点 Compostable コンポスト可能 Modular design モジュール設計 Embeddable 埋込可能 Small footprint 小さなフットプリント Customizable カスタマイズ可能 Extend or replace defaults デフォルトの拡張・置換 JavaEE Optional modules オプションモジュール Specifications 仕様 HTTP and Servlet compliance HTTP とサーブレットのコンプライアンス Scalable 拡張可能 nio & asynchronous servlets NIO (ノンブロッキング I/O )と非同期サーブレット Cometd Java reference implementation Java のリファレンスを実装 Libraries ライブラリー Client, server, utility, testing Tool support ツールサポート Maven, ant, eclipse integration Innovative 革新的 We like new use-cases :) 新規ユースケースを希望
11.
Small footprint 小さなフットプリントJetty client/server on phones 携帯電話上での Jetty クライアント・サーバー i-jetty Google Android me-jetty J2ME CLDC
12.
Feature: scalability 特徴:拡張性Cloud クラウド Used in hadoop cluster that holds record for sorting a TB ソートしたテラバイトのデータを保持する Hadoop のクラスタリングで使用 Footprint フットプリント As important in cloud as in mobile モバイル・クラウドで同様に重要 Asynchronous 非同期 Not limited by thread pool スレッドプールに制限なし Modularity モジュール方式 Use only the bits you need 必要最小限のみ使用 Replace/Customize parts 一部分を置換 / カスタマイズ化
13.
Feature: asynchronous servlets特徴:非同期サーブレット Long poll (aka comet, hanging GET) 長期ポーリング(別名: Comet 、 Get 制御) Threadless wait スレッドレスで待機が可能 Jetty native Continuations also Servlet Specification 3.0 Jetty のネイティブな延長が、サーブレット 3.0 の仕様 resume suspend servlet GET Response
Why Async HTTP/Servlets?何故、非同期 HTTP/ サーブレットであるのか ? For Async IO ??? 非同期の I/O とは‽ 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??? 部分的な XML の要素、または UTF-8 の文字コード ??? 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! 非同期の Jetty は非同期の I/O ではありません
Waiting for WSResponses Web サービスのレスポンスの待機 Blocking WS Asynchronous WS Web サービスをブロック 非同期の Web サービス
25.
Asynchronous WS – Async client! 非同期の Web サービス – 非同期のクライアント! Webapp doGet doGet startAsync WS call dispatch Server
26.
Waiting for Resources.eg JDBC リソースへの待機 例) JDBC Slow resource may cause thread starvation: リソース不足はスレッドの停止を引き起こすかもしれません: 1000 request / sec 1 秒間に 1000 リクエスト 500 threads in server pool サーバーに 500 スレッド 10% requests use JDBC connection (25 in pool) 10% のリクエストが JDBC 接続を使用 If DB becomes blocked: データベースがブロックされた場合: 5 seconds to consume ALL 500 threads! 5 秒間で全ての 500 スレッドを消費 If DB becomes slow (500ms): データベースが遅くなった場合: 10 seconds to consume ALL 500 threads! 10 秒間で全ての 500 スレッドを消費 The 90% of non DB requests blocked by 10% !!! データベースへの接続がないリクエストの 90% が 10% でブロック
27.
QoSFilter サンプルソースコードtry { 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(); } }
28.
Waiting for Eventsイベントへの待機 Ajax Comet aka Ajax Push, Long Polling, Forever Frame New class of web-2.0 applications Web2.0 対応アプリケーションの新規クラス Ajax Chat (hello world of comet) Ajax チャット( Comet のハローワールド) Live stock prices 生で株価 Gaming ゲーム Collaborative editing コラボレーションして編集 Social Networking ソーシャルネットワーキング
29.
Why Async Servlets?何故、非同期のサーブレットであるのか ? Because there are REAL use-cases: 現実的なユースケースは以下の通りです: Waiting for resources リソースの待機 Waiting for events イベントの待機 Waiting for responses レスポンスの待機 Jetty provides: Jetty は以下を提供します: Async HTTP Server 非同期の HTTP サーバー can suspend/resume requests リクエストの停止 / 再開 Async HTTP Client 非同期の HTTP クライアント callbacks on status, headers and content ステータス、ヘッダーと内容をコールバック
#8 + written 1997 for programming contest + provides an http server like Apache but in Java + also a servlet server like Tomcat but both combined + philosophy is to be small as possible and easily embeddable, not monolithic standalone but can also be run standalone. Mission is to do the servlet spec implementation in the best possible way. + few jar dependencies as possible: just + many previous versions, now rewritten for Jetty6 taking advantage of NIO, non-blocking IO and support for Continuations + other j2ee services like <resource-ref> and UserTransactions, JAAS etc developed as optional add-ons, generally referred to as JettyPlus + jetty is the webcontainer in a number of J2EE app servers, mostly currently using jetty5, moving on to jetty6. A bit of Jboss history, still available from mortbay servers. + the Jetty “hall of fame” page, as well as numerous cds, books etc