Testing Load Balancing
Testing Load Balancing
When application traffic grows, adding resources to a single server can help temporarily but does not remove the scalability limitation. A clustered application layer with automatic load balancing distributes requests across multiple application-server instances and improves both performance and availability.
Create an Environment and Deploy the Application
- Log in to the platform dashboard and click Create environment.
- In the topology wizard, choose the required programming language and application server. The source example uses Apache PHP.
- Set the resource limits, attach a Public IP to the application server, specify an environment name such as
balancer, and click Create. - After the environment appears in the dashboard, deploy an application. The source example uses the default
HelloWorld.zippackage.
Run the Control-Point Test
The source workflow uses ApacheBench (ab) to generate HTTP load and store response-time data.
ab -n 500 -c 10 -g res1.tsv {URL_to_your_env}
res1.tsv.Change the Environment Configuration
- Return to the dashboard and open Change environment topology for the test environment.
- Increase the application-server count from one to two.
- The platform automatically enables an NGINX load balancer in front of the application servers.
- Apply the topology change and wait until it completes.
Test the Load-Balanced Configuration
Run ApacheBench again with the same request and concurrency settings, but save the result to a different file:
ab -n 500 -c 10 -g res2.tsv {URL_to_your_env}
Compare Results with Gnuplot
Start gnuplot and configure the comparison graph:
set size 1, 1 set title "Benchmark testing" set key left top set grid y set xlabel 'requests' set ylabel "response time (ms)" set datafile separator '\t'
plot "/home/res1.tsv" every ::2 using 5 title 'single server' with lines, "/home/res2.tsv" every ::2 using 5 title 'two servers with LB' with lines
Expected Result
At low load, both configurations can show similar response times. As the request count increases, the single application server’s response time rises more sharply, while two application servers behind NGINX can serve more concurrent requests with better response-time behavior.
Important Notes
- The source example uses Apache PHP and ApacheBench.
- The control test uses one application-server instance.
- The load-balanced test uses two application-server instances with NGINX.
- Both tests should use identical ApacheBench parameters.
- The documented benchmark sends 500 requests with concurrency of 10.
- Gnuplot compares
res1.tsvandres2.tsv.
