Load Balancing an Application Using an AppSpace
This process demonstrates the concept of an AppSpace for scaling an application.
Before you begin
- TIBCO Enterprise Message must be running.
- To run this sample, you can either use TIBCO ActiveMatrix BusinessWorks™ 6.x client or ActiveMatrix BusinessWorks™ 5.x as a client.
- PostgreSQL Database should be installed and running on the machine. Create tables by using the related scripts for the engine database.
- Sample uses default queue - 'queue.sample' of EMS server running on localhost.
- Procedure
- In a terminal, navigate to TIBCO_HOME\bw\n.n\bin and type bwadmin.
- Create a Domain, AppSpace and AppNode:
bwadmin[admin]> create domain MyDomain bwadmin[admin]> cd MyDomain bwadmin[admin@MyDomain]> create appspace MyAppSpace bwadmin[admin@MyDomain]> cd MyAppSpace bwadmin[admin@MyDomain/MyAppSpace]> create –httpPort 9999 appnode MyAppNode
- Copy TIBCO_HOME\bw\n.n\config\appspace_config.ini_template to a temporary location.
- Rename the
appspace_config.ini_template file to
config.ini.
- Uncomment the following property and change the value to group.
bw.engine.persistenceMode=group
- Set the datastore configuration with values similar to:
# BW Engine Database Driver. bw.engine.db.jdbcDriver=org.postgresql.Driver # BW Engine Database URL. bw.engine.db.url=jdbc:postgresql://localhost:5432/postgres1 # BW Engine Database User Name. bw.engine.db.userName=postgres # BW Engine Database User Password. bw.engine.db.password=root # BW Engine Database Connection Pool Size. bw.engine.db.maxConnections=10
- Save the
config.ini file.
For the JMS Receive Message activity, load balancing is done by setting Max Jobs limit and the flow limit. If one instance is down, the other instance processes the messages. Thus avoiding any outage. For the HTTP Receiver activity, load balancing is done at the external load balancer level. If one instance is down, all requests are sent to the other instance. However, when you use load balancing with fault tolerance, a database is required.
- Uncomment the following property and change the value to group.
- Push the configuration to the AppSpace running the following command in the bwadmin terminal:
bwadmin[admin@MyDomain/MyAppSpace]> config -cf <temporary_location>/config.ini - In the bwadmin terminal, upload and deploy the EAR file into the AppSpace:
bwadmin[admin@MyDomain/MyAppSpace]>upload TIBCO_HOME\bw\x.x\samples\AppSpace\core\admin\ears\samples\tibco.bw.sample.core.scalability.LoadBalancingUsingAppSpace.application_1.0.0.ear
bwadmin[admin@MyDomain/MyAppSpace]> deploy -as tibco.bw.sample.core.scalability.LoadBalancingUsingAppSpace.application_1.0.0.ear
- Start the AppSpace using the following command:
bwadmin[admin@MyDomain/MyAppSpace]> start appspace MyAppSpace
- Start TIBCO Designer and click New Empty Project.
- Click and import the client project, TIBCO_HOME\bw\n.n\samples\core\scalability\LoadBalancingUsingAppSpace\bw5\tibco.bw.sample.core.scalability.LoadBalancingUsingAppSpace.client.
- Update the JMS shared resource configuration and verify the Host and Port values.
- In TIBCO Designer, click . Wait for 30 seconds before completing the next steps.
- In the bwadmin terminal, create a second AppNode in MyAppSpace. Run the create command to create the AppNode and then the start command to start the AppNode:
The TIBCO ActiveMatrix BusinessWorks™ JMS application should be deployed to
MySecondAppNodeautomatically by the AppSpace.bwadmin[admin@MyDomain/MyAppSpace]> create –httpPort 9996 appnode MySecondAppNode bwadmin[admin@MyDomain/MyAppSpace]> start appnode MySecondAppNode
- Open the bwappnode.log files on each node located under <DomainLocation>/<appnodes>/<appspace>/<nodename>/log [Example: <DomainLocation>/appnodes/betaappspace/betaappnode1/log] and monitor the messages flow.
- Stop the second AppNode using the following command:
bwadmin[admin@MyDomain/MyAppSpace]> stop appnode MySecondAppNode
Setup the Domain
Create the config.ini File
Configure and Start the Client
Create a Second AppNode
Result
Before stopping the second AppNode, the application is active on both the nodes. After stopping the second AppNode, the application is active only on the first AppNode. See the bwappnode.log file to monitor the messages processed by AppNode1.