Compute services in AWS (Amazon Web Services) refer to the various cloud-based services that provide businesses with the ability to create and run applications, workloads, and services without having to manage physical infrastructure. These services provide virtual computing resources, such as servers, storage, and networking, that can be easily and quickly provisioned and scaled on demand, based on the needs of the application or workload.
Compute services in AWS include a range of services, such as virtual machines, containers, serverless computing, and batch processing. These services enable businesses to build, deploy, and manage their applications and workloads efficiently and cost-effectively while providing high levels of scalability, security, and reliability.
Some examples of compute services in AWS include Amazon Elastic Compute Cloud (EC2), Amazon Elastic Container Service (ECS), Amazon Elastic Kubernetes Service (EKS), AWS Lambda, Amazon Lightsail, AWS Batch, and Amazon Elastic Beanstalk. Each of these services provides unique capabilities and benefits, allowing businesses to choose the right service for their specific use case and workload requirements.
Elastic Compute Cloud (EC2)
EC2 is a foundational service in AWS that provides resizable compute capacity in the cloud. It allows businesses to quickly spin up and scale virtual machines, called instances, to run their applications. EC2 offers a wide range of instance types optimized for different use cases, such as compute-optimized instances for high-performance computing, memory-optimized instances for in-memory databases, and storage-optimized instances for large-scale data processing.
Here is the picture of the AWS console, you can see various options that need to be filled in to create an EC2. Before this, we have to select an AMI (Amazon Machine Image). An AMI is a pre-configured virtual machine image used to create instances in Amazon Elastic Compute Cloud (EC2) service. An AMI provides the information required to launch an instance, which includes the operating system, application server, and any additional software needed to run the instance.
EC2 Instance types
General Purpose :
These instances are designed for a variety of workloads and provide a balance of CPU, memory, and network resources. Examples include t3, t3a, m5, m5a, m5n, m5dn, m5ad, m5nd, m6g, and m6gd.
Compute Optimized:
These instances are optimized for CPU-intensive workloads and offer a high ratio of vCPUs to memory. Examples include c5, c5n, c5d, c5ad, c6g, and c6gd.
Memory Optimized:
These instances are optimized for memory-intensive workloads and provide high memory-to-CPU ratios. Examples include r5, r5a, r5n, r5d, r5ad, r5dn, and r6g.
Storage Optimized:
These instances are optimized for storage-intensive workloads and provide high, low-latency storage capacities. Examples include i3, i3en, d2, h1, and z1d.
There are three types of purchasing options available for Amazon Elastic Compute Cloud (EC2) instances, which are as follows:
On-Demand Instances:
On-Demand instances are the default option for EC2 instances. With On-Demand instances, you pay for compute capacity by the hour, with no long-term commitments. This purchasing option is ideal for applications with unpredictable workloads, and for workloads that require short-term, bursty compute capacity.
Reserved Instances:
Reserved Instances provide a significant discount on the hourly rate of an instance, in exchange for a one-time, upfront payment. You can choose to reserve an instance for a 1-year or 3-year term, and there are three different payment options: All Upfront, Partial Upfront, or No Upfront. Reserved Instances are ideal for predictable workloads and long-term commitments and can result in significant cost savings over time.
Spot Instances:
Spot Instances provide access to unused EC2 instances at a discounted price, with savings of up to 90% compared to On-Demand instances. With Spot Instances, you bid on the price you're willing to pay for compute capacity, and when your bid matches the current Spot price, your instance will be launched. However, your instance can be terminated with a 2-minute notification if the Spot price exceeds your bid or if Amazon needs the capacity back. Spot Instances are ideal for workloads that are flexible and can handle interruptions.
EC2 User Data
EC2 User data refers to a script or data that can be passed to an EC2 instance during its launch process. This user data can be used to perform various tasks, such as installing and configuring software, running scripts, and setting up environment variables.
Note: EC2 user data script only runs once while Instance is starting for the first time.
User data can be used for a variety of purposes, such as automating software installation, configuring network settings, and setting up security features. For example, a user data script can be used to install and configure a web server. Refer the below script which is used to install and start Apache on EC2.
#!/bin/bash
# Use this for your user data (script from top to bottom)
# install httpd (Linux 2 version)
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "<h1>Hello World from $(hostname -f)</h1>" > /var/www/html/index.html
Amazon Elastic Container Service (ECS)
ECS is a fully-managed container orchestration service that allows businesses to run and manage Docker containers on a cluster of EC2 instances. With ECS, businesses can easily deploy and scale containerized applications, while maintaining high availability and reliability. ECS integrates with other AWS services, such as Elastic Load Balancing and Amazon Elastic File System, to provide a complete container solution.
The below image shows how the Docker image is stored in ECR and is pulled by ECS or EKS services for running those images.
Amazon ECR is a fully managed container registry service that makes it easy to store, manage, and deploy Docker container images. ECR is tightly integrated with other Amazon Web Services (AWS) services, such as Amazon ECS, Amazon EKS, and AWS Fargate, making it easy to build, store, and deploy containerized applications on the AWS cloud.
Amazon Elastic Kubernetes Service (EKS): EKS is a fully-managed Kubernetes service that enables businesses to run containerized applications using Kubernetes on AWS. EKS provides a highly-available, secure, and scalable Kubernetes control plane, and integrates with other AWS services, such as Elastic Load Balancing and Amazon Elastic File System.
AWS Lambda
Lambda is a serverless compute service that enables businesses to run code without provisioning or managing servers. With Lambda, businesses can upload their code and the service will automatically run and scale it in response to events, such as changes to data in Amazon S3 or Amazon DynamoDB. Lambda supports a variety of programming languages, including Node.js, Python, Java, and C#.
AWS lambda use cases :
Event-driven data processing:
AWS Lambda can be used to process data in real-time, such as streaming data from Amazon Kinesis or Amazon S3. This can be useful for processing data for analytics or for triggering other AWS services.
Serverless API backends:
With AWS Lambda, developers can build serverless APIs that can handle dynamic traffic loads and scale automatically. This can be useful for building APIs for mobile applications, web applications, or IoT devices.
Serverless ETL pipelines:
AWS Lambda can be used to transform and load data from one data store to another. For example, it can be used to extract data from a relational database, transform it, and load it into a data warehouse.
Real-time stream processing:
AWS Lambda can be used to process real-time streams of data, such as clickstreams, IoT sensor data, or social media feeds. This can be useful for processing and analyzing data in real-time.
AWS Elastic Beanstalk
AWS Elastic Beanstalk is a fully managed service that allows developers to deploy, manage, and scale applications easily in the AWS cloud. Elastic Beanstalk is designed to simplify the process of deploying and managing applications by providing a platform that automatically handles the deployment, configuration, scaling, and monitoring of applications.
Some of its key features include:
Multi-platform support: AWS Elastic Beanstalk supports a wide range of popular programming languages such as Java, .NET, Node.js, PHP, Python, Ruby, and Go, as well as popular web application platforms such as Docker, Tomcat, and Packer.
Easy deployment: Elastic Beanstalk makes it easy to deploy applications using various methods such as AWS Management Console, AWS CLI, or Git. It also allows you to easily deploy new versions of your application without downtime.
Monitoring: Elastic Beanstalk provides detailed monitoring and logging of your application and the underlying infrastructure. It can also integrate with AWS CloudWatch to monitor metrics, set alarms, and respond to events.
Security: Elastic Beanstalk integrates with other AWS services such as AWS Identity and Access Management (IAM) and AWS Key Management Service (KMS) to provide a secure environment for your application.
Customization: Elastic Beanstalk allows you to customize the configuration of your environment by adding or modifying resources such as databases, load balancers, or caching services.
Cost-effective: Elastic Beanstalk offers a pay-as-you-go pricing model, which means you only pay for the resources you use. It also offers free usage tiers for some of its supported services.
Conclusion
In conclusion, Amazon Web Services (AWS) offers a wide range of compute services that provide flexible, scalable, and cost-effective computing resources for various use cases. These services include Amazon EC2 for virtual machines, Amazon ECS for container orchestration, AWS Lambda for serverless computing, and many others.
Each compute service in AWS offers unique features and benefits, allowing users to choose the right service based on their specific needs. For example, EC2 provides a wide range of instance types and purchasing options, while ECS simplifies container management and deployment. AWS Lambda allows users to run code without managing servers, while AWS Batch is ideal for running batch computing workloads at scale.
By using these compute services, AWS customers can take advantage of the scalability, reliability, and cost-effectiveness of cloud computing, allowing them to focus on their business needs and application development, rather than managing the underlying infrastructure.