Amazon EC2
Amazon Elastic Compute Cloud (Amazon EC2) is an Amazon Web Services service that provides secure and scalable virtual server (“compute”) capacity in the cloud, falling under the Infrastructure as a Service (IAAS) category. Instances are launched from an Amazon Machine Image (AMI), can be attached to persistent Amazon Elastic Block Store (EBS) volumes, and scale automatically through Amazon EC2 Auto Scaling.
AI Practitioner focus
- EC2 can self-host training or inference when custom hardware, runtime, networking, or model control is required; the customer manages more scaling, patching, availability, and security than with a managed AI API.
- For foundational questions, compare this operational control with Amazon SageMaker AI managed training/hosting and Amazon Bedrock managed FM inference.
Key points
- Current purchasing/tenancy options (seven, per the EC2 billing and purchasing options guide):
- On-Demand Instances — no advance payment, no prior commitment; useful for short-term needs and unpredictable workloads (appropriate for intermittent, spiky, experimental workloads of roughly 3–6 months); billed by the second with a 60-second minimum.
- Spot Instances — no advance payment, no prior commitment; useful for cost-sensitive, interruptible workloads; can offer discounts of up to 90% off the On-Demand price; AWS can reclaim the capacity with a two-minute interruption notice.
- Reserved Instances — useful for long-running, predictable workloads; 1- or 3-year terms with a choice of No Upfront, Partial Upfront, or All Upfront payment; commits to a consistent instance configuration (type and Region).
- Savings Plans — a commitment to a consistent amount of usage (measured in /hour commitment over a 1- or 3-year term, not solely 12 months).
- Dedicated Instances — run on hardware dedicated to a single customer; other customers cannot share the hardware; billed hourly.
- Dedicated Hosts — a whole physical server allocated to an organization, with visibility into sockets and physical cores so existing per-socket, per-core, or per-VM software licenses (BYOL) can be brought over — unlike Dedicated Instances, which dedicate the hardware but don’t expose that visibility.
- Capacity Reservations — reserve On-Demand capacity in a specific Availability Zone for any duration, without requiring a 1- or 3-year term; Capacity Blocks are a related option for reserving a cluster of GPU instances for a fixed time window.
- Instance types and sizes are chosen based on price, CPU, operating system, storage, and networking (e.g.
t2.micro,t4g.nano,m4.large,r5a.large). - Amazon Machine Images (AMIs) are pre-configured templates packaging the operating system and other software for launching instances.
- Key pairs let users log in to instances: AWS manages the public key, the user holds the private key.
- Security groups provide firewall-like protection by specifying IP ranges, protocol (e.g. TCP), and port range (e.g. 22, 25, 443), and control both incoming and outgoing instance traffic by port and protocol type.
- Storage options:
- Instance store volumes — temporary storage that is deleted (ephemeral) if the instance is stopped, hibernated, or terminated.
- Amazon EBS volumes — persistent, non-temporary block storage.
- User data lets users run scripts automatically at instance launch.
- Instance lifecycle: stopping halts compute billing while preserving EBS volume data (instance store data is lost); terminating deletes the root EBS volume by default (unless
DeleteOnTerminationis disabled) and can’t be reversed; hibernating saves in-memory (RAM) state to the root EBS volume so the instance resumes without a full boot. Hibernation isn’t available for Linux instances with more than 150 GiB of RAM or Windows instances with more than 16 GiB of RAM, and a hibernated instance can’t stay hibernated for more than 60 days. - Shared responsibility: EC2 is IaaS, so AWS secures the physical hardware, hypervisor, and network, while the customer patches the guest operating system, secures applications and data, and configures security groups — see AWS Shared Responsibility Model.
- Three IP address types:
- Public IP address — changes when the instance is stopped or refreshed.
- Private IP address — retained even if the instance is stopped.
- Elastic IP address — a static public IP address.
Pricing
- Spot Instances can offer discounts of up to 90% off the On-Demand price.
- Reserved Instances offer No Upfront, Partial Upfront, or All Upfront payment options.
- Savings Plans commit to a consistent amount of usage (in $/hour) for a 1- or 3-year term at a reduced rate.