php script to get server details ( details.php )
<html> <body> <?php echo $_SERVER['SERVER_ADDR']; ?> </body> </html>
Place this in the s3 bucket and mention the same in below bootstrapping script.
aws ec2 bootstrapping script
#!/bin/bash yum install httpd php -y yum update -y aws s3 cp --recursive s3://YOUR_BUCKET_NAME /var/www/html/ service httpd start chkconfig httpd on
This runs the apache and pulls out the details.php file and placed in the apache public folder which is
When starting the instances make sure you place one instance in zone-a and another two in zone-b
|Instance private ip||AZ zone|
Now attach these instances to ELB say
myelb-2041804452.ap-south-1.elb.amazonaws.com is the DNS name generated.
Now disable the cross zone load balancing and hit the below url
myelb-2041804452.ap-south-1.elb.amazonaws.com/details.php in three browser instances and observe the ip address echoed on console.
Here the requests are not routed to all instances equally.
Now enable the cross zone load balancing and hit the same above url and check the console. This time you will see requests hit equally to all the nodes.