| 1 |
<html> |
| 2 |
<head> |
| 3 |
<style type='text/css'> |
| 4 |
iframe {border: 0px} |
| 5 |
table, tr, td {border: 0px} |
| 6 |
</style> |
| 7 |
</head> |
| 8 |
<body> |
| 9 |
<h1>Blocking vs Asynchronous REST</h1> |
| 10 |
<p> |
| 11 |
This demo calls the EBay WS API both synchronously and asynchronously, |
| 12 |
to obtain items matching each of the keywords passed on the query |
| 13 |
string. The time the request thread is held by the servlet is displayed in red for both. |
| 14 |
</p> |
| 15 |
|
| 16 |
<table width='100%'> |
| 17 |
|
| 18 |
<tr> |
| 19 |
<td> |
| 20 |
<iframe id="f1" width='100%' height='175px' src="testSerial?items=kayak"></iframe> |
| 21 |
</td> |
| 22 |
<td> |
| 23 |
<iframe id="f3" width='100%' height='175px' src="testSerial?items=mouse,beer,gnome"></iframe> |
| 24 |
</td> |
| 25 |
</tr> |
| 26 |
|
| 27 |
<tr> |
| 28 |
<td> |
| 29 |
<iframe id="f2" width='100%' height='175px' src="testAsync?items=kayak"/></iframe> |
| 30 |
</td> |
| 31 |
<td> |
| 32 |
<iframe id="f4" width='100%' height='175px' src="testAsync?items=mouse,beer,gnome"/></iframe> |
| 33 |
</td> |
| 34 |
</tr> |
| 35 |
|
| 36 |
</table> |
| 37 |
By the use of Asynchronous Servlets and the Jetty Asynchronous client, the server is able to release the thread (green) while |
| 38 |
waiting for the response from Ebay. This thread goes back into the thread pool and can service many other requests during the wait. |
| 39 |
This greatly reduces the number of threads needed, which in turn greatly reduces the memory requirements of the server. |
| 40 |
<p> |
| 41 |
Press reload to see even better results after JIT and TCP/IP warmup! |
| 42 |
|
| 43 |
</body> |
| 44 |
</html> |