How to Create EC2 Instance in AWS?
Overview
Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing power which helps users to create and release apps more quickly by saving cost over hardware.
Using Amazon EC2, users may launch as many (or) as few virtual servers according to their need, configure networking and security settings, and manage storage. A user can scale up (or) down with Amazon EC2 to handle variations in demand or popularity spikes, eliminating the need to predict traffic.
What is Amazon EC2 Instance?
Elastic Compute Cloud abbreviated as EC2. An EC2 instance is merely a virtual server in the language of Amazon Web Services.This web service enables AWS customers to inquire about and set up compute servers within the AWS cloud. Depending on the instance chosen, a different hourly rate will be applied to the instance. AWS provides a range of instance types to satisfy the user's unique business requirements.
EC2 Instance Types:
General Purpose EC2 Instance
General purpose instances can be used for diverse workloads and offer a balance of computing, memory, and networking resources. These instances are best suited for programs like web servers and code repositories that use these resources in an equal distribution.
T and M are the two categories of general-purpose instances.
T instances are made for straightforward tasks like testing environments and have minimal networking options. Therefore, they are typically not a best choice if you want a production environment. On the other hand, if you select the option for your development or staging environments, you ought to give them a shot.
If you still require an all-purpose instance then use M instances. The M instance is mainly for an instance of production environment and it offers more evenly distributed resources than the T instance.
Compute Optimized
Compute-optimized instances are ideal for applications that require a lot of computing power and benefit from high-performance processors. Instances from this family are suitable for batch processing workloads, media transcoding, high-performance web servers, high-performance computing (HPC), scientific modeling, dedicated gaming servers, ad server engines, machine learning inference, and other compute-intensive applications.
Use Cases:
Batch processing, advertising, video encoding, gaming, distributed analytics, high-performance computing (HPC), and CPU-based machine learning inference.
Memory Optimized
For workloads that process big data sets in memory, memory-optimized instances are made to perform quickly. Some memory-optimized instances are R6a, R6i, R6g, R5a, R5a, R5b, R5n, R4, X1e, X2iezn,z1d, etc.
-
"X1e" instances, designed for high-performance databases or in RAM applications, are typically only used by enterprise applications. SAP has authorized the use of this instance type (x1e.32xlarge), which has a nearly 4TB RAM option, with the Business Suite S/HANA.
-
Although it uses fewer resources, X1 is also intended for enterprise applications, unlike X1e. Only two X1 options are available, but it is a good option for high-performance computing and Big Data operations.
-
Because they have more user-friendly resource options, the most recent generation of R instances, R4 instances, are an excellent choice for in-memory applications like databases and data mining and analysis.
Use Cases:
In-memory databases, distributed web-scale SQL and NoSQL databases, Memcached, Redis, SAP, real-time big data analytics like Hadoop and Spark clusters, and other enterprise software, are memory-intensive applications.
Accelerated Computing
Compared to software running on CPUs, accelerated computing instances use hardware accelerators, or co-processors, to perform tasks like floating point number calculations, graphics processing, or data pattern matching. Depending on the instance size, accelerated instances have "p" and "g" instances with their own NVIDIA cards with varying amounts of GPU.
-
The older P instances are simpler to use and have the processing power needed for data science, data analysis, and rendering even though P2 is a "general" purpose instance.
-
With its NVIDIA Tesla V100, the most recent P3 instance has more power. Similar to the P2, this is an excellent option for data analysis. It will also work great for autonomous vehicles and speech recognition.
-
The best choice for 3D rendering, video encoding, or application streaming, G3 instances are ideal for building your remote graphics station.
Use Cases:
High-performance computing, computational fluid dynamics, computational finance, seismic analysis, speech recognition, self-driving cars, and drug discovery are examples of these technologies.
Storage Optimized
Instances optimized for storage are made for workloads that demand frequent, sequential read and write access to enormous amounts of data stored locally. They are made to offer tens of thousands of low-latency, random I/O operations per second to applications (IOPS). These instances are in three groups: H, I, and D, which are a fantastic choice for databases that must frequently write to the disk.
-
For distributed file systems or centralized log processing, H instances are the best choice.
-
Excellent database option is I instances, particularly for NoSQL or data warehouses.
-
D instances are similar to H ones but perform better for massively parallel processing data warehousing and distributed computing, such as Hadoop and MapReduce.
Use Cases:
These instances increase the number of transactions handled per second for I/O-intensive and business-critical workloads with medium-sized data sets that can benefit NoSQL and relational databases (MySQL, MariaDB, and PostgreSQL) with high network speed and computational performance (TPS).
Additionally, they are a perfect fit for workloads like data analytics and search engine workloads requiring quick access to medium-sized data sets on local storage.
What's an AMI?
Amazon Machine Image provides the required information for launching EC2 instances, which may include EBS snapshots, operating systems, and application servers. Single AMI can be used to create multiple instances, copied in the same (or) different AWS region, and can be deregistered if no longer needed.
AMIs consist of the following:
-
A template for the instance's root volume, single or more Amazon Elastic Block Store (Amazon EBS) snapshots or for AMIs backed by an instance store.
-
Launch permissions that regulate which AWS accounts can launch instances using the AMI.
-
A block device mapping designates the volumes that should be attached to the instance at Launch.
Steps to Create EC2 Instance in AWS
-
Step 1: Log in to AWS Management Console and Open EC2
The AWS Console must first be accessed by logging in. Visit https://aws.amazon.com/console/ and select "Sign In to the Console" to do this.
-
Step 2: Click on Launch Instance
Click on the EC2 link to enter the EC2 dashboard in the compute area. Scroll down and click the launch instance button. You will then be taken to a page where you can select an AMI.
-
Step 3: Choose an Amazon Machine Image (AMI)
Choose the appropriate Amazon Machine Image from the list of options such as Linux, ubuntu, windows, etc.
-
Step 4: Choose an Instance Type
Choose a required instance and click on configure instance details below to go to the next step.
-
Step 5: Configure Instance Details
Now, you can select the number of instances, purchasing options, network, subnet, IAM group, etc. Click on Add Storage in the below right corner.
-
Step 6: Add Storage
Now, you can select the required size, volume type, encryption, etc., as shown below. Then click on Add Tags.
-
Step 7: Add Tags
Now you can add tags for whichever project of your requirements, such as spring-boot, or angular project, which help identify the project uniquely. Then click on configure security group button.
-
Step 8: Configure Security Group
Specify the required type, IP, protocol, and source, or can choose default ones. Then click on the Review and Launch button.
-
Step 9: Review and Launch
Now you can review the selected properties of the EC2 instances and launch the instance.
-
Step 10: Create/Select a Key Pair
For the first-time instance creation, specify the key pair, download the key pair file, store it for further use, and click on Launch.
Conclusion
-
In this article we discussed how to build an on-demand EC2 instance
-
Users can reduce costs by keeping the instance "Running" when needed and "Stopping" it when it's not.
-
Based on the operating system that is preferred by the user, users can launch a Linux (or) Windows EC2 instance (or) any available AMIs in the AWS.