A service instance is an executing instance of a service. There can be many instances of a service at any one time. Service instances are created by service instance managers.
Service instances can be started either before or when they are assigned to a session. They can stay running to compute multiple tasks of the same session to use the data and state information cached in memory for better performance. They can either exit or continue running when their serviced session is finished.
A service is transient if the service instances start and exit per session. A service is persistent if the service instances stay and serve multiple sessions. A persistent service is a long-running process like a daemon, which has to be more carefully programmed to avoid any accumulated problems such as memory leaks.
By default, the service instances in Symphony persist for multiple sessions. To make a service instance transient, you can return a control code from onSessionLeave() to tell Symphony to restart the service instance once it leaves the current session. This can also be used when you want to clean up any accumulated problems by restarting your service from time to time.
The service instance lifecycle can be affected by different configured timeouts. If an application has timeouts configured, then Symphony will take action if an operation exceeds the configured timeout. In this case, Symphony terminates the service instance, causing the cleanup methods not to execute under the following circumstances:
As a best practice, you should configure a timeout for the onCreateService() method if you believe that it may be hanging, otherwise some sessions may become under-allocated.
To verify if the method is hanging:
Run soamview resource to show that the resource is assigned to the session.
Run soamview session -a to show that the session deserves the resource but the resource is not assigned to it. Note that it is reasonable for the number or deserved resources and the number of assigned resources to be out-of-synch for some time (they will be out-of-synch while onCreateService() is executing); if their values do not seem to be converging after periodically monitoring them, you should suspect that the method is hanging.