Software Engineer • Talk about System Design, Distributed Systems and AI Agents • Building B2B SaaS

DM for Collab & Work ✉️
Joined February 2018
Most backend engineers learn in fragments A tutorial here, A Stack Overflow answer there. I spent 10 weeks building the complete picture. APIs → Caching → Queues → Load Balancing → Microservices → DB Scaling → API Gateway → Monitoring → Security → CI/CD 10 weeks, 10 articles, One foundation. Full series + all Medium articles in first reply 👇
32
74
1
462
34,348
if you're not a noob developer, solve this: a user updates their profile picture, but the old image keeps appearing. how would you fix it without disabling caching entirely?
14
20
365
Ritesh Roushan retweeted
before deploying code to production, check these 10 things: ☐ 1. environment variables & secrets ☐ 2. error handling ☐ 3. input validation ☐ 4. authentication & authorization ☐ 5. database migrations ☐ 6. logs & monitoring ☐ 7. unit & integration tests ☐ 8. API rate limiting ☐ 9. performance & security ☐ 10. rollback plan what would you add to this checklist?
29
7
91
1,616
before deploying code to production, check these 10 things: ☐ 1. environment variables & secrets ☐ 2. error handling ☐ 3. input validation ☐ 4. authentication & authorization ☐ 5. database migrations ☐ 6. logs & monitoring ☐ 7. unit & integration tests ☐ 8. API rate limiting ☐ 9. performance & security ☐ 10. rollback plan what would you add to this checklist?
29
7
91
1,616
Ritesh Roushan retweeted
7.8K developers follow me for system design, Thank you for every like, bookmark and reply. 3 things this journey taught me: → Production failures teach more than any textbook → Every system design answer is a tradeoff, never "the best" → Simple beats clever, almost every time Drop one topic you want me to break down next. Top 3 get a full post this week.
35
2
46
913
7.8K developers follow me for system design, Thank you for every like, bookmark and reply. 3 things this journey taught me: → Production failures teach more than any textbook → Every system design answer is a tradeoff, never "the best" → Simple beats clever, almost every time Drop one topic you want me to break down next. Top 3 get a full post this week.
35
2
46
913
Ritesh Roushan retweeted
developer, a simple question for you: your mobile app uses /api/v1/users, but you need to change the response structure. how do you avoid breaking existing users?
9
1
25
5,829
developer, a simple question for you: your mobile app uses /api/v1/users, but you need to change the response structure. how do you avoid breaking existing users?
9
1
25
5,829
Ritesh Roushan retweeted
a junior developer presents this system design to you, take a look at the approach. would you approve it for production, or ask them to change something first?
3
1
19
1,086
a junior developer presents this system design to you, take a look at the approach. would you approve it for production, or ask them to change something first?
3
1
19
1,086
Ritesh Roushan retweeted
17
1
24
819
Ritesh Roushan retweeted
every AI giant has a different strategy, who do you think will win the AI race: OpenAI, Anthropic, Google, Meta, xAI?
20
2
28
1,051
every AI giant has a different strategy, who do you think will win the AI race: OpenAI, Anthropic, Google, Meta, xAI?
20
2
28
1,051
Ritesh Roushan retweeted
two devs, same deadline A) spends 5 hours coding manually. B) ships in 1 hour using AI and verifies everything. who's the better engineer?
60
2
60
3,843
two devs, same deadline A) spends 5 hours coding manually. B) ships in 1 hour using AI and verifies everything. who's the better engineer?
60
2
60
3,843
Ritesh Roushan retweeted
which developer would you hire? A) uses AI to build faster B) writes everything from scratch speed or fundamentals?
43
2
42
1,763
which developer would you hire? A) uses AI to build faster B) writes everything from scratch speed or fundamentals?
43
2
42
1,763
Ritesh Roushan retweeted
System Design: How would you build an AI agent orchestration platform? Imagine asking 3 AI agents to complete one task: → Agent 1 writes the code. → Agent 2 reviews it. → Agent 3 runs tests before merging. Sounds simple, right? The real challenge is coordinating everything reliably. 1. Orchestration Layer - A central orchestrator assigns tasks, tracks workflow state, and coordinates agents. 2. Workflow Engine - Represent dependencies as a DAG. - Code writing must finish before review starts, and tests run after approval. - Independent tasks can execute in parallel. Each task follows a state machine: "PENDING → READY → RUNNING → COMPLETED" On failure: "RUNNING → RETRY_WAIT → READY" If retries are exhausted, the task moves to "FAILED". Persist state transitions so workflows can recover after crashes. A task becomes "READY" only when its dependencies are satisfied. 3. Execution Queue - Use Kafka or a durable job queue to distribute tasks to workers. - Workers claim jobs, execute them, and report results. - Use idempotency keys to prevent duplicate processing. 4. Failure Handling Failures are inevitable. Design for them. - Transient errors: Retry with exponential backoff and jitter. - Repeated failures: Move tasks to a dead-letter queue for investigation. - Worker crashes: Use leases and heartbeats to detect abandoned tasks and safely reassign them. - Model/API timeouts: Apply timeouts, retry limits, and circuit breakers. - Partial failures: Persist completed outputs so successful agents don't need to rerun unnecessarily. - Invalid agent output: Validate results before allowing dependent tasks to proceed. Never assume a retry means the previous execution didn't happen. Use idempotency and durable checkpoints to avoid duplicate side effects. 5. Shared Context - Store task instructions, agent outputs, code diffs, logs, and conversation history in shared storage. - Pass each agent only the context it needs. 6. Conflict Prevention - Give coding agents isolated Git branches or worktrees. - Validate diffs, run tests, and merge only after conflict checks and required approvals. 7. Observability & Cost Control - Track token usage, model costs, execution time, retries, and failure rates. - Set budgets and stop runaway workflows. 8. Pause, Resume & Cancel Persist workflow state in PostgreSQL. - Pause: Stop scheduling new tasks and let active workers reach safe checkpoints. - Resume: Requeue eligible tasks. - Cancel: Stop pending tasks and signal active workers to terminate safely. Keep "FAILED" and "CANCELLED" separate: one means execution failed; the other means execution was intentionally stopped. Architecture at a glance: Developer → API → Orchestrator → Workflow Engine → Durable Queue → Agent Workers Supporting services: - PostgreSQL - workflow state and checkpoints - Redis - caching and short-lived coordination - Object storage - logs, artifacts, and code outputs - Retry/DLQ mechanism - failed task recovery - Observability - logs, metrics, traces, and cost tracking The key principle: assume every component can fail, and make recovery part of the architecture. How would you prevent two agents from modifying the same files and accidentally overwriting each other's work?
System Design Problem: Design an AI Agent Orchestration Platform. A developer asks multiple AI agents to work on a large task. One agent writes code, another reviews it, and another runs tests before the changes are merged. Requirements: - Coordinate agents working on the same task - Manage task dependencies and execution order - Share context and results between agents - Handle agent failures and retry tasks - Prevent conflicting code changes - Track token usage and execution costs - Pause, resume, or cancel workflows How would you design the architecture?
43
25
168
4,766
System Design: How would you build an AI agent orchestration platform? Imagine asking 3 AI agents to complete one task: → Agent 1 writes the code. → Agent 2 reviews it. → Agent 3 runs tests before merging. Sounds simple, right? The real challenge is coordinating everything reliably. 1. Orchestration Layer - A central orchestrator assigns tasks, tracks workflow state, and coordinates agents. 2. Workflow Engine - Represent dependencies as a DAG. - Code writing must finish before review starts, and tests run after approval. - Independent tasks can execute in parallel. Each task follows a state machine: "PENDING → READY → RUNNING → COMPLETED" On failure: "RUNNING → RETRY_WAIT → READY" If retries are exhausted, the task moves to "FAILED". Persist state transitions so workflows can recover after crashes. A task becomes "READY" only when its dependencies are satisfied. 3. Execution Queue - Use Kafka or a durable job queue to distribute tasks to workers. - Workers claim jobs, execute them, and report results. - Use idempotency keys to prevent duplicate processing. 4. Failure Handling Failures are inevitable. Design for them. - Transient errors: Retry with exponential backoff and jitter. - Repeated failures: Move tasks to a dead-letter queue for investigation. - Worker crashes: Use leases and heartbeats to detect abandoned tasks and safely reassign them. - Model/API timeouts: Apply timeouts, retry limits, and circuit breakers. - Partial failures: Persist completed outputs so successful agents don't need to rerun unnecessarily. - Invalid agent output: Validate results before allowing dependent tasks to proceed. Never assume a retry means the previous execution didn't happen. Use idempotency and durable checkpoints to avoid duplicate side effects. 5. Shared Context - Store task instructions, agent outputs, code diffs, logs, and conversation history in shared storage. - Pass each agent only the context it needs. 6. Conflict Prevention - Give coding agents isolated Git branches or worktrees. - Validate diffs, run tests, and merge only after conflict checks and required approvals. 7. Observability & Cost Control - Track token usage, model costs, execution time, retries, and failure rates. - Set budgets and stop runaway workflows. 8. Pause, Resume & Cancel Persist workflow state in PostgreSQL. - Pause: Stop scheduling new tasks and let active workers reach safe checkpoints. - Resume: Requeue eligible tasks. - Cancel: Stop pending tasks and signal active workers to terminate safely. Keep "FAILED" and "CANCELLED" separate: one means execution failed; the other means execution was intentionally stopped. Architecture at a glance: Developer → API → Orchestrator → Workflow Engine → Durable Queue → Agent Workers Supporting services: - PostgreSQL - workflow state and checkpoints - Redis - caching and short-lived coordination - Object storage - logs, artifacts, and code outputs - Retry/DLQ mechanism - failed task recovery - Observability - logs, metrics, traces, and cost tracking The key principle: assume every component can fail, and make recovery part of the architecture. How would you prevent two agents from modifying the same files and accidentally overwriting each other's work?
System Design Problem: Design an AI Agent Orchestration Platform. A developer asks multiple AI agents to work on a large task. One agent writes code, another reviews it, and another runs tests before the changes are merged. Requirements: - Coordinate agents working on the same task - Manage task dependencies and execution order - Share context and results between agents - Handle agent failures and retry tasks - Prevent conflicting code changes - Track token usage and execution costs - Pause, resume, or cancel workflows How would you design the architecture?
43
25
168
4,766
Ritesh Roushan retweeted
I was asked this in an Uber SDE-1 interview last year. Problem: Design the low-level system for matching a rider with the nearest available driver. My answer: I’ll store drivers in a hash map keyed by driver ID. When a rider requests a ride, I’ll scan all online drivers, calculate distance for each, and pick the closest one. Then mark that driver as busy. But then they asked: How does this work when you have 50k online drivers in a city, and 200 ride requests come in at the same second? I knew the interview was cooked right there. What’s your response to get selected?
35
9
165
23,991