🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

AWS Data Engineering Architecture Patterns

AWS Data EngineeringReference Architecture Patterns⭐ Premium

Advertisement

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.

PrincipleDescriptionAWS Services
ScalabilityHandle growing data volumes seamlesslyAuto Scaling, Lambda, Kinesis
Fault ToleranceEnsure high availability and durabilityMulti-AZ, S3 replication
Cost OptimizationPay only for what you useSpot Instances, S3 Lifecycle
SecurityDefense in depth approachIAM, KMS, VPC, Shield
DecouplingLoose coupling between componentsSQS, SNS, EventBridge
ObservabilityFull visibility into system behaviorCloudWatch, X-Ray, CloudTrail

Pattern Categories

AWS data engineering patterns generally fall into three categories:

  1. Batch Processing Patterns - ETL/ELT pipelines, data warehousing, scheduled transformations
  2. Stream Processing Patterns - Real-time analytics, event-driven architectures, CDC
  3. 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:

  1. Ingestion Layer: Lambda functions triggered by CloudWatch Events or API Gateway collect data from various sources
  2. Raw Storage: Data lands in S3 in its original format (raw zone)
  3. Catalog: Glue Crawlers automatically discover and catalog data schemas in the Glue Data Catalog
  4. Transformation: Glue ETL jobs transform data using Spark, outputting to processed zones
  5. Query Layer: Athena provides serverless SQL for ad-hoc analysis; Redshift handles complex analytical workloads
  6. Visualization: QuickSight connects to both Athena and Redshift for dashboarding
  7. 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

ComponentPricing ModelOptimization Tip
LambdaPer request + durationRight-size memory; use ARM64
S3Per GB stored + requestsUse lifecycle policies for infrequent access
GluePer DPU-hourUse auto-scaling workers; schedule crawlers
RedshiftPer node-hourUse Concurrency Scaling for peak loads
AthenaPer TB scannedUse 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

ZonePurposeFormatRetentionAccess
RawImmutable source data, exact copyJSON, CSV, AvroPermanentWrite-once
CleansedValidated, deduplicated, schema-enforcedParquet, ORC2-5 yearsRead-mostly
EnrichedJoins with reference data, business logic appliedParquet1-3 yearsRead-mostly
CuratedAggregated, analytics-ready datasetsParquet, Delta6 months-2 yearsRead-heavy
SandboxAd-hoc exploration, data science notebooksAny format30-90 daysRead-Write

Key Data Lake Best Practices

  1. Partition Strategy: Partition by date for time-series data (year=/month=/day=)
  2. File Format: Use Parquet with Snappy compression for analytical queries
  3. File Sizing: Target 256 MB - 1 GB per file to optimize Spark parallelism
  4. Metadata: Use Glue Data Catalog as the central metadata repository
  5. Governance: Implement Lake Formation for fine-grained access control
  6. Catalog: Run Glue Crawlers on a schedule to keep the catalog current

Data Lake vs Data Warehouse

AspectData LakeData Warehouse
Data TypesStructured, semi-structured, unstructuredPrimarily structured
SchemaSchema-on-readSchema-on-write
CostLower per TB (S3 pricing)Higher (compute + storage)
LatencyMinutes to hoursSeconds to minutes
UsersData engineers, data scientistsBusiness analysts
PurposeExploration, ML, batch analyticsReporting, 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:

  1. Producers emit events from IoT sensors, web/mobile apps, log agents, or database triggers
  2. Ingestion via Kinesis Data Streams or MSK buffers and durably stores events across shards/partitions
  3. 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
  4. Destinations receive processed data for storage, visualization, or alerting

Streaming vs Batch Comparison

AspectBatch ProcessingStream Processing
LatencyMinutes to hoursMilliseconds to seconds
ThroughputVery high per batchModerate per record
ComplexityModerateHigh (state management)
Cost ModelLower per GBHigher per record
Use CaseHistorical analyticsReal-time dashboards
Error HandlingRerun batchCheckpointing + replay
ToolsGlue, EMR, AthenaKinesis, 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

