Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

3.1.2.2. Loosely Coupled & Distributed Architectures

3.1.2.2. Loosely Coupled & Distributed Architectures

Tight coupling means one component's failure cascades to everything else. Loose coupling isolates failures and lets components scale independently.

Decoupling patterns:

Asynchronous messaging (SQS): Producer sends a message to a queue; consumer processes it later. If the consumer crashes, messages remain in the queue (no data loss). The producer never knows or cares about the consumer's state.

Pub/sub (SNS): One event triggers multiple subscribers simultaneously. Use for fan-out: a single order event notifies inventory, billing, and shipping services in parallel.

Event-driven (EventBridge): Rules match events to targets based on content patterns. Enables complex routing without the producer knowing about consumers.

Producer → SQS Queue → Consumer ASG
   ↓
  (Scales independently)
   
# SQS-based scaling: consumer ASG scales on queue depth
ScalingPolicy:
  TargetTrackingConfiguration:
    CustomizedMetricSpecification:
      MetricName: ApproximateNumberOfMessagesVisible
      Namespace: AWS/SQS
      Dimensions:
        - Name: QueueName
          Value: orders-queue
    TargetValue: 100  # ~100 messages per instance
Key design principles:
  • No synchronous chains: If Service A calls B which calls C synchronously, C's failure takes down A. Use queues between services.
  • Idempotent consumers: Messages may be delivered more than once (SQS at-least-once). Consumers must handle duplicates.
  • Dead letter queues (DLQ): Messages that fail processing N times go to a DLQ for investigation instead of blocking the main queue.

Exam Trap: SQS Standard queues provide at-least-once delivery and best-effort ordering. FIFO queues provide exactly-once processing and strict ordering — but are limited to 3,000 messages/second (with batching). If the exam requires strict ordering, the answer is SQS FIFO. If it requires high throughput (> 3K msg/s), the answer is SQS Standard with application-level deduplication.

Alvin Varughese
Written byAlvin Varughese•Founder•15 professional certifications