Stress test your Flex application using Jmeter and EC2 - Part 2
In part 1 we discussed Jmeter configuration.
In this part, we'll go over EC2 configuration
We’ll be using Amazon’s cloud computing service (aka EC2/S3).
I’ll be assuming you already have an account with Amazon. If you don’t, create one, and save the cert-XXX.pem and pk-XXX.pem key files.
What we’d like to achieve, is a machine image (AMI) stored on S3 service, which will have Jmeter already installed. That will let us create instances of that image when needed.
- Download EC2 tools from here: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351.
- Extract ec2-api-tools.zip to some directory. I’ve installed them at /root/.ec2
- Create a ‘keys’ directory under /root/.ec2
- Install JRE>=1.5
- Export/set the following environment variables; JAVA_HOME, EC2_HOME, EC2_PRIVATE_KEY, EC2_CERT, PATH. You could simply add these to your .bashrc file:
The easiest way to create an AMI is to use an existing public one and install what you need over it.
- Select an AMI
The first step is to locate an AMI that contains the packages and services that you require. This can be one of your own AMIs or one of the public AMIs provided by Amazon EC2. Use ec2-describe-images to get a list of available AMIs, then select one of the listed AMIs and note its AMI ID, e.g. ami-4b709422 (Ubuntu 8.10 64bit).
- Generate a Keypair
This step is only required if you’ve selected one of the public AMIs provided by Amazon EC2 (which we do). A public/private keypair must be created to ensure that you, and only you, have access to the instances that you launch. ec2-create-keypair key1 – the result will be something like:
KEYPAIR key1 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
The resulting private key must be saved in a local file for later use. Create a file named key1-keypair in /root/.ec2/keys and paste into it all lines starting with the line
“-----BEGIN PRIVATE KEY-----“
and ending with the line
“-----END PRIVATE KEY-----“.
Confirm that the file contents looks exactly as shown below.
—–BEGIN RSA PRIVATE KEY—–
—–END RSA PRIVATE KEY—–
Make sure that only the owner can read & write to that file. i.e.
chmod 600 /root/.ec2/keys/key1-keypair
- Launch an instance of the AMI you selected above:
ec2-run-instances ami-4b709422 -k key1 -n 1-1 -t m1.large
the result will be something like
INSTANCE i-10a64379 ami-5bae4b32 EC2 pending key1
The instance ID in the second field of the output is a unique identifier for the instance and can be used subsequently to manipulate your instance, e.g. to terminate it.Important: Once you launch an instance, you will be billed per hour for CPU time. Make sure you terminate any instances which you don't intend to leave running indefinitely.It will take a few minutes for the instance to launch. You can follow its progress by running: ec2-describe-instances i-10a64379
RESERVATION r-fea54097 495219933132 EC2
INSTANCE i-10a64379 ami-5bae4b32 domU-12-34-31-00-00-05.usma1.compute.amazonaws.com EC2 running key1
When the status field reads “running”, the instance has been created and has started booting. There may still be a short time before it is accessible over the network, however. The DNS name displayed in the sample output above will be different from that assigned to your instance. Make sure you use the appropriate one.
- Authorize network access In order to be able to reach the running instance from the Internet, you need to enable access for the ssh service which runs on port 22:
ec2-authorize default -p 22
PERMISSION default ALLOWS tcp 22 22 FROM CIDR 0.0.0.0/0
- Connect to the instance
ssh -i /root/.ec2/keys/key1-keypair root@domU-12-34-31-00-00-05.usma1.compute.amazonaws.com
- Now you have complete control over the instance, and you better change the root password to something else.
- Upload your Amazon Web Services (AWS) private key (PK) & certificate (CERT) files to that instance.
You can use scp to do this.
scp -i /home/azeez/.ec2/keys/key1-keypair pk-XXX.pem cert-xxx.pem
root@domU-12-34-31-00-00-05.usma1.compute.amazonaws.com:/tmpThe new AMI will be encrypted and signed to ensure that it can only be accessed by you and Amazon EC2. You therefore need to upload your Amazon EC2 private key and X.509 certificate to the running instance, for use in the AMI bundling process.
Note: It is important that the key and cert files are uploaded into /tmp to prevent them being bundled with the new AMI.
- Install Java
sudo vim /etc/apt/sources.list
Ensure that the following two sources are added to the configuration file:
deb http://za.archive.ubuntu.com/ubuntu/intrepid main restricted
deb http://za.archive.ubuntu.com/ubuntu/intrepid multiverse
After the configuration file is updated, the package repository needs to updated with the following command:
sudo apt-get update
To install Java version 6, the following command needs to be executed:
sudo apt-get install sun-java6-jre
- Install Jmeter
Download and install Jmeter, and scp the scenarios you’d like to run.
- Bundle the AMI
USE THE AWS CONSOLE at
We will contact you as soon as possible.