So you decided to start using AWS as your cloud provider. Well, there are a lot of services that can be used on the go, but one of the most basic and probably the most common is Amazon EC2. In this blog, you will see the basic concepts and we’ll tell you step by step how to create EC2 instances.
We are about to start with the creation and configuration of an EC2 instance. Keep in mind that this is just the 2nd Part of our sequence of How to create a High-Performance WordPress with Autoscaling on AWS.
The complete sequence is here:
What is Amazon EC2
EC2 (Elastic Cloud Compute) is the service where you can create servers (from now on I’m going to call them instances since it’s the name used inside AWS) to launch your websites or applications.
Why Use Amazon EC2
Since there are a bunch of other providers on the network which can host your app, we choose Amazon EC2 because it offers a lot of possibilities. You can start with a small instance and then when you get more traffic, grow it up to a bigger option; making EC2 more flexible and adaptable than other technologies to host your application.
It is easy to increase your hard drive size in case that you need to store more code or images for your app. Without mentioning that you are two clicks away to start using the load balancer on AWS, considering that you just literally have to select your load balancer and add an instance to it. The thing is that most of the common hosting users are afraid of how much AWS would cost, but considering its capacity and flexibility, your application will be in good hands on AWS.
AWS has more time on the market, so the services have been improved since it started, refining them every year for better user experience and technology innovation. All of these reasons made AWS the top provider chosen by millions of companies around the globe.
EC2 Instance Types
One of the first things that you are going to find when you try to create your first EC2 instance, is the instance type/size. There are several options to choose for each kind of workload that you want to do.
General Purpose EC2 Instance
This kind of instances are used the most for testing purposes. General purpose instances are divided into “T” and “M” varieties.
“T” instances are targeted to simple jobs just like testing environments, and they have a modest networking on the most basic options. So in general, they are not your choice if you want a production environment. On the other hand, if you are taking the option for your dev or staging environments, you should give them a try.
“M” Instances are for general use when you don’t want a testing environment, but you want an all-purpose instance. They offer more balanced resources compared to “T” instance, so if you are looking for an instance for your production environment and you don’t want to worry a lot about the resources, “M” instance is what you are looking for.
Note: “T and M” instances offer two types of virtualization; PV and HVM. The first was the one provided by AWS in the past, and it’s available on t1 and m1 instance types. I wouldn’t recommend it because you can’t take advantage of all the hardware, and in some cases are a bit slower.
Another restriction is that you are going to be able to increase your instance type to instances only based on PV, and the newer instance types are not going to be available. My suggestion is always to use HVM instances.
If your application requires to process a lot of information like math operations, load balancing, rendering task or sometimes video encoding, you need an instance that can process all that information in less time. “C” instance is your ally in this stressful operation since it has more CPUs capacity and lower RAM.
If your app doesn’t require too much CPU, but instead, it needs more and faster RAM; you should check out the available option on the “X1e, X1 and R” instances.
“X1e” instances are targeted for high-performance databases or in RAM application, but it’s commonly used just by enterprise applications. This instance (x1e.32xlarge) type has an option with almost 4TB of RAM, and it’s certified by SAP to be used with the Business Suite S/HANA.
“X1”, like “X1e”, is targeted to enterprise applications but that require fewer resources, but they are also a pretty good option for Big Data operations and high-performance computing but instead “X1e” options we only have two options to choose with “X1” instances.
“R4” instances are the new generation of “R” instances, an excellent choice for data mining and data analysis and in memory applications such as databases, they have more accessible options with resources that a common user can choose.
“R3” instances are the old generation of the “R” instances, and compared with “R4” are expensive, so if you are considering this option, you better choose “R4”.
Creating a movie and need to render the textures? Need to design with power? Or you just have money to spend and want to play games on streaming? If you feel identified, P and G instances are what you are looking for, all these instances have their own NVIDIA Graphics card and vary the amount of GPU that they have depending on the instance size.
“P2” it’s a “general” purpose instance, but the older version of the “P” instances are more accessible compared with the new ones offer the power that you need for data science, data analysis, and rendering power.
“P3”, the latest version of the “P” instances, offer more power with its NVIDIA Tesla V100. Like the “P2”, this is an excellent option for data analysis, but it’s also going to be incredible at speech recognition and for autonomous vehicles.
“G3” instances are perfect for creating your remote graphics station, the best option for 3D rendering, video encoding or application streaming (yes you can stream an application which requires too many resources, even run a game and stream it to your laptop).
This Kind of instances are provisioned with a more significant amount of TB for storage, and you are going to have the best I/O Performance. These instances are a great option for those databases that need to be writing regularly on the disk, here we have three groups of instances: H, I and D.
“H” instances are the best option for distributed file systems or centralized log processing.
“I” instances are also a great choice for databases especially for NoSQL or data warehouse
“D” instances similar to H ones but offer better performance for Massive Parallel Processing data warehousing and distributed computing like Hadoop and MapReduce.
These are all the available instance types and some of their uses I hope with this little explanation it’s easier to you to choose from one or another.
What’s An AMI
AMI it’s the acronym for Amazon Machine Image. Pretty clear right? I don’t think so. To make this a bit easier to understand, I’ll give you an example.
If you have worked with old computers or even with physical servers, you probably know that you need to update or install the same stack on more than three devices. This is done by using tools like Norton Ghost or Acronis True Image to create disk snapshots which let you take a picture of the current state of the disk to load it on the other devices in less time, compared to doing it manually.
Well, an AMI has the same idea, but it is a combination of multiple snapshots. This means that if the instance has more that one disk the AMI it’s going to contain the other disks.
That’s the theory, but you also have to know that all the OS
offered by AWS are packed as an AMI so that you can find empty images with Ubuntu, Fedora, Centos, RedHat, Amazon Linux, even with Windows Server.
There are other AMI’s options on the marketplace with preinstalled software like LAMP and LEMP stacks, Redis optimized or hardened software to launch your brand new instances. But be careful my friend, some of those marketplace AMI are not only smiled, some of them include a fee per hour for you to use it (plus the cost per hour of the instance). So, if you want to choose an AMI from the AWS Marketplace check the prices of it.
Note: To Use some of the instances you need to accept an agreement, sometimes you are going to be redirected to the AWS Marketplace to take it and, in other cases, you will have to access the marketplace to accept it.