Performance Goals and Cost Optimization

ElastiCache Redis/Memcached, CloudFront, DynamoDB DAX, Aurora, EBS, S3 performance optimization alongside Savings Plans, Spot, and right-sizing cost strategies.

In SAP-C02, performance and cost look like opposing forces, but the exam tests your ability to find solutions that satisfy both simultaneously. "Most cost-effectively meet the performance target" is the standard question format. This post systematically covers caching layers, purpose-built database selection, storage optimization, and cost reduction strategies.

 

Caching Layers — ElastiCache Redis vs Memcached

ElastiCache uses in-memory caching to reduce database load and shorten response times to microseconds.

Know the selection criteria between Redis and Memcached clearly.

| Item | Redis | Memcached | |------|-------|----------| | Data structures | String, Hash, List, Set, Sorted Set, Stream | String only | | Replication and HA | Multi-AZ, automatic failover | Not supported | | Persistence | AOF/RDB snapshots | Not supported | | Distributed session store | Well suited | Possible but limited | | Multi-threading | Limited | Fully multi-threaded | | Geospatial | Supported | Not supported |

Choose Redis when you need high availability, persistence, or complex data structures. Choose Memcached when you need a simple high-performance cache and multi-threading is important.

!ElastiCache Redis versus Memcached

DynamoDB DAX (DynamoDB Accelerator) is an in-memory cache with a fully DynamoDB-compatible API. Just swap the endpoint to DAX and you achieve microsecond response times. DAX is the direct solution for hot partitions — partitions where repeated reads concentrate.

MemoryDB for Redis is Redis-compatible but guarantees data durability through a Multi-AZ transaction log. It offers stronger durability than standard ElastiCache Redis and suits patterns that use Redis as the primary database.

 

CloudFront — Origin Shield, Lambda@Edge

CloudFront caches content at 450+ edge locations worldwide, reducing origin server load and serving responses from the edge closest to the user.

Origin Shield adds an extra caching layer between CloudFront's regional edge caches and the origin. It minimizes the number of requests reaching the origin, reducing origin load and data transfer costs. Enable Origin Shield when you have global users and need to minimize origin load.

Lambda@Edge runs Lambda functions at CloudFront edge locations. You can modify HTTP headers or handle authentication before requests reach the origin. Common use cases include A/B testing, dynamic URL redirects, and request-based authentication.

The distinction between CloudFront Signed URL and Signed Cookies matters. Signed URL is a one-time access token for a single file. Signed Cookies control access to multiple files matching a path pattern with a single cookie. For video streaming where you need to control access to many files, choose Signed Cookies.

 

DynamoDB Performance Optimization

DynamoDB performance depends heavily on partition key design. To avoid hot partitions, choose attributes with high cardinality (many unique values) as the partition key, or add a random suffix to composite partition keys.

A GSI (Global Secondary Index) uses a different partition key and sort key from the base table and can be added after table creation. An LSI (Local Secondary Index) uses the same partition key with a different sort key and can only be added at table creation time.

DynamoDB TTL adds a Unix timestamp attribute to items and automatically deletes them when they expire. There is no additional charge, and deletion completes within 48 hours of expiration. This suits session data and temporary data management.

DynamoDB Streams captures table change events in real time. Integrating with Kinesis Data Streams enables high-volume real-time event processing for use cases like anomaly detection, replication, and cache invalidation triggers.

For data that needs periodic bulk deletion, like time-series data, use the table rotation pattern. Create a new table each month and delete old tables entirely with DeleteTable. This deletes data with zero WCU consumption. TTL deletion has up to a 48-hour delay and consumes WCUs, making table rotation more efficient for bulk deletes.

 

Aurora Performance — Read Replicas, Global DB, Serverless v2

Aurora provides both high availability and performance through its six-way replication storage architecture across three AZs.

Aurora Read Replicas share the cluster volume, meaning replication lag is minimal. The Reader Endpoint load-balances across all Read Replicas to distribute read queries. Enabling Aurora Auto Scaling automatically adjusts the number of Replicas based on read load.

