Skip to content

Setting up last Poxa RELEASE in Amazon EC2 running Amazon Linux AMI

diegopau edited this page Sep 16, 2014 · 2 revisions

Very useful EC2 guide: http://khaidoan.wikidot.com/amazon-ec2

How to start! Creating the EC2 instance

AMIs & virtualization

An AMI (Amazon Machine Image) is a Operating System Image ready for using with an EC2 instance.

There are two tipes of virtualization used by the AMIs: Paravirtual (PV) & Hardware virtual machine (HVM).

Once you choose a type there is no way back: You cannot change the virtualization type of an instance or an AMI; an instance can only be resized to an instance type that supports its method of virtualization, and AMIs can only be launched on instance types that support their method of virtualization.

I recommend HVM for 2 reasons: it is said that it performs better and there are no problems on upgrading from a t2.micro to a m3.medium for example. Also AWS recommends now going for the HVM, being the only advantage of PV that PV has been much more tested (its an older type of virtualization).

INSTANCES & AMIs

You have to choose an instance and then you have to install an AMI on it. The instance is the hardware you choose and the AMI the operating system and software running on it.

For the instances we can choose t2.micro to start with the cheapest (if you have just registered in AWS you can run one t2.micro for free during a year!). Its easy to scale it in the future to bigger instances as far as we use the EBS-Backend.

There is an Amazon Linux AMI (mantained by the Amazon guys) and there are many other AMIs provided by other people / companies. Even though it could be more comfortable to start with what we now better and we use in our local machines (Ubuntu), Linux AMI is the one who is gonna better take advantage of the EC2 architecture, plus its going to be more stable and with some integrated EC2 tools in it. It is based on CentOS distribution.

EBS backed vs Instance store

With instance store volume, changes done on your EC2 instance are lost when your EC2 instance is rebooted. EBS are persistent storage volumes. Instance store volumes are non-persistent.

So, which AMI do I recommend to start with?

Amazon Linux AMI HVM EBS-Backed 64-bit (http://aws.amazon.com/amazon-linux-ami/)

General Purpose (SSD) vs Provisioned IOPS (SSD) vs Magnetic

Provisioned IOPS isn't included in the free layer. I can’t see a disadvantage of using the General Purpose SSD instead of the Magnetic (slower)

Storage size for root partition Its free upto 30 GB. But I don’t think we will need that much, and you can’t make them smaller (you can make them bigger), so it should be fine to go for the default 8 GB, should be enough.

Security Group

You set here the protocols and Ports that you allow to access to your EC2 instance. We need:

  • HTTP (port 80) allow any IP
  • HTTPS (port 443) allow any IP
  • SSH (port 22) ===> is how we access the instance to manage it. You should allow all IPs here, just the one from your local machine so you can access to the instance.
  • Custom TCP Rule (port 8080) ===> its the default port that websockets will use to open connections. (you can change it to another port using poxa config file)

Private key file

Its a .pem file that you will have to safely storage in your local machine and use each time you access your EC2 instance.

Access to your EC2 instance: setting up PuTTY (explained for windows)

First of all download it from here: http://the.earth.li/~sgtatham/putty/latest/x86/putty-0.63-installer.exe

Putty need a .ppk key file instead of the .pem file. So we open the PuTTY Key Generator (PuTTYgen.exe), click on Load, select "all files" and we search for the .pem file we downloaded from the AWS Console. Now we click on "save private key".

We open now PuTTY.

In the Host Name we enter ec2-user@public_DNS_of_our_instance
Port is 22
We go to Connection => SSH => Auth and we click on Browse to load the .ppk key file that we have just created in the last step.
We go to Session, choose a name (maybe Poxa EC2?) for our session in "Saved sessions" and we click on Save. Now we can clic on Open to connect with our instance.

Setting up Erlang and running Poxa

First go to https://github.com/edgurgel/poxa/releases to check what is the last release avaliable

Which version of Erlang do I need? ⇒ if its not specified in the name of the release you can check elixir_buildpack.config from poxa release repository. In this case we look for the requiriments of the poxa-0.3.0 release: https://github.com/edgurgel/poxa/blob/v0.3.0/elixir_buildpack.config

erlang required version is 17.0

###Installing Erlang

cd ~
sudo yum install gcc glibc-devel make ncurses-devel openssl-devel autoconf
wget http://www.erlang.org/download/otp_src_17.0.tar.gz
tar zxvf otp_src_17.0.tar.gz
cd otp_src_17.0
./configure && make && sudo make install

###Getting Poxa In the green icon of the last release (https://github.com/edgurgel/poxa/releases), right-click and "copy link address". Now in your EC2 terminal do:

cd ~
wget https://github.com/edgurgel/poxa/releases/download/v0.3.0/poxa-0.3.0.tar.gz
mkdir poxa-0.3.0
tar zxvf poxa-0.3.0.tar.gz -C poxa-0.3.0/

Now we can run poxa just doing:

cd ~
./poxa-0.3.0/bin/poxa console

But we haven't config it for our Pusher credentials and settings, we should do this first!

cd ~
nano poxa-0.3.1/releases/0.3.1/poxa.conf

# HTTP port
poxa.port = 8080

# Pusher app key
poxa.app_key = "app_key"

# Pusher secret
poxa.app_secret = "secret"

# Pusher app id
poxa.app_id = "app_id"

Now you can run poxa:

./poxa-0.3.1/bin/poxa (to get a list of commands) ./poxa-0.3.1/bin/poxa start (to run it as daemon)