6.5 Multiple Kernel Pools
For some applications, it is useful to use several pools of Mathematica kernels to serve different requests. You can configure the kernels in each pool differently, perhaps with different timeout parameters or different initialization files. Another possibility would be to use a pool with one Mathematica kernel as a demonstration server and another pool with four Mathematica kernels to serve customer requests. This would ensure that the customers received priority. Another benefit of multiple pools is the guarantee that one set of computations is completely isolated from another. Disadvantages, however, are the additional administration and the need for extra webMathematica licenses.
Whenever webMathematica is launched, there is always one pool created, called the General pool. If you wish to configure for additional pools, add a KernelPools statement to the MSP.conf file, as shown below.
This specifies two additional pools, called Examples and Test. The system will look for the configuration files Examples.conf and Test.conf in the same directory as MSP.conf. In these configuration files, you can modify many of the parameters set in the main file. Any values that are not set will take their values from MSP.conf. If the pool-specific configuration file is missing, all of the values will be taken from MSP.conf. The documentation on MSP.conf describes the configuration parameters that can be placed in these files.
If you wish to work with multiple pools, you need to have webMathematica licenses for all the kernels you wish to run. The Kernel Monitor contains information on all of the pools, so this is a good place to confirm that a pool has been properly initialized. The servlet log files also contain information about each pool, as the section on Logging describes.
6.5.1 Mapping JSPs to Pools
The JSP custom tag msp:allocateKernel is used to allocate Mathematica kernels. The pool that it uses to obtain a kernel is determined by the available pools and the name of the JSP. This is set by the MSP.conf setting of PoolPath, which maps the directories of JSPs to pools. An example is shown below.
In this example there are two kernel pools, Examples and Test. JSPs that are found in or beneath the top-level directory, ExampleDir, will use the Examples pool and those in the directory TestDir will use the pool Test. Other JSPs will use the General pool. For example, http://host/webMathematica/ExampleDir/Files/Work.jsp, which refers to the file webMathematica/ExampleDir/Files/Work.jsp, will use the Examples pool.
6.5.2 Multiple Web Applications
Yet another way to divide requests is to install multiple web applications. This might be beneficial if your server provides special configuration tools for web applications. For this you would repeat the installation process for the webMathematica web application, giving each new installation a different name. All web applications run in a common instance of the Java Virtual Machine will share the same kernel monitor.