allowing tty in a Amazon EC2 instance


Fabric has been quite an unique tool to me. I encounter a few quirks that I want to share with my readers.

Users of Fabric know that in order to run the init service, you have to switch off the pty. Recently I encountered while trying to run some service on init.d on an amazon instance. It just can’t run no matter what I do. Then I realised that AWS EC2 instances require tty by default. Hence you need to switch it off before you can run your fabric commands

Here is my stackoverflow question where I ownself answer ownself. (Only Singaporeans know this :-p  )


Fdisk in fabric


One of the issues in Fabric is every command, sudo() or run() is equivalent to a new session. Hence it is difficult to do a fdisk command as you need to have an interaction.

In bash script, you overcome this problem by using a pipe. You put the inputs that you want before the | symbol so bash knows what commands to key in

So how do you translate that into a fabric command? I have been exploring around for months, trying to tinker with different ways of running fdisk. Finally I managed to come up with a working command as shown below:

sudo('echo "g\r\n\
"|fdisk /dev/xvdb' %('\n', '\n'))

Load, Loader, Locust


I recently tried out using a new load testing tool called Amazing tool. It allows you a great free will to customise your load test. Also it allows master-slave cluster setup that gives you the power to blast 100K DAU/HAU type of load if you want it.

A big thanks to Alvin Yeoh, a fellow colleague who helped me with the setup

Below are the steps on how to set up a master-slave

  1. Set up two instances, one master the other save.
  2. Install the following packages into both instances
    1. sudo yum install python27-devel.x86_64
    2. sudo yum install gcc
    3. sudo pip install locustio
    4. sudo yum install gcc-c++.noarch
    5. sudo yum install git
    6. sudo yum install mysql-devel
    7. sudo pip install MySQL-python

On your slave client run this command:

locust --slave --master-host=MASTER_IP --host=TARGET_URL

On the master client run this command:

locust --master