Amazon EC2 のアイコン

Amazon EC2 Essential2006年〜

A compute service that provides virtual servers in the cloud

What It Does

Amazon EC2 (Elastic Compute Cloud) is a service for launching and managing virtual servers (instances) in the cloud. You can freely choose CPU, memory, storage, and network configurations, and spin up servers in regions around the world within minutes. It uses a pay-as-you-go model where you launch only the instances you need and stop them when you're done.

Use Cases

It is used for web servers, application servers, batch processing, machine learning training, development and test environments, and virtually any computing workload. It is also widely used as the first choice when migrating on-premises servers to the cloud.

Everyday Analogy

Think of it like a car rental service. Instead of buying and maintaining your own car (on-premises server), you rent a vehicle of the right size (instance type) whenever you need one. You can choose anything from a compact car to a truck depending on your needs, and you only pay for the time you use it.

What Is EC2?

Amazon EC2 is the most fundamental compute service on AWS. Instead of purchasing and installing physical servers, you can launch virtual servers with just a few clicks from the API or console. It supports a wide range of operating systems including Linux, Windows, and macOS, with over 750 instance types to choose the optimal configuration for your use case.

Instance Types and How to Choose

EC2 instance types are organized into families by use case. General purpose (M series) offers a balanced configuration ideal for web servers. Compute optimized (C series) is for CPU-intensive processing, and memory optimized (R series) is suited for databases and caches. GPU instances (P series, G series) are used for machine learning and video processing. Instance type names like 'm7g.xlarge' are composed of family, generation, and size.

Pricing Models

EC2 offers several pricing models. On-Demand charges by the second and lets you start and stop anytime. Reserved Instances offer up to 72% discount by committing to 1 or 3 years of usage. Spot Instances let you use AWS spare capacity at up to 90% discount, but may be interrupted. Savings Plans are flexible discount plans where you commit to a certain dollar amount of compute usage. For a systematic understanding of pricing models, technical books (Amazon) are also a good reference.

Getting Started

Click 'Launch instance' in the EC2 console and select an AMI (OS image), instance type, key pair, and security group. After launch, a public IP address is assigned and you can connect via SSH or RDP. The free tier lets you use a t2.micro or t3.micro instance for up to 750 hours per month for 12 months at no charge.

Things to Watch Out For

  • EBS volume charges continue even after stopping an instance, so delete unnecessary volumes
  • Opening SSH (port 22) to 0.0.0.0/0 in security groups is a high security risk. Restrict by IP address or use Session Manager instead
  • The free tier t2.micro allows up to 750 hours per month. Running multiple instances counts toward the total, so be careful
共有するXB!