Designing High-Performance Architectures on AWS: Caching, Scaling, Right Sizing, Database Choice and Performance Tools
Performance Vocabulary
| Term | Meaning |
| Latency | Time for one request to complete (milliseconds). Users feel this |
| Throughput | Work done per second (requests/s, MB/s) |
| IOPS | Disk operations per second |
| Concurrency | Requests handled at the same time |
| Percentiles (p50, p95, p99) | p99 = slowest 1 percent. Averages hide slow requests, so watch p95/p99 |
| Bottleneck | The slowest part that limits the whole system |
The Method
- Measure first: define goals (for example p95 under 300 ms at 2,000 requests/s)
- Find the bottleneck with metrics and tracing (CloudWatch, X-Ray, Performance Insights)
- Change one thing, test again
- Automate scaling and load tests
- Repeat as the system grows
Caching at Every Layer
text
Browser cache ─► CloudFront (edge) ─► API Gateway cache ─► ALB ─► app in-memory cache
─► ElastiCache / DAX ─► database (query cache, read replicas) ─► storage
| Layer | Service | What it caches |
| Browser and CDN | CloudFront + Cache-Control headers | Static files, images, even API GET responses |
| API layer | API Gateway cache (REST) | API responses per stage |
| Application | In-process cache, ElastiCache | Computed results, sessions, hot objects |
| Database | DAX (DynamoDB), RDS/Aurora read replicas, ElastiCache | Hot items, repeated queries |
| DNS | Route 53 TTL | Name lookups |
- Caching trades freshness for speed. Choose TTLs and invalidation deliberately
- Cache static, popular and expensive-to-compute data first
- Use versioned URLs (
app.v123.js) to avoid manual invalidation
Scaling for Performance
| Approach | Meaning | Use |
| Vertical scaling (scale up) | A bigger instance | Quick fix, limited, needs restart for EC2 |
| Horizontal scaling (scale out) | More instances behind a load balancer | Preferred: better availability, cost-effective, near unlimited |
| Read scaling | Read replicas, caches, CloudFront | Read-heavy apps |
| Partitioning / sharding | Split data by key | Write-heavy at big scale (DynamoDB does it for you) |
| Asynchronous processing | Queue the work, return fast | Image processing, emails, reports |
Compute Performance
| Choice | Guidance |
| Instance family | Match the workload: compute (C), memory (R/X), storage I/O (I), GPU (G/P), general (M/T). Graviton often gives better price/performance |
| Right-size with AWS Compute Optimizer | Recommendations from CloudWatch metrics (CPU, memory with agent, network) |
| Burstable T instances | Credits run out → CPU is throttled. Use unlimited mode or move to M/C for sustained load |
| Enhanced networking (ENA), EFA | Higher bandwidth, low latency. EFA for HPC/ML with MPI |
| Placement group (cluster) | Lowest latency between instances |
| Lambda memory | More memory means more CPU. Test with Power Tuning |
| Containers | Set CPU and memory requests and limits correctly |
Storage Performance
| Need | Choice |
| Consistent, highest IOPS, low latency | EBS io2 Block Express (up to 256,000 IOPS) |
| General purpose with tunable IOPS | gp3 (set IOPS and throughput separately) |
| Large sequential throughput | st1 or FSx for Lustre |
| Fastest local scratch | Instance store NVMe |
| Many instances sharing files | EFS (Elastic throughput) or FSx |
| S3 high request rates | Spread across prefixes, multipart, Transfer Acceleration, Express One Zone for lowest latency |
| EBS-optimized instance | Make sure the instance type supports enough EBS bandwidth |
Database Performance
- Pick the right engine for the access pattern (see the database lessons)
- Add indexes and fix slow queries (use Performance Insights,
EXPLAIN)
- Read replicas and caching for reads, Aurora for fast replication
- RDS Proxy for connection storms (Lambda)
- DynamoDB: good partition keys, DAX, on-demand or auto scaling, avoid scans
- Redshift: distribution and sort keys, columnar compression, workload management, Concurrency Scaling
- Batch writes, use pagination, avoid N+1 queries
Network Performance
- CloudFront for global content, Global Accelerator for non-cacheable and TCP/UDP traffic over the AWS backbone
- Same AZ placement lowers latency and avoids cross-AZ data fees for chatty services (balance with availability)
- VPC endpoints and PrivateLink keep traffic on the AWS network
- Jumbo frames (MTU 9001) inside a VPC, Transit Gateway and Direct Connect for stable latency
- Route 53 latency routing to the nearest Region
- Use HTTP/2 or HTTP/3 and keep-alive connections
Data Ingestion Performance
| Problem | Fix |
| Uploading big files to S3 from far away | Multipart upload + Transfer Acceleration |
| Burst of events | SQS/Kinesis as a buffer |
| Many small writes to S3 | Batch them with Firehose |
| Huge offline data | Snow Family |
| Streaming analytics | Kinesis Data Streams with enough shards |
Measure With AWS Tools
| Tool | Use |
| CloudWatch metrics and alarms | CPU, network, latency, queue depth, custom metrics |
| CloudWatch Logs Insights and Application Signals | Search logs, service-level indicators |
| AWS X-Ray | Distributed tracing: find which service or call is slow |
| RDS/Aurora Performance Insights | DB load by SQL, wait, host |
| Compute Optimizer | Right-sizing for EC2, EBS, Lambda, ECS on Fargate, ASG |
| Trusted Advisor | Checks including underused resources and service limits |
| Distributed load testing (a solution), JMeter, k6, Locust | Generate load and find limits before users do |
A Tuning Checklist
- Do you have latency and error SLOs and dashboards?
- Is the web tier stateless and auto-scaled on the right metric?
- Is static content on CloudFront?
- Are there caches in front of slow or expensive reads?
- Is the database indexed, with replicas or a cache for reads?
- Are heavy or slow tasks asynchronous?
- Are instance types and storage right-sized (Compute Optimizer)?
- Do you load test before big events?
Practice Tasks
- Run a load test against a sample site and record p95 latency before and after adding CloudFront and an ElastiCache layer
- Use Compute Optimizer or CloudWatch to find an oversized instance
- Switch a gp2 volume to gp3 and set IOPS and throughput
- Enable X-Ray in a Lambda and API Gateway app and find the slowest segment
- Explain why p99 matters more than the average for a payment API
Conclusion
Improve performance by measuring first, then caching at every layer, scaling horizontally, choosing the right instance, storage and database for the workload, moving slow work to asynchronous queues, using the AWS network (CloudFront, Global Accelerator, endpoints), and verifying with CloudWatch, X-Ray, Performance Insights and Compute Optimizer.
Quick Summary: method; caching layers; scaling types; compute/storage/db/network choices; ingestion; measurement tools; tuning checklist.