| | |
|
|
|
Zero Socket Opener
The zero.management.zso extension enables the Java runtime which is hosting a Zero application to be started on demand when a client connects to the application. The Zero Socket Opener, or ZSO, works in a similar way to inetd. It opens a listening socket and when a client connects to that listening port the Zero application associated with that port is started to accept the connection.
The ZSO is currently only available on Linux systems.
Objectives
The goal of the zero.management.zso extension is to allow many applications to be available and ready for client connections, while at the same time releasing the resources for applications which are not currently in use. The runtime memory requirements of a ZSO process is smaller than required by a running Java runtime. The advantages of using ZSO include:
- Allowing an application to be available for connections, without permanently using the resources required by the Java runtime.
- Starting the Java runtime hosted Zero applications on demand, when a connection is initiated by a client.
- Allowing tens or hundreds of Zero applications to be available, while those applications not in use consume almost no resources.
- Enforcing the short lived runtime lifecycle of a Zero application.
Adding zero.management.zso to your application
You must resolve a dependency in order to add zero.management.zso to your application. Start by adding the following line to the dependencies element in your config/ivy.xml file:
<dependency org="zero" name="zero.management.zso" rev="1.0+"/>
If you're using Eclipse, then the dependency is automatically resolved when you save the modified ivy.xml file. Steps to resolve from the command line are outlined on the dependencies page.
Setting the idle timeout or the maximum requests parameters
When the ZSO starts, it will open a socket listener and wait for an incoming connection. When a client does connect, it will start the Java runtime which will host the Zero application. Once the Java runtime is started, it will stay running and will respond to all connections, bypassing the ZSO process.
In order to really take advantage of the ZSO, the Zero application must be configured to shutdown the Java runtime, to release resources and to allow control of the open socket back to the ZSO process. This can be done by either setting an idle timeout or a maximum request configuration parameter.
Idle Timeout
The idle timeout allows the Java runtime of a Zero application to be stopped whenever there is an idle period when the application is not servicing requests. For example, if the idle time is 60 seconds then the application will shut down if there are no incoming client connections after a period of 60 seconds.
The idle timeout can be set by adding the following to the zero.config of the application:
/config/idleTimeout=60
The unit is in seconds since last completed connection.
Maximum Requests
The maximum requests parameter allows the Java runtime to be stopped whenever the total number of requests processed by the application has been reached. Once the maximum number of requests have been reached, the Java runtime will be stopped, and control will pass back to the ZSO process.
When the maximum number has been reached, all current requests that have entered processing will be allowed to complete and all new requests received will be queued by the socket listener. If the server is currently being flooded with many requests, the Java runtime will be halted. In this case, the ZSO process will see that there are still requests to be processed and the Java runtime will be restarted.
The maximum request parameter can be set by adding the following to the zero.config of the application:
/config/maxRequests=100
This will cause the Java runtime to stop after servicing 100 connections.
Starting and stopping the ZSO process
Once the zero.management.zso dependency has been added to your application, the ZSO process can be started with the following command from the root of your application:
zero startzso
The ZSO process will be started in the background and the application will behave exactly as if the application was started with the zero start command from the management command line extensions.
To stop the application and the ZSO process, use the stop command from the management CLI extensions:
zero stop
|
r5 - 22 Feb 2008 - 19:49:31 - jason
|
|
|
| | |
|