FactorKinesis Data StreamsAmazon MSK
ProtocolAWS SDK onlyKafka protocol (open)
ThroughputUp to 2 MB/shardScales horizontally
Consumer ModelPull (SDK) or Push (Lambda)Consumer groups
OrderingPer-shardPer-partition
ManagementFully managedSelf-managed brokers
Schema RegistryVia GlueConfluent Schema Registry
Best ForAWS-native, simple streamingKafka 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

ConsiderationRecommendation
ReconciliationPeriodically recompute batch views to correct streaming approximations
StorageUse S3 as the immutable source of truth for both layers
OrchestrationUse Step Functions for batch; EventBridge for stream triggers
MonitoringTrack lag in Kinesis; monitor Glue job duration and failures
IdempotencyDesign processors to handle duplicate events gracefully

Pattern 5: Event-Driven Microservices Architecture

Key Benefits of Event-Driven Architecture

BenefitDescription
Loose CouplingServices communicate via events, not direct calls
ScalabilityEach service scales independently
ResilienceFailure in one service does not cascade
ExtensibilityAdd new consumers without modifying producers
AuditabilityEventBridge provides full event history

EventBridge Rule Example

{
  "source": ["custom.order-service"],
  "detail-type": ["OrderPlaced"],
  "detail": {
    "status": ["confirmed"],
    "total": [{ "numeric": [">=", 100] }]
  }
}

Common Event Patterns

  1. Event Notification: Notify downstream systems of state changes
  2. Event-Carried State Transfer: Include full state in the event payload
  3. Event Sourcing: Store all state changes as a sequence of events
  4. 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

RequirementRecommended Pattern
Batch ETL with minimal opsServerless ETL (Lambda + Glue + S3)
Multi-format data lakeData Lake Architecture (S3 + Lake Formation)
Real-time dashboardsStreaming Architecture (Kinesis + Lambda)
Historical + real-timeHybrid Architecture (Lambda Architecture)
Microservices integrationEvent-Driven (EventBridge + Lambda)

Decision Factors

FactorBatchStreamingHybrid
Data FreshnessHoursSecondsBoth
ComplexityLow-MediumMedium-HighHigh
CostLowerHigherModerate
Operational OverheadLowMediumHigh
Best ForReporting, ML trainingMonitoring, alertsFull-stack analytics

AWS Service Quick Reference

CategoryServices
ComputeLambda, EC2, ECS, EKS, Fargate
StorageS3, EBS, EFS, FSx
DatabasesRDS, Aurora, DynamoDB, ElastiCache
ProcessingGlue, EMR, Athena, Redshift, Lake Formation
StreamingKinesis Data Streams, Kinesis Firehose, MSK, Managed Flink
IntegrationEventBridge, SQS, SNS, Step Functions
AnalyticsQuickSight, SageMaker, OpenSearch
SecurityIAM, KMS, VPC, Shield, WAF, Macie
MonitoringCloudWatch, 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:

  1. Ingestion: Use Kinesis Data Streams for real-time data or S3 Transfer Family for batch file transfers. For databases, AWS DMS handles CDC.

  2. Storage (Raw Zone): All incoming data lands in S3 organized as s3://bucket/raw/{source}/{year}/{month}/{day}/

  3. Cataloging: Glue Crawlers run on a schedule to discover schemas and populate the Glue Data Catalog.

  4. 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.

  5. Serving:

    • Athena for ad-hoc serverless queries
    • Redshift for complex analytical workloads and joins
    • OpenSearch for full-text search and log analytics
  6. Orchestration: Step Functions coordinate the pipeline with error handling, retry logic, and notification on failure.

  7. Visualization: QuickSight connects to Athena and Redshift for dashboards.

  8. 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:

  1. 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.

  2. Processing: Kinesis Data Analytics with Apache Flink for windowed aggregations (tumbling windows of 1 minute). Alternatively, use Lambda with Kinesis trigger for simpler transformations.

  3. Real-time Storage: DynamoDB with DAX (caching) for sub-millisecond reads of aggregated metrics. Use global tables for multi-region availability.

  4. Batch Rollup: Kinesis Firehose buffers data to S3 every 60 seconds. Glue jobs aggregate hourly/daily summaries into Redshift.

  5. Visualization: QuickSight with SPICE for dashboard rendering. Use refresh schedules aligned with data availability.

  6. 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:

