AWS Data Engineering Architecture Patterns
Module: AWS Data Engineering | Topic: Reference Architecture Patterns | Difficulty: Advanced
Master production-ready architecture patterns for building scalable, reliable, and cost-efficient data engineering solutions on AWS.
Architecture Patterns Overview
đ
Key Concept: Understanding this architecture is essential for designing scalable, cost-effective data platforms on AWS. Draw this diagram from memory during interviews.
AWS provides a rich ecosystem of services that can be combined into various architectural patterns to solve different data engineering challenges. Understanding these patterns is essential for designing solutions that are scalable, fault-tolerant, and cost-effective.
Key Design Principles
â ī¸
Common Interview Mistake: Don't just list features. Explain WHY each feature matters for data engineering and when you'd choose one option over another.
| Principle | Description | AWS Services |
|---|---|---|
| Scalability | Handle growing data volumes seamlessly | Auto Scaling, Lambda, Kinesis |
| Fault Tolerance | Ensure high availability and durability | Multi-AZ, S3 replication |
| Cost Optimization | Pay only for what you use | Spot Instances, S3 Lifecycle |
| Security | Defense in depth approach | IAM, KMS, VPC, Shield |
| Decoupling | Loose coupling between components | SQS, SNS, EventBridge |
| Observability | Full visibility into system behavior | CloudWatch, X-Ray, CloudTrail |
Pattern Categories
AWS data engineering patterns generally fall into three categories:
- Batch Processing Patterns - ETL/ELT pipelines, data warehousing, scheduled transformations
- Stream Processing Patterns - Real-time analytics, event-driven architectures, CDC
- Hybrid Patterns - Combining batch and streaming for comprehensive data solutions
đ
Deep Dive: Architecture Decision Records
AWS Well-Architected Framework provides guidelines for cloud architecture. Understanding the six pillars is essential for data engineering. Learn more in our Data Mesh Architecture guide and Data Lake Architecture for lake design patterns.
đ¯
Interview Question: "How do you design a fault-tolerant data pipeline?" Answer: (1) Use multi-AZ deployments, (2) Implement dead letter queues, (3) Use idempotent operations, (4) Enable auto-scaling, (5) Set up CloudWatch alarms, (6) Use Step Functions for orchestration with error handling.
Pattern 1: Serverless ETL Pipeline (Lambda + S3 + Glue + Redshift)
How This Pattern Works
The Serverless ETL Pipeline pattern leverages AWS Lambda and AWS Glue to create a fully managed, event-driven data processing workflow:
- Ingestion Layer: Lambda functions triggered by CloudWatch Events or API Gateway collect data from various sources
- Raw Storage: Data lands in S3 in its original format (raw zone)
- Catalog: Glue Crawlers automatically discover and catalog data schemas in the Glue Data Catalog
- Transformation: Glue ETL jobs transform data using Spark, outputting to processed zones
- Query Layer: Athena provides serverless SQL for ad-hoc analysis; Redshift handles complex analytical workloads
- Visualization: QuickSight connects to both Athena and Redshift for dashboarding
- Orchestration: Step Functions coordinate the entire workflow with error handling and retry logic
When to Use This Pattern
- Data volumes between 100 GB to 10 TB
- Batch processing with moderate complexity
- Teams wanting minimal infrastructure management
- Cost-sensitive workloads that benefit from pay-per-use pricing
Cost Considerations
| Component | Pricing Model | Optimization Tip |
|---|---|---|
| Lambda | Per request + duration | Right-size memory; use ARM64 |
| S3 | Per GB stored + requests | Use lifecycle policies for infrequent access |
| Glue | Per DPU-hour | Use auto-scaling workers; schedule crawlers |
| Redshift | Per node-hour | Use Concurrency Scaling for peak loads |
| Athena | Per TB scanned | Use Parquet format; enable partitioning |
Pattern 2: Data Lake Architecture
Data Lake Zone Architecture
The data lake follows a medallion architecture pattern with progressive data refinement:
Zone Definitions
| Zone | Purpose | Format | Retention | Access |
|---|---|---|---|---|
| Raw | Immutable source data, exact copy | JSON, CSV, Avro | Permanent | Write-once |
| Cleansed | Validated, deduplicated, schema-enforced | Parquet, ORC | 2-5 years | Read-mostly |
| Enriched | Joins with reference data, business logic applied | Parquet | 1-3 years | Read-mostly |
| Curated | Aggregated, analytics-ready datasets | Parquet, Delta | 6 months-2 years | Read-heavy |
| Sandbox | Ad-hoc exploration, data science notebooks | Any format | 30-90 days | Read-Write |
Key Data Lake Best Practices
- Partition Strategy: Partition by date for time-series data (
year=/month=/day=) - File Format: Use Parquet with Snappy compression for analytical queries
- File Sizing: Target 256 MB - 1 GB per file to optimize Spark parallelism
- Metadata: Use Glue Data Catalog as the central metadata repository
- Governance: Implement Lake Formation for fine-grained access control
- Catalog: Run Glue Crawlers on a schedule to keep the catalog current
Data Lake vs Data Warehouse
| Aspect | Data Lake | Data Warehouse |
|---|---|---|
| Data Types | Structured, semi-structured, unstructured | Primarily structured |
| Schema | Schema-on-read | Schema-on-write |
| Cost | Lower per TB (S3 pricing) | Higher (compute + storage) |
| Latency | Minutes to hours | Seconds to minutes |
| Users | Data engineers, data scientists | Business analysts |
| Purpose | Exploration, ML, batch analytics | Reporting, dashboards |
Pattern 3: Real-Time Streaming Architecture
How This Pattern Works
The Real-Time Streaming Architecture processes data as it arrives with sub-second latency:
- Producers emit events from IoT sensors, web/mobile apps, log agents, or database triggers
- Ingestion via Kinesis Data Streams or MSK buffers and durably stores events across shards/partitions
- Processing options include:
- Kinesis Data Analytics: SQL or Flink for windowed aggregations
- Lambda: Serverless event processing with fan-out
- Kinesis Firehose: Buffered delivery with optional transformations
- Managed Flink: Complex event processing with stateful operations
- Destinations receive processed data for storage, visualization, or alerting
Streaming vs Batch Comparison
| Aspect | Batch Processing | Stream Processing |
|---|---|---|
| Latency | Minutes to hours | Milliseconds to seconds |
| Throughput | Very high per batch | Moderate per record |
| Complexity | Moderate | High (state management) |
| Cost Model | Lower per GB | Higher per record |
| Use Case | Historical analytics | Real-time dashboards |
| Error Handling | Rerun batch | Checkpointing + replay |
| Tools | Glue, EMR, Athena | Kinesis, Flink, Lambda |
Windowing Strategies
Streaming analytics relies on windowing to aggregate events over time:
- Tumbling Window: Fixed-size, non-overlapping intervals (e.g., every 5 minutes)
- Sliding Window: Fixed-size, overlapping intervals (e.g., 5-minute window sliding every 1 minute)
- Session Window: Dynamic windows based on activity periods (with gap threshold)
- Global Window: Accumulates all events (use with custom triggers)
Kinesis vs MSK Decision Matrix
| Factor | Kinesis Data Streams | Amazon MSK |
|---|---|---|
| Protocol | AWS SDK only | Kafka protocol (open) |
| Throughput | Up to 2 MB/shard | Scales horizontally |
| Consumer Model | Pull (SDK) or Push (Lambda) | Consumer groups |
| Ordering | Per-shard | Per-partition |
| Management | Fully managed | Self-managed brokers |
| Schema Registry | Via Glue | Confluent Schema Registry |
| Best For | AWS-native, simple streaming | Kafka ecosystem compatibility |
Pattern 4: Hybrid Batch + Streaming Architecture
How This Pattern Works
The Hybrid Architecture combines batch and stream processing to provide both historical accuracy and real-time insights:
Speed Layer (Real-Time)
- Events flow through Kinesis for immediate processing
- Lambda functions enrich and transform data in real-time
- Results stored in DynamoDB or ElastiCache for low-latency access
- SNS triggers alerts for threshold breaches
Batch Layer (Historical)
- Full data dumps collected in S3 (raw zone)
- Glue ETL jobs run on schedule (hourly/daily) to transform and aggregate
- Results land in S3 (processed zone) and Redshift for complex analytics
- Step Functions orchestrate the entire batch workflow
Serving Layer
- Unified query API merges both real-time and batch views
- Queries first check real-time cache, then fall back to batch results
- Provides a single interface for all consumers
When to Use This Pattern
- Applications requiring both real-time dashboards AND historical trend analysis
- Compliance requirements that mandate complete data audit trails
- Systems where late-arriving data must be incorporated into analytics
- Organizations transitioning from batch-only to real-time capabilities
Key Design Considerations
| Consideration | Recommendation |
|---|---|
| Reconciliation | Periodically recompute batch views to correct streaming approximations |
| Storage | Use S3 as the immutable source of truth for both layers |
| Orchestration | Use Step Functions for batch; EventBridge for stream triggers |
| Monitoring | Track lag in Kinesis; monitor Glue job duration and failures |
| Idempotency | Design processors to handle duplicate events gracefully |
Pattern 5: Event-Driven Microservices Architecture
Key Benefits of Event-Driven Architecture
| Benefit | Description |
|---|---|
| Loose Coupling | Services communicate via events, not direct calls |
| Scalability | Each service scales independently |
| Resilience | Failure in one service does not cascade |
| Extensibility | Add new consumers without modifying producers |
| Auditability | EventBridge provides full event history |
EventBridge Rule Example
{
"source": ["custom.order-service"],
"detail-type": ["OrderPlaced"],
"detail": {
"status": ["confirmed"],
"total": [{ "numeric": [">=", 100] }]
}
}
Common Event Patterns
- Event Notification: Notify downstream systems of state changes
- Event-Carried State Transfer: Include full state in the event payload
- Event Sourcing: Store all state changes as a sequence of events
- CQRS: Separate read and write models using events
Architecture Decision Framework
Choosing the right pattern depends on several factors. Use this decision matrix:
Pattern Selection Guide
| Requirement | Recommended Pattern |
|---|---|
| Batch ETL with minimal ops | Serverless ETL (Lambda + Glue + S3) |
| Multi-format data lake | Data Lake Architecture (S3 + Lake Formation) |
| Real-time dashboards | Streaming Architecture (Kinesis + Lambda) |
| Historical + real-time | Hybrid Architecture (Lambda Architecture) |
| Microservices integration | Event-Driven (EventBridge + Lambda) |
Decision Factors
| Factor | Batch | Streaming | Hybrid |
|---|---|---|---|
| Data Freshness | Hours | Seconds | Both |
| Complexity | Low-Medium | Medium-High | High |
| Cost | Lower | Higher | Moderate |
| Operational Overhead | Low | Medium | High |
| Best For | Reporting, ML training | Monitoring, alerts | Full-stack analytics |
AWS Service Quick Reference
| Category | Services |
|---|---|
| Compute | Lambda, EC2, ECS, EKS, Fargate |
| Storage | S3, EBS, EFS, FSx |
| Databases | RDS, Aurora, DynamoDB, ElastiCache |
| Processing | Glue, EMR, Athena, Redshift, Lake Formation |
| Streaming | Kinesis Data Streams, Kinesis Firehose, MSK, Managed Flink |
| Integration | EventBridge, SQS, SNS, Step Functions |
| Analytics | QuickSight, SageMaker, OpenSearch |
| Security | IAM, KMS, VPC, Shield, WAF, Macie |
| Monitoring | CloudWatch, X-Ray, CloudTrail |
Architecture Flow
Interview Questions and Answers
Interview Q&A Section
Master these architecture patterns to excel in data engineering interviews.
Q1: Walk me through a complete AWS data pipeline architecture from ingestion to visualization.
Show Answer
A complete AWS data pipeline typically follows this architecture:
-
Ingestion: Use Kinesis Data Streams for real-time data or S3 Transfer Family for batch file transfers. For databases, AWS DMS handles CDC.
-
Storage (Raw Zone): All incoming data lands in S3 organized as
s3://bucket/raw/{source}/{year}/{month}/{day}/ -
Cataloging: Glue Crawlers run on a schedule to discover schemas and populate the Glue Data Catalog.
-
Transformation: Glue ETL jobs (or EMR for large-scale Spark) read from raw zones, apply business logic, and write to processed zones in Parquet format.
-
Serving:
- Athena for ad-hoc serverless queries
- Redshift for complex analytical workloads and joins
- OpenSearch for full-text search and log analytics
-
Orchestration: Step Functions coordinate the pipeline with error handling, retry logic, and notification on failure.
-
Visualization: QuickSight connects to Athena and Redshift for dashboards.
-
Monitoring: CloudWatch tracks job metrics; CloudTrail provides audit logs; Lake Formation enforces access policies.
Q2: How would you design a real-time analytics dashboard that processes millions of events per second?
Show Answer
Architecture for high-throughput real-time analytics:
-
Ingestion Layer: Kinesis Data Streams with multiple shards (each shard handles 1 MB/s in, 2 MB/s out). Use enhanced fan-out for multiple consumers.
-
Processing: Kinesis Data Analytics with Apache Flink for windowed aggregations (tumbling windows of 1 minute). Alternatively, use Lambda with Kinesis trigger for simpler transformations.
-
Real-time Storage: DynamoDB with DAX (caching) for sub-millisecond reads of aggregated metrics. Use global tables for multi-region availability.
-
Batch Rollup: Kinesis Firehose buffers data to S3 every 60 seconds. Glue jobs aggregate hourly/daily summaries into Redshift.
-
Visualization: QuickSight with SPICE for dashboard rendering. Use refresh schedules aligned with data availability.
-
Alerting: CloudWatch Alarms on Kinesis iterator age and Lambda error rates. SNS for PagerDuty integration.
Scaling considerations: Auto-shard Kinesis based on IncomingBytes and IncomingRecords metrics. Use Lambda reserved concurrency to prevent throttling.
Q3: Explain the difference between Kinesis Data Streams and Kinesis Firehose. When would you use each?
Show Answer
Kinesis Data Streams (KDS):
- Real-time streaming with 200ms latency
- Custom consumer applications (KCL, Lambda, SDK)
- Manual shard management and scaling
- Data retention up to 365 days
- Exactly-once processing with enhanced fan-out
- Use when: You need real-time processing, custom logic, or exactly-once semantics
Kinesis Data Firehose (KDF):
- Near-real-time with 60-900 second buffer
- Managed delivery to S3, Redshift, OpenSearch, HTTP endpoints
- Automatic scaling (no shard management)
- Data conversion (JSON to Parquet/ORC)
- Built-in compression and encryption
- Use when: You need simple, managed delivery without custom processing
Decision Matrix:
| Scenario | Use KDS | Use Firehose |
|---|---|---|
| Real-time ML scoring | Yes | No |
| Log delivery to S3 | No | Yes |
| Exactly-once requirements | Yes | No |
| Schema conversion needed | No | Yes |
| Multi-consumer fan-out | Yes | No |
| Simple archival | No | Yes |
Q4: How do you handle schema evolution in a data lake?
Show Answer
Schema evolution strategies for S3-based data lakes:
-
Partitioned Writes: Use Hive-style partitioning with dynamic partitions. New partitions automatically get the new schema.
-
Iceberg/Delta Lake: Use table formats that support schema evolution natively:
- Add columns without rewriting existing data
- Rename columns (metadata-only operation)
- Change column types with compatibility rules
-
Glue Schema Registry: Register Avro/JSON schemas. Consumer applications detect schema changes and handle them gracefully.
-
Column-Level Lineage: Use AWS Lake Formation to track which schema version each dataset uses.
-
Best Practices:
- Never delete columns (add new, deprecate old)
- Add new columns at the end
- Use nullable types for backward compatibility
- Version datasets with suffixes:
orders_v2/
# Glue ETL with schema evolution
spark.conf.set("spark.sql.schemaEvolution.enabled", "true")
df.write.mode("append").partitionBy("year", "month").parquet("s3://lake/cleaned/orders/")
Q5: Compare Lambda architecture vs Kappa architecture. Which would you recommend?
Show Answer
Lambda Architecture (two layers):
- Batch Layer: Processes complete historical dataset (Glue + Redshift)
- Speed Layer: Processes real-time data (Kinesis + Lambda)
- Serving Layer: Merges both views for queries
Pros: Handles both historical and real-time, fault-tolerant Cons: Two codebases to maintain, complexity, storage overhead
Kappa Architecture (single layer):
- Single stream processing layer (Kafka/Flink)
- Reprocess from beginning of log when logic changes
- All data treated as a stream
Pros: Simpler operations, one codebase, easier debugging Cons: Replay can be expensive, stream-only processing
Recommendation:
- Use Lambda when: you have complex batch transformations, need batch corrections, or have distinct batch and real-time use cases
- Use Kappa when: your processing logic is relatively simple, you want operational simplicity, or you are building greenfield
On AWS: Lambda architecture maps naturally to Glue+Redshift (batch) + Kinesis+Lambda (speed). Kappa maps to Managed Flink + Kinesis.
Q6: How do you implement data quality checks in an AWS data pipeline?
Show Answer
AWS-native data quality implementation:
-
Glue DataBrew: Visual data profiling with built-in quality rules. Detect anomalies, duplicates, and missing values before ETL.
-
Custom Glue Jobs with Great Expectations:
import great_expectations as ge
df = ge.from_pandas(spark_df)
df.expect_column_values_to_not_be_null("order_id")
df.expect_column_values_to_be_between("amount", min_value=0, max_value=100000)
results = df.validate()
-
Step Functions Validation Step: Add a Lambda validation step before downstream processing. If validation fails, write to quarantine S3 bucket and send SNS alert.
-
CloudWatch Metrics: Emit custom metrics for record counts, null rates, and schema drift. Set alarms on thresholds.
-
Athena for Ad-hoc Quality: Run SQL queries against raw data to spot-check completeness:
SELECT date, COUNT(*) as cnt, COUNT(DISTINCT order_id) as unique_orders
FROM raw_orders
GROUP BY date
HAVING cnt != unique_orders OR cnt < 1000;
- Automated Alerts: Use EventBridge to trigger Lambda functions when quality metrics fall below thresholds.
Q7: Describe how you would migrate a legacy on-premises data warehouse to AWS Redshift.
Show Answer
Phase 1: Assessment
- Profile source data volumes, query patterns, and SLAs
- Map schema types (Oracle/SQL Server to Redshift)
- Identify dependencies and downstream consumers
Phase 2: Infrastructure Setup
- Provision Redshift cluster (RA3 nodes for managed storage)
- Set up VPC, security groups, and IAM roles
- Configure S3 buckets for staging (raw, processed, archive)
Phase 3: Schema Migration
- Use AWS Schema Conversion Tool (SCT) for automated conversion
- Handle stored procedures, views, and functions manually
- Create distribution keys and sort keys for optimal performance
Phase 4: Data Migration
- Initial load: Use DMS for bulk data transfer or S3 Copy Command
- Set up ongoing CDC with DMS for zero-downtime migration
- Validate row counts and checksums post-migration
Phase 5: Query Migration
- Convert source SQL to Redshift-optimized syntax
- Replace proprietary functions with Redshift equivalents
- Implement materialized views for frequently-run queries
Phase 6: Cutover
- Dual-run period (2-4 weeks) comparing results
- Update connection strings in applications
- Decommission legacy system after validation
Key Redshift Tips: Use COPY command for bulk loads, leverage STL query tables for performance tuning, enable concurrency scaling for peak loads.
Q8: How do you optimize costs in an AWS data architecture?
Show Answer
Storage Optimization:
- S3 Intelligent-Tiering for unpredictable access patterns
- S3 Lifecycle policies to move infrequent data to Glacier
- Redshift Managed Storage with auto-scaling
- Compress data (Parquet + Snappy reduces storage 4-10x)
Compute Optimization:
- Lambda: Right-size memory (CPU scales proportionally)
- EMR: Use Spot Instances (60-70% savings) for non-critical jobs
- Glue: Use auto-scaling workers and schedule crawlers off-peak
- Redshift: Pause during off-hours, resume for batch runs
Data Architecture Optimization:
- Partition data by date to minimize scanned data
- Use columnar formats (Parquet) to skip unnecessary columns
- Implement data retention policies (archive old data)
- Deduplicate early in the pipeline to reduce downstream processing
Monitoring & Alerts:
- Cost Explorer with budget alerts
- CloudWatch custom metrics for per-pipeline cost tracking
- Trusted Advisor recommendations for idle resources
| Technique | Estimated Savings |
|---|---|
| S3 Intelligent-Tiering | 30-40% |
| EMR Spot Instances | 60-70% |
| Redshift Pause/Resume | 50-65% |
| Parquet compression | 75-90% |
| Lambda ARM64 | 20% |
Q9: How would you implement a CDC (Change Data Capture) pipeline on AWS?
Show Answer
AWS CDC Architecture:
-
Source Database: Enable logical replication (PostgreSQL) or use Oracle LogMiner / SQL Server CDC feature.
-
AWS DMS: Create a replication instance with CDC task:
- Full load + CDC mode for initial sync + ongoing changes
- Table mapping rules to filter specific tables/schemas
- LOB handling configuration for large objects
-
Target Options:
- S3: DMS directly writes to S3 in Parquet format
- Kinesis: DMS streams changes to Kinesis for real-time processing
- Redshift: DMS with bulk insert for near-real-time warehousing
- Aurora: DMS for cross-region replication
-
Processing: Lambda or Kinesis Data Analytics processes the CDC stream for:
- Deduplication (last-write-wins or merge logic)
- Schema transformation
- Enrichment with reference data
-
Downstream: Write processed CDC events to:
- DynamoDB for operational queries
- S3 for historical archive
- OpenSearch for search indexing
DMS Task Configuration Example:
CDCStartTime: Beginning of capture windowLOBSupport: Full for LOB columnsParallelLoadThreads: 4-8 for performanceParallelLoadBufferSize: 500 for batch size
Q10: Explain how you would design a multi-region data architecture on AWS.
Show Answer
Multi-Region Data Architecture Patterns:
-
Active-Active: Both regions process data simultaneously
- DynamoDB Global Tables for real-time sync
- Route 53 with health checks for failover
- S3 Cross-Region Replication for data backup
-
Active-Passive: Primary region handles all traffic; secondary is standby
- DMS for continuous replication to standby
- CloudFront for static content from both regions
- Redshift cross-region snapshot copy
-
Data Sovereignty: Data stays in specific regions per regulation
- Region-locked S3 buckets
- KMS keys per region
- VPC endpoints to prevent data egress
Key Services:
| Service | Multi-Region Capability |
|---|---|
| DynamoDB | Global Tables (active-active) |
| S3 | Cross-Region Replication |
| Redshift | Cross-Region Snapshots |
| DMS | Cross-Region Replication Tasks |
| Aurora | Global Database (read replicas) |
| SQS | S2S VPN or custom replication |
Design Principles:
- Design for failure in each region independently
- Use eventual consistency for cross-region sync
- Implement conflict resolution (last-write-wins or application-level)
- Monitor cross-region latency and replication lag
Summary
Key Takeaways
- No one-size-fits-all: Choose the pattern based on data volume, latency requirements, and team expertise
- Start simple: Begin with serverless patterns (Lambda + Glue + S3) and evolve as needs grow
- Decouple everything: Use SQS, SNS, and EventBridge to build resilient, independently deployable components
- Data governance first: Implement Lake Formation, IAM policies, and encryption from day one
- Cost awareness: Monitor per-pipeline costs; use lifecycle policies and right-sized resources
- Observability is critical: CloudWatch, X-Ray, and CloudTrail provide the visibility needed to debug and optimize
Recommended Reading
- AWS Well-Architected Framework - Data Analytics Lens
- AWS Big Data Blog
- AWS re:Invent Data Engineering Sessions
- AWS Data Analytics Specialty Certification