Benchmarking with Bees with Machine Guns

The last week or so I've been stress testing/optimising various services using Bees with Machine Guns. If you've not heard of it before, the repo adequately describes it as:

A utility for arming (creating) many bees (micro EC2 instances) to attack (load test) targets (web applications).

This is partly just notes for myself as well as a tutorial on how to get things set up and running.

Set Up

Before you start you'll need install the tool installed, instructions on getting this can be found on the repository page

Setting up your boto file

You'll need to create a .boto file in your home directory. This file will contain both your AWS user conditionals (you may need to get an admin to create these for you or if you have admin privileges you can create them for each user here) and the regional settings you want to spawn the servers in.

your .boto should look like the following:

aws_access_key_id = <Access Key ID>  
aws_secret_access_key = <Secret Access Key>

ec2_region_name = eu-west-1c  
ec2_region_endpoint =  
  • aws_access_key_id & aws_secret_access_key: This should be generated by AWS in Security Credentials console for the user that is setting it up
  • ec2_region_name: This is the name of the region that you want to create the servers in. A list can be found here
  • ec2_region_endpoint: This is the URI of the region end point. A list can be found here

Bees up

To start your bee servers you can type the following command (replacing the chevrons with your settings):

$ bees up -s <number of servers> -g <EC2 security group> -k <ssh key pare> -z <region name> -i <AMI ID> -l <ssh user>
  • number of servers: This should be a number and will be limited to the amount of servers you have available in EC2
  • EC2 security group: You'll need to create this in EC2 make sure SSL (port 22) is accessible. Also make sure that VPC is set to No VPC
  • ssh key pare: You can create this though the EC2 console under Key Pairs. The key will also need to be added to your ssh agent
  • region name: This should be the same as the one you set in your bota
  • AMI ID: You need to provide a AMI ID for the servers to use, this can something you can make or you can search for a community one. The best way I have found for searching is by lunching a new instance and using the "Community AMIs" panel to search.
  • ssh user: This will vary depending on your AMI but should be based on the root user for the server

This is an example of a full bees up command:

$ bees up -s 10 -g bees -k samstefan -z eu-west-1c -i ami-67212413 -l ec2-user


The bees attack command looks like the following (replacing the chevrons with your settings):

$ bees attack -n <number of requests> -c <number of concurrent requests> -u <target URI>
  • number of requests & number of concurrent requests: These should should not be set anything else than 1 request per server. I've found setting this too low can cause errors.
  • target URI: This is the end point you want to hit with the bees, I've found that it doesn't seem to pass more than one query parameter if you're using a http url. It's worth setting up access logs on the server you're testing to make sure the urls are correctly constructed.

This is an example of a full bees attack command:

$ bees attack -n 100 -c 100 -u ''


  • Sometimes it take a while for the server to become fully available despite bees reporting that they are. If you can ssh into them then generally they are good to go.