Install iperf on RHEL7

I use AWS and Azure all the time, it makes it very easy to spin up RHEL instances quickly, some times I need to use iperf, so here is a quick and simple way to install iperf on RHEL7

rpm -Uvh rpmforge-release-1.5.3-1.el7.rf.x86_64.rpm
yum update
yum install iperf



AWS Exam Passed

Having used AWS since it’s early days and as part of my work I get to architect solutions for customers, I felt it was time to get that stamp of recognition for the skills that I have built up over the years. Yesterday I sat the AWS Certified Solutions Architect – Associate exam and was super happy with my nice new shiny certificate,



Installing GO 1.5 on Ubuntu 15.04

Just a quick post on installing go 1.5 on Ubuntu 15.04. Here is the link to the GO downloads page

$ cd /usr/local/go

$ wget

$ tar xvzf go1.5.linux-amd64.tar.gz

$ export GOROOT=/usr/local/go

$ export PATH=$PATH:$GOROOT/bin

$ echo 'GOROOT=/usr/local/go' >> ~/.bashrc

$ echo ‘export PATH=$PATH:$GOROOT/bin’ >> ~/.bashrc

You should now have a working GO, lets check it,

$ go version

You will get something like ‘go version go1.5 linux/amd64’.

Docker 1.8

With the release of Docker 1.8 its time to install on my Ubuntu 15.04, the default package for Docker will give you version 1.5. Installing is easy you just need to subscribe to the correct repo and bingo you will get 1.8.1 or at the time you to it you may get a newer version. The following will add a key and add the correct package repository. Important! The following instruction only work for Ubuntu 15.04, with a small change to the line with  ubuntu-vivid you should be able to make this work for most Ubuntu releases.

#Lets add a repo key to our local machine
$ apt-key adv --keyserver hkp:// --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

#We need to ass the repo to our local machine, we we edit the following file (I using VIM you can use andy editor)
$ vim /etc/apt/sources.list.d/docker.list
Add or change the following line
$ deb ubuntu-vivid main

The next will remove any old docker that may be running and install the latest docker package.

$ apt-get update

$ apt-get purge lxc-docker*

$ apt-get install docker-engine

You can now do a quick version check

$ docker --version

Docker host mode for networking is cool

Docker host mode for networking is real useful, many times I need to have a container with all its container goodness but I need the same container have access to the host networking stack. This is where the magic ‘–net=host’ flag on the docker command line comes in handy. When you run a container with this flag the container will not get an isolated network stack. I have used this functionality to containerize software that normally expected to use and see the host network stack, for example OpenStack Neutron. OpenStack Neutron uses the host network namespace extensively to create software definable networking for OpenStack, by containerizing Neutron and keeping the host networking the neutron software runs happily.

You ca quickly test this this feature out,

First create a container with the above flag

#docker run --net=host -it ubuntu /bin/bash

Next do a list of the network interfaces,

#ip a

you will see the interfaces listed are the same as your host.

Speedtest Linux

Sometimes I need to check the speed of the server I am working on to the internet and often I only have a command line available. Here is a quick way to achieve this from the CLI. First we need to install the speedtest-cli software, for this I am installing on a ubuntu 15.04 desktop.

Install pip if it is not already installed
#sudo apt-get install python-pip

Next install speedtest-cli
#sudo pip install speedtest-cli

Next lets try it out

To get help 
#speedtest-cli -h

If you have a browser on you Linux desktop, you could try

Docker 1.5 is out (Time for a upgrade)

Docker 1.5 is out and it’s time to upgrade and check out the new features. Lets get the upgrade or install out of the way before we look at the new features. To upgrade, this is what I did on my Ubuntu 14.04 desktop, first make sure you do not have any containers running, shut them down safely, then do the following,

sudo apt-get update
sudo apt-get remove --purge lxc-docker #Only do this is you have docker installed already.
sudo apt-get autoremove --purge  #Only do this if ypsou have docker install all ready.
sudo apt-get install lxc-docker #This will install docker

Now we have a working docker installed, lets do a quick check to make sure it is OK and working,

sudo service docker status 
This will return the process number if docker is running, if not you will need to start docker 'service docker start', make sure their is no errors. 
sudo docker version 
This will return the version of docker

We now good to go.................

Check out the following link from the guys at Docker,

Lest have a quick look and see what is new that I find good and useful,

  • IPv6 support, much needed, good to see.
  • Read only containers.
  • Stats, O…. this is very nice, you can see resources live cpu, memory, block, networking info about you container from the CLI or API.
  • Specify a docker file to use during build.

Nice one docker team……………

Goroutines and thight loops

In Ireland we drive on the left and yield right of way for on comming traffic, forget to yeild and it’s a big mess.

Goroutines in Go also require you to yeild, forget and you also have a big mess.

The Go runtime manages threads/goroutiens  in you application. So when you use ‘go’ to create a goroutine the Go runtime will created  thread/goroutine. This thread/goroutine is not created  on or by the operating system. The Go runtime will map it’s threads/goroutines to operating system threads and schedule the for a slice of time to run.

This is why it is low cost to create and use goroutiens as they are not operating system threads. Operating system threads have to allocate memory space on the stack to hold the info during a contex switch, this is expensive, also to create a thread a system call has to be preformed, this is also expensive. One other thing here is the fact that operating system threads are preemptive, the operating system halts and saves the contex and then passes the CPU to another thread/process for it to run.

Go uses a cooperative threading model, this means that your code has to yeild so the Go runtime can give the CPU/operating thread to other goroutines to run. If your app dose no yeild then other goroutines in that application do not get time to run.

Just imagine having to write you code and pick points to yeild so other threads/goroutiens  could run. Luckily Got has figured this out and for the most part when your code is blocked wating for something  like  a response  from  a socket you have yielded or if you are wating on a channel or have called sleep you have also yielded.

With how goroutine work in our minds we can better understand that a thight loop like a for or while loop that takes a long time to finish a task that dose not block is not good.  Their is no chance for the runtime to get to schedule. You must ensure that you do not use thight loops or if you do that you provide a way for the runtime scheduler and do its job, you could just do a ‘ sleep’ now and again while in the thight loop. But it best to try to avoid thight loops completely.

So why has Go decided on this model, well its  faster because  their is no context switching. In large applications where their could be lots of threads the context switching will grind the operating system to a halt. With a go routiens  their is no context switching, no system calls  to create  or clean up threads, way less memory overhead. All this means that  goroutiens work very well for web scale applications.

For me I had to force my brain to think different when writing Go code. I always tryed to not use threads or if I did I would pool them. Now I can freely create  and use goroutiens,  this gives us a new way  to develop.

One last thing that I see people doing with goroutines is creating them and providing no way to gracefully clean up. Many Go apps use the quick kill method to shutdown their application. Unless you know what your app is doing at that point in time you could loose  data. It be better to provide a way to shutdown the goroutines gracefully.

I hope you find this useful, if you have questions please leave a comment.