Skip to content

Instantly share code, notes, and snippets.

@AgilanVageesan
Last active March 16, 2025 14:44
Show Gist options
  • Select an option

  • Save AgilanVageesan/d49f264f03b7e8fb2b870168eab3564a to your computer and use it in GitHub Desktop.

Select an option

Save AgilanVageesan/d49f264f03b7e8fb2b870168eab3564a to your computer and use it in GitHub Desktop.

πŸš€ DynamoDB Useful Tables – Healthcare System Analogy

πŸ“Š DynamoDB WCU & RCU Calculation Formulas

πŸ”Ή Read Capacity Units (RCU) Calculation

Metric Formula Description
RCU (Strongly Consistent Reads) RCU = (Item size in KB / 4 KB) * 1 Each strongly consistent read requires full RCU allocation
RCU (Eventually Consistent Reads) RCU = (Item size in KB / 4 KB) * 0.5 Eventually consistent reads consume half the RCU
RCU (Transactional Reads) RCU = (Item size in KB / 4 KB) * 2 Transactional reads require double the RCU

πŸ”Ή Write Capacity Units (WCU) Calculation

Metric Formula Description
WCU (Standard Writes) WCU = (Item size in KB / 1 KB) Each write consumes WCU based on item size
WCU (Transactional Writes) WCU = (Item size in KB / 1 KB) * 2 Transactional writes require double the WCU

πŸ’‘ These formulas help estimate the required WCU and RCU for efficient DynamoDB capacity planning! πŸš€

πŸ“Œ DynamoDB Key Features & Healthcare Analogy

DynamoDB Feature Healthcare System Equivalent Purpose πŸ“Œ
Primary Key (Partition Key + Sort Key) Unique Patient ID & Medical Record Number Ensures quick patient record retrieval
Global Secondary Index (GSI) Searching patients by blood type or disease Fast alternate queries
Local Secondary Index (LSI) Organizing patient history within a department Optimized sorting
DynamoDB DAX (Cache Layer) Emergency Fast Track for critical patients Reduces latency for urgent lookups and speeds up frequently accessed data
DynamoDB Streams Real-time medical alert system Tracks data changes & triggers workflows
Time-To-Live (TTL) Auto-archiving old patient records Deletes outdated or unnecessary data
DynamoDB Transactions Coordinating multi-department patient care Ensures atomic, consistent updates
DynamoDB PartiQL Querying records with SQL-like syntax Enables complex queries on NoSQL
DynamoDB CLI Doctor's quick-access terminal Manages records via command line
DynamoDB Conditional Writes Preventing duplicate prescriptions Ensures no conflicting updates
DynamoDB Session State Keeping logged-in doctor’s session active Stores temporary session data

βš™οΈ DynamoDB API Operations – CRUD for Patient Records

API Operation Healthcare Equivalent Function πŸ₯
PutItem Registering a new patient Adds a new record to the system
GetItem Looking up a patient’s history Retrieves an existing record
UpdateItem Updating patient treatment progress Modifies an existing record
DeleteItem Archiving old patient records Removes outdated entries
BatchWriteItem Processing multiple lab reports at once Writes multiple records in one call
BatchGetItem Retrieving multiple patient histories Fetches multiple records at once
Query Searching for all patients with a certain condition Retrieves data using indexes
Scan Checking all patients in a department Reads entire table (less efficient)

πŸ”„ DynamoDB vs. Other Databases – Feature Comparison

Feature DynamoDB (NoSQL) RDS (SQL Databases) MongoDB (NoSQL Document DB) Cassandra (Wide-Column NoSQL)
Schema Type Schema-less (Key-Value, JSON) Structured (Relational) Schema-flexible (JSON/BSON) Schema-less (Column-Family)
Scalability Auto-scales, serverless πŸš€ Vertical & manual scaling πŸ—οΈ Horizontal scaling Horizontally scalable
Performance Millisecond latency ⚑ Dependent on indexing Fast for document queries Optimized for write-heavy workloads
Indexes GSIs, LSIs Primary & Secondary Indexes Indexing on document fields Tuned for high-performance queries
ACID Compliance Supports Transactions βœ… Fully ACID compliant βœ… Supports transactions Limited ACID properties
Use Case High-traffic apps, real-time data Complex relationships, OLTP Flexible document storage Time-series, logging, IoT
Availability Multi-region, highly available 🌍 Single-region unless set up Replication for availability Distributed, high-availability
Pricing Model Pay-per-use, serverless πŸ’° Instance-based pricing Subscription or self-hosted Pay-per-node-based pricing

πŸ’‘ DynamoDB is ideal for high-speed, scalable applications, whereas RDS is better for structured relational data. Choose based on your specific use case! πŸš€

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment