Broadcast on Broadcast off
The Documentation for Project Zero has moved. Please update your bookmarks to: http://www.projectzero.org/documentation/
Table of
Contents...
Hide

Project Zero Developer’s Guide

Concepts and components
Basic concepts overview
Event processing
Writing Java handlers
Writing Groovy handlers
Firing events
Global Context
Global Context reference
Application directory layout
Virtualized directories
Assemble
PHP
Features and configuration
Configuration
Debugging
Dependencies
Packaging
Application classpath
Logging and tracing
RESTful resources
RESTful documentation
File serving
Response rendering
Validators and validation
HTTP error handling
Calling a remote resource
Using the Connection API
Sending an email using EmailConnection
Configuring destinations
Configuring protocols
Configuring connection handlers
Creating a connection handler
Creating a custom protocol transport
Simple logging connection handlers
Protocol reference
Client programming with Dojo
Runtime options
Deployment modifications
HTTP configuration
SSL configuration
Proxy configuration
Extending the CLI
Security considerations
Authentication
OpenID authentication
Extending security
Security tokens
CSRF prevention support
Extending token support
Leveraging TAI
User service
File based user service
LDAP user service
Extending user service
Security Utilities
Leveraging XOREncoder
Extensions
Atom support
RSS support
JSON support
XMLEncoder
REST to SOAP extension
URIUtils
Developer Web tools
Database setup tools
Configuring data access
Common query patterns
Advanced query patterns
Update patterns
Local database transactions
Extending data access
Configuration vendor differences
PHP data access
Resource model
Configuring ZRM
Resource model declaration
Programmatic model API
HTTP REST API
A ZRM mini tutorial
Active content filtering support
Default filters
Custom filters
Runtime management
Management commands
Zero socket opener
Other extension modules
Amazon E-commerce service
Flickr service
WeatherZero forecast service
Wikipedia service
Reference
Zero command line interface
JavaDoc - Public API
JavaDoc - Public SPI
JavaDoc - All Classes

 

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
Syndicate this site RSS ATOM
Copyright 2007 © IBM Corporation | Privacy | Terms of Use | About this site