ScenarioUse KDSUse Firehose
Real-time ML scoringYesNo
Log delivery to S3NoYes
Exactly-once requirementsYesNo
Schema conversion neededNoYes
Multi-consumer fan-outYesNo
Simple archivalNoYes

Q4: How do you handle schema evolution in a data lake?

Show Answer

Schema evolution strategies for S3-based data lakes:

  1. Partitioned Writes: Use Hive-style partitioning with dynamic partitions. New partitions automatically get the new schema.

  2. 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
  3. Glue Schema Registry: Register Avro/JSON schemas. Consumer applications detect schema changes and handle them gracefully.

  4. Column-Level Lineage: Use AWS Lake Formation to track which schema version each dataset uses.

  5. 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:

  1. Glue DataBrew: Visual data profiling with built-in quality rules. Detect anomalies, duplicates, and missing values before ETL.

  2. 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()
  1. Step Functions Validation Step: Add a Lambda validation step before downstream processing. If validation fails, write to quarantine S3 bucket and send SNS alert.

  2. CloudWatch Metrics: Emit custom metrics for record counts, null rates, and schema drift. Set alarms on thresholds.

  3. 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;
  1. 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
TechniqueEstimated Savings
S3 Intelligent-Tiering30-40%
EMR Spot Instances60-70%
Redshift Pause/Resume50-65%
Parquet compression75-90%
Lambda ARM6420%

Q9: How would you implement a CDC (Change Data Capture) pipeline on AWS?

Show Answer

AWS CDC Architecture:

  1. Source Database: Enable logical replication (PostgreSQL) or use Oracle LogMiner / SQL Server CDC feature.

  2. 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
  3. 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
  4. Processing: Lambda or Kinesis Data Analytics processes the CDC stream for:

    • Deduplication (last-write-wins or merge logic)
    • Schema transformation
    • Enrichment with reference data
  5. 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 window
  • LOBSupport: Full for LOB columns
  • ParallelLoadThreads: 4-8 for performance
  • ParallelLoadBufferSize: 500 for batch size

Q10: Explain how you would design a multi-region data architecture on AWS.

Show Answer

Multi-Region Data Architecture Patterns:

  1. 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
  2. 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
  3. 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:

ServiceMulti-Region Capability
DynamoDBGlobal Tables (active-active)
S3Cross-Region Replication
RedshiftCross-Region Snapshots
DMSCross-Region Replication Tasks
AuroraGlobal Database (read replicas)
SQSS2S 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

  1. No one-size-fits-all: Choose the pattern based on data volume, latency requirements, and team expertise
  2. Start simple: Begin with serverless patterns (Lambda + Glue + S3) and evolve as needs grow
  3. Decouple everything: Use SQS, SNS, and EventBridge to build resilient, independently deployable components
  4. Data governance first: Implement Lake Formation, IAM policies, and encryption from day one
  5. Cost awareness: Monitor per-pipeline costs; use lifecycle policies and right-sized resources
  6. Observability is critical: CloudWatch, X-Ray, and CloudTrail provide the visibility needed to debug and optimize

Recommended Reading

Knowledge Check

See Also

🔒

Premium Content

AWS Data Engineering Architecture Patterns

You've previewed the first section. Unlock this full lesson and 900+ advanced tutorials with a Premium plan.

đŸŽ¯End-to-end Projects
đŸ’ŧInterview Prep
📜Certificates
🤝Community Access

Already a member? Log in

Advertisement