AWS Certified Cloud Practitioner
Post 18 of 25
72%
Complete
AWS Cloud Practitioner #18: DynamoDB - NoSQL Serverless
Aprende DynamoDB: base de datos NoSQL serverless, key-value/document store, escalamiento automático y casos de uso.
Recommended Prerequisites
For the best learning experience, we recommend reading these posts first:
🎯 Lo que Aprenderás Hoy
- Explicar DynamoDB y NoSQL
- Diferenciar RDS vs. DynamoDB
- Comprender partition key y sort key
- Configurar auto-scaling
- Identificar casos de uso
¿Qué es DynamoDB?
DynamoDB es una base de datos NoSQL serverless completamente gestionada.
Características clave:
✅ Serverless (no instances)
✅ Auto-scaling
✅ Single-digit millisecond latency
✅ 99.99% availability
✅ Encryption at rest
✅ Point-in-time recovery
✅ Global tables (multi-region)
No gestionas:
❌ Servers
❌ Patches
❌ Backups (automáticos)
❌ Scaling infrastructureNoSQL vs. SQL
| Aspecto | SQL (RDS) | NoSQL (DynamoDB) |
|---|---|---|
| Schema | Fixed | Flexible |
| Structure | Tables + Rows | Tables + Items |
| Scaling | Vertical | Horizontal |
| Joins | Sí | No (denormalize) |
| Transactions | ACID | Eventually consistent* |
| Use case | Complex queries | Simple lookups, high scale |
*DynamoDB también soporta transactions
Conceptos Fundamentales
Tables, Items, Attributes
Table: Users
Item 1:
{
"UserID": "123", ← Partition Key
"Name": "Juan",
"Email": "juan@email.com",
"Age": 30
}
Item 2:
{
"UserID": "456",
"Name": "Maria",
"Country": "Spain", ← Different attributes OK
"Premium": true
}
Flexible schema: Items pueden tener diferentes attributesKeys
Partition Key (Primary Key)
Único identificador del item:
Table: Users
Partition Key: UserID
Query:
GetItem(UserID = "123")
→ O(1) lookup (ultra-fast)
Distribución:
DynamoDB usa partition key para distribuir data
Partition Key → Hash function → Physical partitionComposite Key (Partition + Sort Key)
Para queries más complejas:
Table: Orders
Partition Key: UserID
Sort Key: OrderDate
Permite:
- GetItem(UserID = "123", OrderDate = "2025-11-16")
- Query all orders para UserID = "123"
- Query orders entre datesCapacity Modes
1. On-Demand
Pricing: Pay per request
$1.25 per million write requests
$0.25 per million read requests
Use when:
✅ Unpredictable traffic
✅ Spiky workloads
✅ New applications
Example:
100K writes/day = 100K × $1.25/1M = $0.125/day = $3.75/month
1M reads/day = 1M × $0.25/1M = $0.25/day = $7.50/month
Total: $11.25/month2. Provisioned
Pricing: Set capacity, pay per hour
RCU (Read Capacity Unit): 1 read/sec
WCU (Write Capacity Unit): 1 write/sec
$0.00013 per WCU-hour
$0.000065 per RCU-hour
Use when:
✅ Predictable traffic
✅ Cost optimization (cheaper for steady load)
Example:
10 WCU + 20 RCU provisioned 24/7:
WCU: 10 × $0.00013 × 730 hrs = $0.95/month
RCU: 20 × $0.000065 × 730 hrs = $0.95/month
Total: $1.90/month
vs. On-Demand para same usage: $11.25
Savings: 83%Auto-scaling:
Provisioned with auto-scaling:
Min: 5 WCU, 10 RCU
Max: 100 WCU, 200 RCU
Target: 70% utilization
Traffic spike → Auto-scale up
Traffic drops → Auto-scale down
Best of both worlds:
✅ Cost efficiency de provisioned
✅ Flexibility de on-demandSecondary Indexes
¿Por qué? Permitir queries en attributes que NO son keys.
Global Secondary Index (GSI)
Table: Users
Partition Key: UserID
Quieres query por Email:
Create GSI:
GSI Name: EmailIndex
Partition Key: Email
Ahora puedes:
Query(EmailIndex, Email = "juan@email.com")
→ Returns UserID = "123"Local Secondary Index (LSI)
Same partition key, different sort key:
Table: Orders
Partition Key: UserID
Sort Key: OrderDate
LSI:
Partition Key: UserID
Sort Key: OrderAmount
Ahora puedes query orders por amountDynamoDB Streams
¿Qué es? Capture changes en table en real-time.
Use cases:
1. Audit trail:
Item updated → Stream → Lambda → Log to S3
2. Replication:
Item inserted → Stream → Lambda → Write to otro table
3. Notifications:
New order → Stream → Lambda → Send email
Stream record:
{
"eventName": "INSERT",
"dynamodb": {
"Keys": {"UserID": {"S": "123"}},
"NewImage": {
"Name": {"S": "Juan"},
"Email": {"S": "juan@email.com"}
}
}
}Global Tables
¿Qué son? Multi-region, fully replicated tables.
Setup:
Table en us-east-1
Enable global table → replicate to:
- eu-west-1
- ap-southeast-1
Beneficios:
✅ Low latency globalmente
✅ Disaster recovery
✅ Multi-region active-active
Replication:
Write en us-east-1 → async replicate a otras regiones
Typically <1 second replication lag
Conflict resolution:
Last writer wins (based on timestamp)DynamoDB Accelerator (DAX)
¿Qué es? In-memory cache para DynamoDB.
Without DAX:
App → DynamoDB (5-10ms latency)
With DAX:
App → DAX → DynamoDB
Cache hit: <1ms (microseconds)
Cache miss: 5-10ms (DynamoDB)
Use when:
✅ Read-heavy workloads
✅ Need sub-millisecond latency
✅ Reduce DynamoDB read costs (less requests)
Pricing:
dax.t3.small: $0.04/hour = $29/monthBest Practices
1. Design partition key carefully:
✅ High cardinality (many unique values)
✅ Uniform access pattern
❌ Hot partition (one key accessed 90% of time)
2. Use GSIs para access patterns:
Main table: Query by UserID
GSI: Query by Email, OrderDate, etc.
3. Denormalize data:
NoSQL = No joins
Store related data together
Example: Store OrderItems dentro de Order (nested)
4. Use DynamoDB Streams:
Para audit, replication, triggers
5. On-Demand vs. Provisioned:
Predictable → Provisioned (cheaper)
Spiky → On-Demand (simplicity)
6. Enable backups:
Point-in-time recovery
On-demand backups antes de migrations
7. Use DAX para read-heavy:
Cache layer reduces costs + latencyRDS vs. DynamoDB
Use RDS when:
✅ Complex queries (JOINs)
✅ Transactions críticos
✅ Relational data (normalize)
✅ SQL expertise en team
Use DynamoDB when:
✅ Simple key-value lookups
✅ Massive scale (millions requests/sec)
✅ Serverless (no server management)
✅ Variable workloads
✅ Low latency requirement (<10ms)
Example:
eCommerce app:
- Product catalog → DynamoDB (fast lookups)
- Orders/Transactions → RDS (complex queries)
- User sessions → DynamoDB (fast reads)📝 Preparación para el Examen
Puntos Clave
DynamoDB:
- 📌 NoSQL: Key-value/document store
- 📌 Serverless: No instances, auto-scaling
- 📌 Latency: Single-digit milliseconds
- 📌 Capacity: On-Demand o Provisioned
Keys:
- 📌 Partition Key: Primary key, required
- 📌 Sort Key: Optional, permite range queries
- 📌 Composite: Partition + Sort key
Features:
- 📌 Streams: Real-time change capture
- 📌 Global Tables: Multi-region replication
- 📌 DAX: In-memory cache
- 📌 Auto-scaling: Automatic capacity adjustment
Preguntas de Práctica
Pregunta 1:
¿Qué database es serverless?
A) RDS B) DynamoDB C) Redshift D) Aurora
Respuesta: B) DynamoDB
DynamoDB es fully serverless (no instances). Aurora Serverless existe, pero standard Aurora NO es serverless.
Pregunta 2:
¿Qué feature permite multi-region replication en DynamoDB?
A) DynamoDB Streams B) Global Tables C) DAX D) Local Secondary Index
Respuesta: B) Global Tables
Global Tables replican data automáticamente across múltiples regiones para low latency global y disaster recovery.
🎓 Resumen
- DynamoDB: NoSQL serverless, key-value store
- Keys: Partition key (required), Sort key (optional)
- Capacity: On-Demand (pay-per-request) o Provisioned (set capacity)
- Features: Streams, Global Tables, DAX cache
- Use case: High-scale, simple lookups, variable workloads
⏭️ Próximo Post
Post #19: AWS Lambda - Serverless Compute
Tags: #AWS #CloudPractitioner #DynamoDB #NoSQL #Serverless #Database #Certification
Related Articles
AWS Cloud Practitioner #19: AWS Lambda - Serverless Compute
Domina Lambda: serverless compute, event-driven execution, pricing pay-per-invocation y casos de uso.
AWS Cloud Practitioner #1: De Servidores Físicos a la Nube
Aprende qué es cloud computing y las diferencias entre IaaS, PaaS y SaaS con una metodología bottom-up que construye tu conocimiento paso a paso.
AWS Cloud Practitioner #2: Infraestructura Global AWS - Regions, AZs y Edge Locations
Descubre cómo AWS distribuye su infraestructura globalmente y aprende a elegir la región correcta para tus aplicaciones usando metodología bottom-up.
AWS Cloud Practitioner #3: Superpoderes de la Nube - Elasticity, Scalability y HA
Comprende las ventajas clave de cloud computing: elasticity, scalability, high availability y agility. Aprende cómo AWS implementa estos conceptos.