Amazon Web Services: EC2, storage and databases
Practical study notes on AWS EC2 (compute), storage options (EBS, instance store, S3) and managed databases (RDS, Aurora, DynamoDB), with definitions, CLI syntax, worked examples and exam guidance.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Cloud engineers use Amazon Web Services (AWS) EC2 and AWS storage/databases to run servers, store data and provide managed database services. Knowing differences between instance types, block vs object storage, and managed relational vs NoSQL databases helps design cost‑effective, available and durable cloud systems.
Key ideas
Start from first principles and define each term before use.
Cloud instance (EC2 instance): a virtual server running in AWS; it has CPU, memory, storage and network properties determined by its instance type. Instance types are groups like t3, m5, r5 that trade CPU, memory and cost. Assumption: virtualization provides isolation and resource control.
AMI (Amazon Machine Image): a snapshot template that contains an operating system image and optional software; launching an EC2 instance requires an AMI ID.
Block storage (EBS — Elastic Block Store): a network-attached virtual disk presented as a block device to an instance. EBS volumes persist independently of instance lifecycle (unless explicitly deleted). EBS volumes are AZ-scoped and can be attached only to instances in the same Availability Zone. Common volume types: gp3 (general-purpose SSD), io1/io2 (provisioned IOPS SSD), st1/sc1 (throughput-optimized/cold HDD). EBS snapshot is a point-in-time, incremental copy stored in S3.
Instance store (ephemeral storage): physically attached disks provided with some instance types. Data is lost if instance stops/terminates. Use for caches or temporary buffers, not for persistent data.
Object storage (S3 — Simple Storage Service): stores data as objects in buckets; not a block device. Objects are identified by keys. S3 is designed for very high durability and scalability (objects accessed over HTTP APIs). S3 provides strong read-after-write consistency for PUT/DELETE of objects and offers storage classes (Standard, Standard-IA, One Zone-IA, Intelligent-Tiering, Glacier Instant Retrieval, Glacier Flexible Retrieval, Glacier Deep Archive) with different cost/availability trade-offs; designed durability is 99.999999999% (11 nines).
Durability vs Availability: Durability is the probability that data is not lost (often expressed as “nines” like 99.999999999%). Availability is the fraction of time the service is reachable. Formula: Availability % = (Total time − downtime) / Total time × 100. Assumption: availability is measured from client's perspective; SLAs define credits for failure.
RDS (Relational Database Service): managed relational database offering (MySQL, PostgreSQL, MariaDB, Oracle, SQL Server, and Aurora). RDS automates provisioning, patching, backups and optionally Multi-AZ replication for high availability. Read Replicas are for read scaling (asynchronous replication), while Multi-AZ is for high availability and automatic failover; they serve different purposes.
Aurora: AWS’s cloud-native, MySQL/PostgreSQL-compatible database. It separates storage and compute: multiple compute nodes attach to a distributed storage layer that is replicated across AZs for fault tolerance. The storage layer maintains six copies across three AZs and auto-scales in 10 GiB increments up to 128 TiB per cluster volume.
DynamoDB: fully managed NoSQL key-value and document database with provisioned or on-demand capacity. Capacity units: WCU (Write Capacity Unit) and RCU (Read Capacity Unit) — these measure allowed throughput. One RCU supports one strongly consistent read per second for up to a 4 KB item (two eventually consistent reads); one WCU supports one write per second for up to a 1 KB item. Transactional reads/writes consume 2× the RCUs/WCUs. Assumption: verify exact definitions if AWS updates them.
Elastic Block Store performance concepts: IOPS (I/O operations per second) and throughput (bytes per second). Relationship: throughput = IOPS × I/O size (bytes). If I/O size varies, compute using average I/O size.
Snapshot and backup strategy: persistent volumes need backups (EBS snapshots or database backups). For RDS use automated backups and snapshots; for EC2/EBS use volume snapshots and AMI creation.
Diagram to draw for an exam: Draw three Availability Zones (AZ1, AZ2, AZ3) inside one AWS Region. In each AZ show an EC2 instance box. Draw EBS volumes attached to instances (label “EBS — block, persists”). Show an S3 bucket at region level (label “S3 — object, cross-AZ durability”). For RDS show one primary in AZ1 and a standby in AZ2 (label Multi‑AZ). For DynamoDB show a global table with replication arrows across regions (if discussing global tables). Label network (VPC) and Security Group firewall around instances. Note: Security Groups are stateful (instance-level), while Network ACLs are stateless (subnet-level).
Formulas
For this programming/cloud topic we list CLI/API syntax and simple formulas to remember.
aws ec2 run-instances --image-id <AMI> --instance-type <type> --key-name <key> --subnet-id <subnet> --security-group-ids <sg>— launch an EC2 instance.aws ec2 create-volume --availability-zone <az> --size <GiB> --volume-type <type>— create an EBS volume.aws ec2 attach-volume --volume-id <vol-id> --instance-id <instance-id> --device /dev/xvdf— attach an EBS volume.aws s3 cp <local-file> s3://<bucket>/<key>— upload an object to S3.aws rds create-db-instance --db-instance-identifier <id> --db-instance-class <class> --engine <mysql|postgres> --master-username <user> --master-user-password <pw> --allocated-storage <GiB>— create an RDS database instance.aws dynamodb put-item --table-name <table> --item '<JSON>'— write an item to DynamoDB.Throughput formula:
throughput_bytes_per_sec = IOPS × IO_size_bytes. Symbols: IOPS = input/output operations per second (1/s); IO_size_bytes = average bytes per operation (B); throughput in B/s. Applies when operations are uniform.Monthly storage cost formula (general):
monthly_cost = size_GB × cost_per_GB_per_month. Units: GB and currency per month.
Worked examples
Launch EC2 + attach EBS and mount (exam-style step list, replace placeholders): Steps:
- Choose an AMI and instance type. Example placeholders: AMI=ami-xxxxxxxx, type=t3.medium.
- CLI:
aws ec2 run-instances --image-id ami-xxxxxxxx --instance-type t3.medium --key-name mykey --subnet-id subnet-aaaa --security-group-ids sg-aaaa. - Create 50 GiB gp3 EBS volume:
aws ec2 create-volume --availability-zone <instance-az> --size 50 --volume-type gp3(the volume’s AZ must match the instance’s AZ) → returnsVolumeId=vol-11111111. - Attach:
aws ec2 attach-volume --volume-id vol-11111111 --instance-id i-22222222 --device /dev/xvdf. - On the instance (SSH): verify the device path with
lsblk(on Nitro-based instances EBS shows as NVMe, e.g.,/dev/nvme1n1). Then format and mount the actual device, e.g.,sudo mkfs -t ext4 /dev/xvdf(or/dev/nvme1n1) &&sudo mkdir /data&&sudo mount <actual-device> /data. - To make permanent, use a stable identifier: get the filesystem UUID with
sudo blkid <actual-device>and addUUID=<uuid> /data ext4 defaults,nofail 0 2to/etc/fstab. Final state: EC2 instance running with a 50 GiB persistent EBS block device mounted at /data.
EBS throughput calculation example: Given: an EBS volume can sustain 3,000 IOPS and average IO size is 16 KiB. Calculate throughput. Formula: throughput = IOPS × IO_size. Numbers: throughput = 3,000 × 16 KiB/s = 48,000 KiB/s = 46.875 MiB/s. Answer: 46.875 MiB/s.
DynamoDB capacity calculation (model answer): Problem: You will store items of average size 1 KB. You expect 200 strongly consistent reads/second and 50 writes/second. How many RCUs and WCUs to provision? Rules (AWS definitions): one RCU supports one strongly consistent read per second for up to 4 KB item; one WCU supports one write per second for up to 1 KB item. (Verify exact definitions if AWS updates them.) Calculation: For reads, each item 1 KB ≤ 4 KB uses 1 RCU → need 200 RCUs. For writes, each item 1 KB uses 1 WCU → need 50 WCUs. Answer: 200 RCUs and 50 WCUs.
Common mistakes
- Using wrong units when calculating throughput (mixing KiB, KB, MiB, MB) — always state the base and convert correctly.
- For DynamoDB, using on‑demand pricing assumptions in capacity-provisioning problems and vice versa.
- Not describing the backup/restore steps for RDS (snapshots, automated backups) when asked about disaster recovery.
For your exam
Typical question types and what full-marks answers include:
- Definitions: define EC2, EBS, S3, RDS, DynamoDB clearly and state one key property (persistence, API type, or typical use-case).
- Short notes: compare EBS vs instance-store vs S3; include durability, latency, mountability, typical uses.
- Diagrams: when asked to draw architecture, include Region → AZs → EC2 instances → EBS attachments → S3 bucket; label Multi-AZ RDS with primary/standby and mention automatic failover.
- Derivations: for availability/durability questions show formula and substitute numbers where given; state assumptions (independence of AZ failures etc.).
- Numericals: follow steps, state formulas, carry units, and show final answer with units.
- Commands/programming: show exact AWS CLI syntax or describe API calls; mention required parameters (AMI, instance-type, subnet, security-group, key-name).
Full-marks answers always: give definitions, list assumptions, provide exact commands or formulas, and explain why each storage/database choice fits the scenario.
Quick check
- Which AWS storage gives a block device you can format and mount?
- One RCU supports how many strongly consistent reads per second for a 4 KB item?
- How to make an EBS volume survive instance termination?
Answers: 1) EBS (Elastic Block Store). 2) One strongly consistent read per second (per 4 KB item — verify AWS doc for updates). 3) Ensure the EBS volume’s DeleteOnTermination flag is false (DeleteOnTermination=false) so it is not deleted with the instance; optionally create a snapshot for backup. To reuse a snapshot, create a new volume from it and attach that volume to a new instance.
Note on uncertainties: I have used AWS's common definitions for RCU/WCU and described typical EBS performance values in examples. AWS updates service limits and exact SLA/durability numbers from time to time — I have not quoted specific SLA percentages or fixed limits for every instance/volume type. See verify list for items to check.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?