Message-ID: <899789572.41718.1371671826755.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_41717_251000040.1371671826754" ------=_Part_41717_251000040.1371671826754 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This demonstration shows how the proposed servlet 3.0 asynchronous API (= inspired by Jetty continuations) can be used to greatly improve web service= s. The demo runs searches using the eBay API, both sync= hronously and asynchronously, and displays the results side-by-side.
The synchronous servlet calls the web service for each keyword sequentia= lly. The thread servicing the web request blocks, waiting for each search t= o complete before making the next request. The servlet thread is held for t= he entire elapsed time of all web service calls.
The asynchronous servlet uses the Jetty HTTP Client to initiate an asynchronous web service call f= or all keywords in parallel. As each search completes, its results are adde= d to the list of search results using a callback method. After all searches= have been completed, the request is resumed. The web service calls are don= e in parallel and the servlet thread is only held for a short time at the s= tart and end of the elapsed time.
With one item, the time it takes to fetch the search results is roughly = equivalent for both synchronous and asynchronous calls. However, with each = additional items, the time it takes to search using the synchronous servlet= increases proportionally, while the asynchronous servlet incurs only minor= additional overhead.
To run the demonstration, first get the source code from SVN. Run it using
then visit http://localhost:8080/. There are two examples each of s= ynchronous and asynchronous; the first example searches for one item, the s= econd for multiple.
You can also use the form at the bottom of the page to run your own sear= ches. For more dramatic results, try conducting a search with ten different= items at once.------=_Part_41717_251000040.1371671826754--