Skip to main content

EC2 Instance

An EC2 Instance is a virtual server rented on demand from AWS, where you choose the operating system, CPU, memory, and storage, and pay only for the time it runs. Every other AWS compute service — ECS, EKS, EMR — ultimately runs on EC2 underneath. Instance types are named by family and size (e.g. `m5.2xlarge`), where the family letter signals whether it's optimized for general use, compute, memory, storage, or GPU workloads.

Zerodha runs its order-matching engine on c-family compute-optimized EC2 instances for CPU-bound processing, while its reporting layer runs on r-family memory-optimized instances for large in-memory aggregations.

Purchasing Options

  • On-Demand — pay per second, no commitment, for unpredictable load
  • Reserved — up to 72% off for steady 24/7 workloads
  • Spot — up to 90% off, reclaimed with a 2-minute warning, for fault-tolerant batch jobs
  • Savings Plans — flexible dollar-commitment discount across instance types
Security

Never open SSH (port 22) to 0.0.0.0/0 — automated internet scanners probe every public IP within minutes of launch. Restrict to a specific IP or use SSM Session Manager instead.

Remember

Attach an IAM Role to the instance instead of storing access keys on disk — roles issue temporary credentials that auto-rotate and can't be stolen the way static keys can.

Frequently Asked Questions

What determines the naming of an EC2 instance type like m5.2xlarge?

The name encodes family, generation, extras, and size. 'm' is the family (general purpose; 'c' is compute-optimized, 'r' is memory-optimized, 'i' is storage-optimized, 'g'/'p' are GPU), '5' is the hardware generation, and '2xlarge' is the size relative to the smallest 'large' unit in that family (8 vCPU / 32 GiB here). Letters like 'n' (network), 'a' (AMD), or 'g' (Graviton/ARM) can also appear mid-name.

Why does an EC2 instance sometimes get 'stopped' instead of terminated when AWS reclaims capacity?

Spot Instances can be reclaimed with only a two-minute warning when AWS needs the capacity back, and depending on your interruption behavior setting they're stopped (EBS-backed root volume preserved, can restart later) rather than terminated. A common mistake is running stateful workloads on Spot without handling this signal via the instance metadata service, causing abrupt data loss or failed jobs instead of a graceful shutdown.