[For AWS beginners] Easy to understand in 5 minutes! Amazon EC2
Hello!
This is Inoue, a Persian cat from Beyond Shikoku Office.
I would like to give you a quick explanation of [EC2], which is one of the Amazon Web Services,
What is [EC2]?
EC2 is an abbreviation for "Elastic Compute Cloud".
It is a service that provides computing capacity, and to put it simply, it is a service that allows you to rent everything you need for a server in the cloud.
You can flexibly choose hardware configurations and OS combinations, making construction easy.
EC2 is an unmanaged service. AWS will be in charge of operating the servers and network, but you will need to operate all the software you install, including the OS.
The advantages of creating a server with EC2 are
- You can easily create one from the management console with a single button.
- Just choose your AMI and instance type.
- No initial cost required. (There is no cost until the instance is running)
- There are many instance types available and you can choose the one that suits your needs.
- It can be integrated with other AWS services.
- Virtualization technology makes it easy to take backups.
- Since it's in the cloud, you can access it from anywhere.
- You can choose the region and availability zone to prepare for failures and disasters.
etc. can be mentioned.
■Main functions of EC2
item | Content |
instance | A virtual server created in the AWS cloud. In EC2, servers with the same configuration can be created many times from an AMI, so the created servers are called instances. |
AMI | A virtual image. (Machine image) Something like a mold from which an instance is created. A variety of AMIs are available, from simple ones that only include the OS to those that include all the software settings. |
key pair | The key used for authentication when connecting to an instance. |
EBS | Storage available within the AWS cloud. Used as storage for the instance. |
security group | virtual firewall. Control traffic for one or more instances. |
Elastic IP | Static (fixed) IPv4 address. *IPv4 address is a number that identifies the communication partner (host). The same IP address cannot exist on the Internet. |
[EC2] price
■Free frame * Reference from AWS official website
Includes 750 hours of Linux and Windows t2.micro instances (t3.micro in regions where t2.micro is not available) for 750 hours each month for one year. To keep your usage within the free tier, use only EC2 micro instances.
■
Depending on the instance you run on-demand, charges are incurred on an hourly or second-by-second basis. Recommended if you want to take advantage of the low costs and flexibility of EC2 without having to pay upfront or commit to a long-term contract.
Ideal for applications that cannot be interrupted due to spikes or unexpected workloads. If you are using EC2 for development or testing for the first time, you should choose on-demand.
■Prices are discounted compared to Reserved On-
Applications with constant or predictable usage can be cheaper to operate than on-demand.
Recommended for applications that are used regularly or require capacity reservations. However, the condition is that you can use Reserved Instances by paying in advance if you can commit to using them for a long period of time (1 to 3 years).
If the number of instances you run in any given hour exceeds the number of applicable Reserved Instances you have, On-Demand pricing will apply.
■
This is an instance with a larger maximum discount than Spot Reserved. You can flexibly respond by increasing the number of instances during times of high load or decreasing instances during times of low load.
This is a style where you buy and operate the necessary instances when you need them, like an auction.
It can be used in a variety of applications that are stateless, fault-tolerant, or flexible.
What is a machine image [AMI]?
AMI is an abbreviation for "Amazon Machine Image".
This is a template that records the software configuration. It is like a mold for creating instances, and the advantage is that once you prepare the mold, you can create multiple servers with the same settings.
Being able to create multiple servers with the same settings is convenient when you want to have multiple servers with the same settings, and it is also easy to create and destroy.
If there was no AMI, you would have to enter the settings for each server one by one, which would be a hassle, but with the AMI, that hassle is saved and you can duplicate servers with the same settings.
An AMI contains the entire contents of a server's disk. When you create an instance from an AMI, everything is copied. Therefore, any AMI always includes an OS.
Please note that it is not possible to write only Wordpress or only some data.
What is an instance type?
Instance type refers to the purpose of the machine.
CPU, memory, storage, network capacity, etc. are combined depending on the application. In other words, choose the performance of the server machine.
■Main instance types
EC2 instance type details
Purpose | instance type | Content |
General purpose | T2, T3, M5, M4 etc. | General server. Use when the load on the server is constant. |
computing optimization | C5, C4 etc. | A server with high computational capabilities. |
memory optimization | X1e, X1 etc. | A server with improved memory access speed. |
R4 | A server equipped with large capacity memory. | |
high speed computing | P3, P2, G3, F1 | Types equipped with GPUs that can be used for machine learning, etc., and types with high graphic capabilities. |
storage optimization | H1, l3, D2 etc. | A storage-optimized type. |
For example, instance type "T2" has
Seven sizes are available: "nano", "micro", "small", "medium", "xlarge", and "2xlarge". Therefore, you can choose the instance size according to your scale.
The instance type is selected based on the general purpose, and
the instance size is selected based on performance such as CPU and installed memory capacity.
Prices vary depending on the instance type and instance size, and the basic price is the unit price x usage time.
What is EBS?
EBS stands for "Elastic Block Store".
A persistent block storage volume used in conjunction with EC2 instances. A block storage volume is a method of storing data in blocks of bytes, and is a common method for storing data on disk.
EBS allows you to choose between HDD and SSD.
Regarding the difference between HDD and SSD, HDD supports large capacity and is cheaper than SSD, but the read/write speed is lower than SSD. It is also weak against shock.
Although SSDs are more expensive than HDDs, they have high IOPS and are resistant to shocks.
*IOPS is the number of inputs and outputs that can be processed per second.
Therefore, if you are looking for higher performance but are more expensive, we recommend SSD, and if you are not concerned about high performance and want to keep costs down and operate at low cost, we recommend HDD.
■Useful functions of EBS
elastic volume | A function that allows you to easily adjust the volume level You can adjust the volume settings according to the usage situation. Volume changes can be performed without downtime or affecting system operation. When disk usage increases, you can automatically expand volumes and file systems without downtime by setting them in advance. Changing the volume can be done easily on the console. You can dynamically change settings by simply specifying the expanded capacity from the AWS console or CLI. If you need to process 10 times more traffic than usual for a set period every month, you can use elastic volumes to set IOPS high for that period, and then return it to the original level when the traffic is finished processing. . |
snapshot | A function to save the entire data at the time of saving |
data lifecycle manager | Ability to create and delete snapshots according to schedule |
optimization instance | Ability to make certain instance types into optimized instances to speed up reading and writing. |
encryption | Ability to encrypt data volumes, boot volumes, and snapshots. You can use the function to create and manage encryption keys. |
As mentioned at the beginning, EBS is used in conjunction with EC2 instances.
The basic configuration is to store all EC2 data in EBS. Although data can be stored in EC2, the saved data will be lost if EC2 is stopped, so we use EBS, which is a persistent block storage volume that does not lose data even if EC2 is stopped. .
EBS-optimized instances refer to minimizing contention between EBS I/O and traffic from other EC2 instances and providing high performance for EBS volumes.
Separate the networks connecting EC2 and EBS and connect them to EC2 using a network path dedicated to EBS.
What is a snapshot?
A snapshot is simply a backup.
A file or folder that stores the entire disk state of a server at a certain point in time. Since the entire file is saved, it includes not only data and software, but also everything such as the OS and setting information.
EBS snapshots are stored in S3. Therefore, S3 fees will be charged for the period that snapshots are retained.
*Please read the previous blog about S3.
[For AWS beginners] Easy to understand! What is Amazon S3?
Snapshots are often taken as backups when updating software or the OS so that you can quickly restore them in case something goes wrong, but they are also used in AWS to create your own AMIs.
AWS allows you to save data on EBS volumes as snapshots.
However, the first snapshot is saved in its entirety, but subsequent snapshots are saved as incremental backups. This is a mechanism that saves you money on snapshots by reducing the amount of time it takes to create a snapshot and by not duplicating data.
Therefore, deleting a snapshot only deletes data specific to that snapshot. This is the same for the first data; the differences between the second data are looked at and only the parts unique to the first data are removed.
Snapshots are created by selecting each volume from the management console. If you create an EBS volume based on this created snapshot, the new volume will be a copy of the original volume.
If you want to create an AWI, create it from a snapshot. Furthermore, by using the data cycle manager, the creation and deletion of snapshots can be automated.
By creating snapshots regularly, you can prevent the risk of server failure.
If you take regular EBS snapshots, you can create an AMI image and clone a new instance if you want to make a copy of your instance.
Finally
For this blog, I learned from this book.
Easy to understand in 5 minutes! I wanted to write a blog about [EC2], so I'll end it here. I would like to write about ELB as a sequel to this blog.
Thank you for reading to the end.
Growing every day, moving forward every day.
I have to update myself every day! ! !
Thank you for reading to the end.