DEV Community

Aisalkyn Aidarova
Aisalkyn Aidarova

Posted on

Decoupled Architecture High-Level Architecture Overview

1️⃣ Start With The Problem (Always Start Here)

The problem was to design a system that accepts file uploads via HTTP and processes those files without blocking user requests, while ensuring scalability, reliability, and fault isolation.

Senior engineers always begin with the problem.


2️⃣ High-Level Architecture Overview

I designed a serverless, event-driven, decoupled architecture using API Gateway, Lambda, S3, SNS, and SQS.

The request layer is separated from the processing layer to avoid synchronous bottlenecks.

Then describe flow clearly:

Client
→ API Gateway
→ Web Lambda
→ S3
→ SNS
→ SQS
→ Worker Lambda
→ Processed Output


3️⃣ Explain Each Layer With Purpose

API Gateway (Edge Layer)

API Gateway acts as the HTTP entry point. It handles routing, request validation, throttling, and can support authentication if needed.

Key point:

  • Protects backend
  • Decouples internet traffic from compute

Web Lambda (Producer)

The web Lambda is responsible only for accepting the request and storing the file in S3. It immediately returns an acknowledgment response to the client, keeping latency low.

Key principle:
Single Responsibility Principle.

It does NOT process.


S3 (Durable Storage + Event Source)

S3 provides highly durable storage and also acts as an event source. When an object is created, it emits an event notification.

Important concept:
State change triggers event.


SNS (Pub/Sub Layer)

SNS acts as an event distribution system. It decouples the storage layer from downstream consumers and allows future expansion, such as adding additional processing services without modifying S3 configuration.

Key concept:
Loose coupling + extensibility.


SQS (Buffering + Reliability Layer)

SQS provides message durability and back-pressure handling. It ensures that messages are not lost and allows the system to handle traffic spikes gracefully.

This is senior-level thinking:

  • Absorbs load
  • Guarantees at-least-once delivery
  • Prevents worker overload

Worker Lambda (Consumer)

The worker Lambda consumes messages from SQS and performs background processing. It scales automatically based on queue depth and operates independently of the request layer.

Important:
Independent scaling.


4️⃣ Why This Architecture Is Superior

Now explain the “why” — this is where senior engineers stand out.


Asynchronous Processing

The architecture is asynchronous. The client receives immediate acknowledgment while processing occurs in the background, improving user experience and system throughput.


Decoupling

By separating the web and processing layers using SNS and SQS, we eliminate tight coupling. Failures in processing do not impact the request layer.


Scalability

Lambda scales horizontally based on concurrency, and SQS absorbs sudden traffic spikes. The web and worker layers scale independently.


Fault Tolerance

If the worker fails, SQS retains the message. Lambda retries automatically. We can also configure Dead Letter Queues for poison messages.


Extensibility

Since SNS is used, we can add additional subscribers (e.g., logging service, analytics service) without changing the core upload logic.


5️⃣ Discuss Failure Scenarios (Very Important)

Interviewer may ask: “What happens if something fails?”

You answer:

If Web Lambda fails:

  • No object stored
  • No event triggered

If Worker Lambda fails:

  • Message remains in SQS
  • Lambda retries
  • DLQ handles failed attempts

If traffic spikes:

  • SQS queues messages
  • Lambda scales based on queue depth

If processing is slow:

  • It does not affect user request latency

That is senior-level fault thinking.


6️⃣ Tradeoffs (This Is Where You Sound Senior)

The tradeoff of asynchronous architecture is eventual consistency. The client does not immediately receive the processed result and must poll for status or receive a callback.

Senior engineers always discuss tradeoffs.


7️⃣ Security Considerations

IAM roles enforce least privilege for each Lambda.
API Gateway can be secured with IAM, JWT, or Cognito.
S3 bucket policies restrict access.
Messages in SQS can be encrypted with KMS.


8️⃣ Observability

CloudWatch logs are used for tracing execution.
We can monitor SQS queue depth as a scaling metric.
X-Ray could be enabled for distributed tracing.

Senior engineers mention monitoring.


9️⃣ Cost Consideration

Since it’s serverless, we pay per request and per execution time. There are no idle compute costs, making it cost-efficient for variable workloads.


🔟 How You Close The Explanation

Finish with something strong:

Overall, this architecture follows cloud-native design principles such as loose coupling, event-driven communication, horizontal scalability, and fault isolation, making it production-ready and resilient under high load.


🔥 If They Push Further (Staff-Level Questions)

They may ask:

“How would you scale this to millions of uploads?”

You answer:

  • Increase Lambda concurrency
  • Monitor SQS depth
  • Use batching
  • Possibly shard queues
  • Consider using S3 event filtering
  • Add DLQ for poison messages

“How would you track job status?”

Answer:

  • Store job state in DynamoDB
  • Update status after worker completes
  • Provide GET /status endpoint

“What if files are very large?”

Answer:

  • Use pre-signed URLs
  • Direct browser-to-S3 upload
  • Avoid passing file through Lambda

🧠 Final Version You Can Memorize

Here is a polished final response:

I designed a serverless event-driven architecture where API Gateway handles HTTP traffic and invokes a lightweight web Lambda that stores files in S3. S3 generates events that are published to SNS and delivered to SQS, which acts as a buffering and reliability layer. A worker Lambda consumes messages from SQS and processes files asynchronously. This design ensures loose coupling, independent scaling, and fault isolation. It prevents blocking user requests, supports high throughput, and provides durable message delivery with automatic retries. The architecture follows cloud-native principles and is production-ready for scalable workloads.

That is senior-level.

Top comments (0)