Have you ever thought about hosting a WordPress site, a
backend service or a database in AWS? Then you've got a
Amazon EC2, which is perfectly suitable for you. But what
exactly is EC2 and how do you get started in AWS? We've got
this post for you to get a grasp about how it works and how
to get started!
Well, first of all - EC2 is a service that Amazon Web
Services provide to set up virtual machines on their
servers. This is called Elastic Cloud Compute (EC2). Each
virtual machine on EC2 is called an instance. Amazon
provides the option to choose between hundreds of different
instances. Therefore, the user can choose exactly what they
need and have the best possible experience.
So you have your backend API set up locally and want to have
it live in the cloud. The first thing you have to do is to
set up your EC2 Service, which is one of AWS services that
they provide and Launch an Instance.
There are tons of different Amazon Machine Image's (AMI)
which are just software templates for your virtual machine.
For simplicity, just select Ubuntu Server and you will see a bunch of Instance types - now its getting technical and you have to know the the purpose of your usage before to choose the correct one. We've got more info about how to choose the right instance on the bottom of the page
Select t2.micro which is free tier eligible and press
Launch. You'll get a Key-pair values to get the connection
possibility via a SSH client such as PuTTY. Just generate
new key-pair and include it when you SSH through PuTTY.
This time, we'll use AWS own console to connect - so we wont
need to use any keys. On your EC2 instance list you'll see
your newly created EC2 instance and when you click on the
Instance ID, you will see your connection details.
Now, let's try it out.
Click on the "Connect" - button on the top right corner and
connect to the EC2 instance through AWS online console and
you'll see the VM appear in a new tab - welcome to your
instance.
To get some simple results, we will set up a simple web
server with Ngnix Web Server in 3 simple commads.
Now when your server is up and running you will be able to
connect to it by requesting the public IP (you can find it
below the Instance command or just your EC2 instance under
"Public IPv4".
But when you request this adress, you wont get far
(yet). Because your EC2 has what's called security
group.
This is very important so you can have your EC2 instances
private or public, for different ports - and for this
purpose you want to have the HTTP inbound port active. So
we've got this part left and we're up and running.
Enter the security group and you'll see "Edit
inbound rules".
Add a new rule with these
credentials
[ Type = HTTP ] [ CIDR blocks = 0.0.0.0/0
] Which means, accept all IP's and hit "Save rule".
Now refresh your public IPv4 domain in the URL and you
will see the ngnix server running!
Well, when you are setting up your instances it can get
confusing when choosing an instance. Especially since there
are so many options to choose from. With EC2, you can choose
different mixes of RAM, CPU, storage, and network
capabilities.
If you are looking to host a small to a mid-size database,
you should consider the M1 and M3 family of EC2. These
virtual machines start from 1 CPU with 2GB Ram and go up to
8 CPUs and 30GB of RAM. These are optimal to run backend
servers for enterprise applications.
The C1 and CC2 instances are ideal if you are looking to run
CPU-intensive applications. These instances provide the
lowest cost per CPU core. Therefore, you can use a large
number of CPUs to handle applications such as web servers,
encoding, and batch processing.
If you are looking for storage optimized EC2 instances, you
should look for the HI1 and HS1. These provide extremely
high-speed storage performance and are optimal for the
deployment of large NoSQL databases such as MongoDB, as well
as Hadoop clusters. The HS1 EC2 can provide storage of up to
48TB, divided over 24 hard-drives for the best concurrent
performance.