Dynamodb in AWS
? Amazon DynamoDB in AWS – Complete Overview
Amazon DynamoDB is a fully managed NoSQL database service provided by AWS that delivers fast and predictable performance with seamless scalability. It is designed to handle high-throughput, low-latency workloads and is ideal for applications that need a scalable, highly available key-value or document database.
? Key Features of DynamoDB
Fully Managed
No need to worry about hardware provisioning, setup, configuration, replication, software patching, or cluster scaling.Serverless
DynamoDB automatically scales up and down to adjust for capacity and maintain performance.Single-Digit Millisecond Latency
Extremely fast response time suitable for gaming, IoT, mobile, and real-time web apps.Multi-Region, Active-Active Replication
Using DynamoDB Global Tables, you can replicate your tables across AWS Regions for higher availability and faster access.Flexible Data Model
Key-Value and Document store.
Supports complex nested attributes using JSON-like data structures.
Built-in Security and Access Control
Integrates with AWS IAM, KMS for encryption, and VPC endpoints for private connectivity.
Event-Driven Programming
Integrates with AWS Lambda, DynamoDB Streams, and Amazon EventBridge for building serverless apps.
? Core Components
| Component | Description |
|---|---|
| Table | Container for data (like an RDBMS table). |
| Item | A single record in a table (like a row). |
| Attribute | A piece of data attached to an item (like a column). |
| Primary Key | Uniquely identifies each item in a table. Can be: - Partition Key only - Partition + Sort Key |
| Secondary Index | Allows querying the table using alternative keys. - Global Secondary Index (GSI) - Local Secondary Index (LSI) |
?? Performance & Scaling
Provisioned Capacity: Specify how much read/write capacity you want.
On-Demand Capacity: Pay only for what you use—ideal for unpredictable workloads.
Auto Scaling: Automatically adjusts read/write throughput.
? DynamoDB Streams
Capture item-level changes (insert, update, delete) in a stream.
Can trigger AWS Lambda to process these changes in real-time.
? Security in DynamoDB
Encryption at Rest: Using AWS KMS.
Encryption in Transit: TLS for data transfer.
Access Control: Through IAM policies, resource-based policies, and fine-grained access control.
? Pricing Model
DynamoDB pricing is based on:
Read and Write Throughput (for provisioned mode)
Data storage
DynamoDB Streams
On-demand backups and point-in-time recovery
Global Tables replication
? Use DynamoDB On-Demand if your usage is unpredictable—it charges per request.
? Use Cases
Gaming leaderboards
IoT data ingestion
Real-time bidding and analytics
Shopping carts and session storage
User profile stores
Mobile and web backends
? Example: Basic Table Creation (AWS CLI)
aws dynamodb create-table \ --table-name Users \ --attribute-definitions AttributeName=UserID,AttributeType=S \ --key-schema AttributeName=UserID,KeyType=HASH \ --billing-mode PAY_PER_REQUEST \ --region us-west-2
? Tips & Best Practices
Use efficient keys: Distribute reads and writes evenly.
Avoid hot partitions: Spread access across many partition keys.
Design with access patterns in mind.
Use DAX (DynamoDB Accelerator) for in-memory caching.
Prefer On-Demand mode for unpredictable workloads.
? Integrations
AWS Lambda: Trigger actions on data changes.
AWS AppSync: Build GraphQL APIs with DynamoDB backend.
Amazon Kinesis: For advanced analytics on stream data.
Amazon CloudWatch: Monitor and alert on usage metrics.
? Summary
| Feature | Benefit |
|---|---|
| Scalable | Handles millions of requests per second. |
| Reliable | SLA-backed availability. |
| Serverless | No infrastructure to manage. |
| Secure | Fully integrated with AWS security tools. |
| Real-Time Capable | Streams + Lambda for event-driven use cases. |