Aurora Global Database keeps cross-region replication lag below one second (typically around 100ms). It is useful not only for DR but also for improving global read performance. Adding Reader Endpoints in secondary regions lets users in those regions receive read responses locally.

Aurora Serverless v2 adjusts capacity automatically in seconds, scaling up and down in ACU (Aurora Capacity Unit) increments from minimum to maximum instantly. It is ideal for applications with unpredictable traffic patterns.

 

EBS Storage Types and S3 Performance

EBS gp3 is the successor to gp2, providing a baseline of 3,000 IOPS independent of storage volume size. With gp2, IOPS scale proportionally with storage size. io2 Block Express provides up to 256,000 IOPS and is the top-performance storage option for database workloads.

S3 multipart upload splits large files into parts for parallel uploading. It is recommended for files over 100 MB and allows retransmitting only the failed part on network errors. S3 Transfer Acceleration routes uploads through CloudFront edge locations to accelerate S3 uploads. Use it for long-distance uploads (international to S3) or when consistently high speed is required.

For HPC workloads, choose FSx for Lustre. It is a high-performance parallel file system delivering hundreds of GB/s throughput and millions of IOPS. POSIX compatibility means Linux-based HPC workloads run without modification.

 

Cost Optimization — Savings Plans, Spot, Right-sizing

| Option | Discount | Commitment | Best for | |--------|----------|------------|---------| | Compute Savings Plans | Up to 66% | 1 or 3 years | EC2, Fargate, Lambda; flexible on region/family | | EC2 Instance Savings Plans | Up to 72% | 1 or 3 years | Fixed region plus instance family for max discount | | Reserved Instance | Up to 72% | 1 or 3 years | Stable, predictable workloads | | Spot Instance | Up to 90% | None | Interruptible batch or stateless workloads |

Compute Savings Plans apply to EC2, Fargate, and Lambda. The discount persists even when you change regions or instance families, making them more flexible than Reserved Instances at a slightly lower discount rate.

Spot Instances offer up to 90% discount but can be interrupted. Placing SQS in front of a Spot Fleet for batch processing means that when a Spot Instance is interrupted, the in-progress task returns to the SQS queue automatically for reprocessing with no loss.

For S3 storage cost optimization, understand Lifecycle policies and S3 Intelligent-Tiering. S3 Intelligent-Tiering automatically moves objects that have not been accessed for 30 days to the Infrequent Access tier. It suits data with irregular access patterns. S3 Glacier Deep Archive is the lowest-cost storage class with retrieval times of 12 to 48 hours, suitable for long-term archiving.

S3 Standard-IA and Glacier Instant Retrieval have a minimum storage duration of 30 days. Deleting objects before 30 days incurs an early deletion charge. When an exam question asks for inexpensive storage for data stored less than 30 days, choose S3 Standard.

 

Exam Key Points

"Cache with high availability plus complex data structures" -- ElastiCache Redis

"Simple high-performance cache plus multi-threading" -- ElastiCache Memcached

"Improve DynamoDB hot partition read performance with minimal code change" -- DAX (endpoint swap only)

"Redis-compatible plus data durability guarantee" -- MemoryDB for Redis

"Extra caching layer to minimize CloudFront origin load" -- Origin Shield

"Control access to multiple files simultaneously" -- CloudFront Signed Cookies

"Delete large amounts of expired DynamoDB data with zero WCU" -- table rotation (more efficient than TTL)

"Aurora read auto-scaling" -- Aurora Auto Scaling plus Reader Endpoint

"Unpredictable traffic, auto-scaling in seconds" -- Aurora Serverless v2

"Covers EC2/Fargate/Lambda, flexible on region" -- Compute Savings Plans

"Up to 90% discount for interruptible batch jobs" -- Spot Instance plus SQS

"Auto-tier data with irregular access patterns" -- S3 Intelligent-Tiering

"S3 class with no minimum storage duration" -- S3 Standard

"Early deletion charge applies before 30 days" -- S3 Standard-IA and Glacier Instant Retrieval

"HPC high-performance parallel file system" -- FSx for Lustre

Back to blog list