Monday, 14 December 2015

Microscaling on Azure - a walkthrough

Our instructions for Microscaling-in-a-Box focus on you running the containers to be scaled on your local machine, but of course you can spin the containers up and down on any machine you like, including a cloud-based virtual machine.

If you've been living under a rock you might not be aware that you can run Linux machines in Microsoft's Azure cloud.  Microsoft have generously given us some Azure credits, so we decided to give it a whirl and try out Microscaling-in-a-Box on the system.  Here's a walk-through using the new 'Portal' UI for Azure.

Installing Ubuntu machines on Azure

Pick Virtual Machines from the list of resources on the left, and click Add.  You can then pick your Linux - we're going for Ubuntu 14.04.



Azure walks you through setting up the basic settings like a machine name, and a username & password or key pair for an admin user.  In step 2 you'll pick the machine size - we've gone for the recommended DS1.



The wizard walks you through picking some additional features for your machine which are all all pretty straightforward. 





Once you're happy with the settings you'll be taken back to the Azure portal dashboard while the machine is provisioned.  When the machine is ready you'll be able to see its public IP address, which you can SSH into using the credentials you set up earlier.

ssh <username>@<ip address>

Install Docker

Now you can follow the instructions to install Docker on a Linux machine.  Here's a summary of the steps you need for a new Ubuntu 14.04 installation like the one we just created.


sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Edit the list of apt repositories ...
sudo vi /etc/apt/sources.list.d/docker.list
...and add the following line: 
deb https://apt.dockerproject.org/repo ubuntu-trusty main

...so that apt knows where to get Docker from.  Just a few more things to install. 

sudo apt-get update

sudo apt-cache policy docker-engine

sudo apt-get install linux-image-extra-$(uname -r)

sudo apt-get install docker-engine
Now we're ready to start Docker:
sudo service docker start
Test that the installation is up and running:
sudo docker run hello-world

Run Microscaling-in-a-box

You'll need to log in to Microscaling-in-a-box so that you have a user ID. Skip straight to step 3.

You'll need to prefix this command with 'sudo' (or you can configure your user as a member of the 'docker' group, as described on Docker's instructions for Ubuntu.)

sudo docker run -e "F12_USER_ID=<your ID>" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -it force12io/force12:latest
VoilĂ  - microscaling on Azure!

Not ready to send metrics

But wait... why do we keep seeing "Not ready to send metrics" in the Force12 logs? Our microscaling agent uses a web socket to send messages to the Force12 server, and it only allows one message to be outstanding at a time. When its timer pops every 500ms, it checks to see if a previous message is still being sent, and logs that message if so.  (You can see the code for this on GitHub.)

Run Force12 natively

Through experimentation we've discovered that performance improves significantly if we run the Force12 executable natively rather than inside a container.  

Clone the Force12 agent and build it as an executable for running on Linux.

GOOS=linux go build .

Copy the resulting force12 executable to the Azure machine if you didn't build it there, and then run it as follows.

sudo F12_USER_ID=<your user ID> ./force12

Our hunch is that there are issues with calling the Docker Remote API from within a container - if you've seen similar issues we'd love to hear about it! 

Next steps

There are two things we'll be doing next:
  • We've got some suspicions about performance - we'll be investigating and reporting back soon! Edit: updated with information about running the Force12 executable natively rather than in a container
  • We're also experimenting with running microscaling on the new Windows Containers on Windows Server 2016