Amazon EC2

Greg Young  |  25 September 2012

We went through the process last night of setting up Amazon EC2 nodes with the Event Store running on them. This post is a quick tutorial of how to do it.

First when setting up your node add to the security group (we did a t1.micro running ubuntu 12 to start with).

22 (SSH)

Now bring up your node. The first thing that you will need to get is mono. To do this you can just

sudo apt-get install mono-complete

You can also build trunk from sources by cloning github and doing an autogen + make however on a tiny node like a t1.micro this is probably going to take a while. You probably would want to get a large node then move the image. For building out a stable environment this is recommended as we have pushed changes to mono trunk that are not yet available outside of trunk dealing with tcp and threading issues.

After that grab the sources (or a binary distribution of the Event Store.

mkdir src
cd src
git clone git@github.com:EventStore/EventStore.git EventStore
cd EventStore
xbuild src/EventStore.sln

Now we have the EventStore built. First we need to get the IP address of the node we can get this by running ifconfig.

ubuntu@domU-12-31-39-09-48-08:~/src/EventStore$ ifconfig
eth0 Link encap:Ethernet HWaddr 12:31:39:09:48:08
inet addr:<span style="color: #ff0000;"></span> Bcast: Mask:
inet6 addr: fe80::1031:39ff:fe09:4808/64 Scope:Link
RX packets:6813 errors:0 dropped:0 overruns:0 frame:0
TX packets:5176 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:555815 (555.8 KB) TX bytes:6101901 (6.1 MB)

Let’s bring up the EventStore

mono --gc=sgen bin/eventstore/debug/anycpu/EventStore.SingleNode.exe -c 0 --ip -h 2113 -t 1113 --prefixes http://ec2-107-21-68-86.compute-1.amazonaws.com:2113/

This tells the EventStore to run on our external ip address on port 2113 for HTTP and 1113 for TCP with no cached chunks (no a lot of memory on the tiny nodes). It also tells us that “http://ec2-107-21-68-86.compute-1.amazonaws.com:2113/” is a valid prefix for HTTP requests. This is the name of your node (or an elastic ip if you are using elastic ips).

Now the EventStore is up and running. We can from home go to http://ec2-107-21-68-86.compute-1.amazonaws.com:2113/ and get the management console.

Here are some benchmarks on the node.

Single Write:

[01929,10,08:14:00.544] Write request took: 00:00:00.4987778.
[01929,10,08:14:00.554] Connection [] was closed cleanly.
[01929,01,08:14:00.555] Command exited with code 0.

5000 Writes:

[01953,12,08:16:11.695] Connection [] was closed cleanly.
[01953,01,08:16:11.696] Command exited with code 0.
[01953,12,08:16:11.696] Completed. Successes: 4976, failures: 24 (WRONG VERSION: 24, P: 0, C: 0, F: 0, D: 0)
[01953,12,08:16:11.696] 5000 requests completed in 62802ms (79.62 reqs per sec).

Single Read:

[01953,140,08:16:58.716] Read request took: 00:00:00.0091795.
[01953,140,08:16:58.716] ##teamcity[buildStatisticValue key='RD-latency-ms' value='9']
[01953,140,08:16:58.716] Connection [] was closed cleanly.
[01953,01,08:16:58.717] Command exited with code 0.

5000 Reads:

[01953,140,08:17:46.753] Completed. READS done: 5000.
[01953,140,08:17:46.753] 5000 requests completed in 7024ms (711.85 reqs per sec).

The t1.micro instance is not a very beefy instance. The benchmarks also appear to fluctuate heavily (these are from this morning, last night writes were twice as fast https://gist.github.com/3783566).  Also note that given the small data the reads were still pretty fast though they would likely get to be slower as more data was put in. However you can take the same image and bring it up on a hi1.4xlarge (high io node).

Single Write:

[01465,06,08:28:20.039] Write request took: 00:00:00.0272964.
[01465,06,08:28:20.039] Connection [] was closed cleanly.
[01465,01,08:28:20.039] Command exited with code 0.

10000 writes:

[01465,10,08:29:18.472] 10000 requests completed in 2173ms (4601.93 reqs per sec).

Single Read:

[01565,09,08:30:25.412] Read request took: 00:00:00.0017523.

Read Flood:

DONE TOTAL 100000 READS IN 00:00:03.6915271 (27089.1/s).

This is actually slower than my desktop computer (about the same as my zenbook laptop, makes you stop and think about cloud costs for a moment!). For write speed the most important determining factor is the hard drives its run on.  Overall however the amazon node performs fairly well. Also note that no optimizations were taken during this process.