pomarańczowy laptop

The basics of working with Amazon EC2

If you’ve heard of AWS, you’ve probably also heard of EC2. In the following article, you’ll find instructions on how to navigate it and how to unlock its capabilities. This is the first of several articles we plan to publish on this topic. To start with, I will present some important information that you should know before starting your first server.

In the following article I will present you with information about EC2 instances offered by Amazon Web Services. First of all, we need to learn what EC2 is. The abbreviation stands for Elastic Compute Cloud. EC2 instances are nothing else than virtual servers of the VPS type. They can be run on shared hardware resources or on servers dedicated exclusively to us (for which, of course, you have to pay more).

Instance types

In AWS EC2 we have several instance types.

Instance types in Amazon EC2

General Purpose – This type of instance has centred parameters and we use it when we don’t want any parameter to be dominant. Instances of this type include:

  • T2 – mainly used in small projects or as test environments. Instances of this type use the so-called CPU credits, so they should not be used in larger IT projects, because after the depletion of CPU credits their performance is reduced. For example, for a t2.micro instance, when the CPU usage is below 20%, 6 credits are accrued per hour. When the CPU usage is above 20% however, these credits are consumed. Credits are stored for up to 24 hours.
  • M5 and M4 – The latest generation of instances of this type is M5. It is well optimised for processing power, memory and network resources. M5 differs from M4 in processor power and a better optimised EBS disk. The performance of these servers is constant and is not based on CPU credits, unlike in the t2 instance type.

Compute optimised are instances optimised for computing power. These include:

  • C4 and C5 – Their high computing power make them an ideal solution for creating high-performance web servers, scientific modelling, batch processing, and distributed analysis.

Memory optimized is a type of instance created for companies for which RAM is important.

  • X1, X1e,R4 – These are used mainly for high-performance databases. The largest instance, x1e.32xlarge, has as much as 3940 GB of DDR4 RAM. It is certified by SAP to work with Business Suite S/4HANA, Business Suite on HANA (SoH), Business Warehouse on HANA (BW), and Data Mart Solutions on HANA in the AWS cloud.

GPU graphics and GPU compute are instances where GPUs play an important role.

  • G3 is GPU graphics. It provides GPUs together with high processor performance, large memory and high network speed. They are ideal for applications requiring high performance graphics acceleration, such as 3D visualization, 3D rendering, video encoding, and virtual reality.
  • P2 and P3 are GPU compute. It provides general-purpose GPUs, high processor performance, large memory and high network speed. They are recommended for compute-intensive applications such as machine learning, high-performance databases, computational fluid mechanics, financial computing, seismic analysis, fluid dynamics, molecular modelling, and genomics.

Special instances include GPU instances and FPGA instances (Accelerated Computing in the picture), which in addition to high computing power have additional instance storage, i.e. SSD drive.

  • G2 – it is the first of the above mentioned instances. In addition to having a GPU, it has additional storage in the form of SSD drives.
  • F1 – it is the second of the special instances. They offer adjustable hardware acceleration thanks to the FPGA programmable logic circuit.

Storage optimised – these are instances optimised for disk performance.

  • D2, I2, H1, H3 – ideal for applications with high I/O and storage size requirements. D2 is recommended for running large data warehouses or parallel file systems.

Before you plan your infrastructure, it is also worth knowing that not every instance type is available in every region. In some regions, there may be instances that are not on the listed site.
Remember that Amazon Web Services evolve dynamically. You may find that on the day you read this article, some of the instances mentioned are no longer available.
To be sure, it is best to check the official website https://aws.amazon.com/ec2/instance-types/ where you will find more information about each instance.

Billing methods

As I have already mentioned, Amazon EC2 brings the possibility of running servers on a shared device or on a dedicated one, which is physically separated from the devices of other customers.

AWS Pricing

Depending on the billing method for the use of instances, we distinguish the following instances:

  • On-demand – you pay for compute capacity by the second with no long-term commitments.
  • Reserved instances – they guarantee the availability of resources that we want to use. With this billing method, when the server works continuously, we save a significant amount of money compared to On-Demand pricing. In this case, we commit to use the instance for 12 or 36 months.
  • Spot instances – these are available at up to a 90% discount compared to On-Demand prices. They are run on an auction-like basis. Unfortunately, the instances of this type are not always available and Amazon can take them away at any time, giving you 2 minutes to complete your processes and save your work on the given machine. In the event that Amazon takes away your servers, you will not incur any costs for the last hour. These types of instances are well suited to, for example, processing queue jobs.
  • Dedicated instances – they run on dedicated devices used only by us which are physically separated from the devices of other customers.

AWS costs (and especially their optimisation) are a topic for a separate article. However, if you would like to estimate the costs, you can use a dedicated tool, which you can find here: https://calculator.s3.amazonaws.com/index.html.

Amazon Web Services cloud management

AWS gives us several options for managing its services. Depending on what we prefer, we can use it with: 

  • AWS Management Console, which is a browser-based GUI. This is the best solution for non-advanced users.
  • Command Line Interface (CLI), which processes commands to a computer program in the form of lines of text.
  • Software Development Kits (SDKs), a set of libraries that allow you to manage with different software languages, such as Java, Node.js, Python, PHP, C++, or the recently added Go.

Before you start creating EC2 instances

In order to create a virtual machine, a pre-configured virtual network infrastructure is required. To run an instance in EC2, it is required to configure the following:

  • VPC (Virtual Private Cloud) – allows you to create a virtual network in AWS
  • Subnet in VPC (a key component in VPC)
  • Internet Gateway in VPC (allows communication between your VPC and the internet)
  • Route table (data file in RAM that is used to store route information about directly connected and remote networks)
  • Security group (acts as a virtual firewall)
  • Network ACL (an optional layer of security for your VPC)

By default, AWS provides all of the above components, but it is good practice to create your own.

What you should pay attention to

Below I will list AWS features that you should pay attention to when creating virtual machines in EC2. These are:

  • Instance type – each instance type is designed for different environments. Please note that the T2 type should not be used in production environments due to CPU credits. Having said that, in some cases (e.g. test environments) they may be appropriate.
  • Placement Groups – thanks to this functionality your virtual machines will be in one “Availability Zone”. This ensures low latency of network communication between servers.
  • Security group – before starting the server, it is worth preparing an appropriate security group which will allow only selected network traffic (and not all of it). A security group is assigned to a given EC2 instance.
  • AMI image – a master image of the operating system for the creation of virtual servers.
  • EBS drive type – The types are General Purpose SSD (gp2), Provisioned IOPS SSD (io1), Throughput Optimised HDD (st1), Cold HDD (sc1). Before choosing a drive, consider what your needs are, IOPS or more throughput.

Follow this link for a detailed description of the parameters of each drive type: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html.

There are always a number of questions to answer before running a server. The most important of these is, what exactly will it be used for? Other important questions are e.g. “Do I need a lot of network bandwidth between other cloud servers?” or “What will the disk load look like?”. Increasing the drive size or changing the instance type will be fairly straightforward, but changing the drive type or joining “Placement Groups” can prove more problematic.

Unfortunately it is not possible to sufficiently describe all the functionalities used in EC2 in one article and you should consider reading the detailed descriptions on the Amazon AWS website. To make things easier for you, we will soon publish an article showing the process of setting up Amazon EC2.

Table of contents:
Any questions? Talk to us!