The WebObjects Adaptor includes a load balancing feature to ensure that WebObjects application requests are spread evenly across your network.
The example in this section assumes that WebObjects is installed on the computer hosting your Web server and on two other computers.
- <WebServerHost> hosts the Web server and one instance of HelloWorld.
- <FirstHost> hosts two instances of HelloWorld.
- <SecondHost> hosts one instance of HelloWorld and one instance of CyberWind.
The following instructions show you how to use Terminal.app's command window to start up the WebObjects applications, modify the WebObjects.conf configuration file, and test the results.
- From <FirstHost>, in a command window, change directories to <NeXT_Root>/NextLibrary/WebObjects/Executables and start the two HelloWorld applications by entering
./DefaultApp -p 3000 -n 1 Examples/HelloWorld
./DefaultApp -p 4000 -n 2 Examples/HelloWorld
- From <SecondHost>, in a command window, change directories to <NeXT_Root>/NextLibrary/WebObjects/Executables and start HelloWorld and CyberWind by entering
./DefaultApp -p 3000 -n 1 Examples/HelloWorld
./DefaultApp -p 4000 -n 1 CyberWind
- From <ServerHost>, in a command window, change directories to <NeXT_Root>/NextLibrary/WebObjects/Executables and start HelloWorld by entering
./DefaultApp -p 5000 -n 33 Examples/HelloWorld
- On <ServerHost>, edit the file WebObjects.conf in your Web server's cgi-bin directory to look like this
Examples/HelloWorld:1@<myHost> 3000
Examples/HelloWorld:2@<myHost> 4000
Examples/HelloWorld:1@<mySecondHost> 3000
CyberWind:1@<mySecondHost> 4000
Examples/HelloWorld:33@<myServerHost> 5000
- Using the same URL as before, try contacting your application
http://<ServerHost>/cgi-bin/WebObjects/Examples/HelloWorld
The WebObjects Adaptor will pick one of the four HelloWorld applications it knows about and try to contact it. If the application is busy serving someone else, the WebObjects Adaptor will wait. If the application died or was not started, the WebObjects Adaptor will fail the request and return its standard error message.
If your WebObjects application carries state for the client between requests, the generated HTML pages will contain the complete path to return to the exact application that served the given client in his previous request, with links such as
http://<myServerHost>/cgi-bin/WebObjects/Examples/HelloWorld:33@<myServerHost>
and no load-balancing will be performed as long as the session lasts.
If your WebObjects application does not maintain state, the application will automatically return HTML pages with links such as
http://<myServerHost>/cgi-bin/WebObjects/Examples/HelloWorld
so that the WebObjects Adaptor can perform load balancing on subsequent requests, possibly contacting a different application.
As there is a single instance of the application CyberWind, all requests for CyberWind will always go to this same application. If you experience too much traffic for this single instance, you can deploy it on other hosts as you did with HelloWorld.
The WebObjects Adaptor will contact both autostarted applications and load-balanced applications (started by hand) at all times, as long as they don't have the same names. When names conflict, the WebObjects Adaptor will pick load-balanced applications rather than any previously autostarted application.