intermediate

EC2

Run virtual machines when the team needs OS-level control, custom networking, persistent processes, or migration-friendly hosting.

EC2 provides resizable virtual machines in AWS VPCs. A FullStack Node.js team uses them when they need a full OS, long-lived processes, custom networking, or a lift-and-shift path from on-prem.

| Concept | Role | |---------|------| | Instance type | CPU, memory, and network profile | | AMI | Boot image and baseline software | | Security group | Stateful firewall on the ENI | | EBS volume | Persistent block storage attached to the instance |

Place API servers in private subnets; expose traffic through a load balancer. Use IAM instance profiles instead of static keys on the box. User data or configuration management installs Node.js, systemd units, and log agents.

On interviews: instance families, spot versus on-demand, security groups versus NACLs, EBS types, health checks behind ALB, and why you would not run a stateless API fleet on a single EC2 host without autoscaling.

Common pitfalls: SSH keys baked into AMIs; open security groups on port 22; storing uploads on local disk; no autoscaling or health checks; treating instance IDs as stable identity.

The trade-off is maximum control and migration flexibility versus operational burden compared with containers or serverless.

Checklist:

  • Run app tiers in private subnets behind a load balancer.
  • Attach instances via IAM roles, not long-lived access keys.
  • Use autoscaling groups with health checks.
  • Persist durable data on EBS or external services, not ephemeral local disk.