Q26Deployment
What is orchestration with Kubernetes?
Kubernetes schedules containers, reconciles desired replicas, and provides service networking, rollout, and health checks.
Answer
Kubernetes schedules containers, reconciles desired replicas, and provides service networking, rollout, and health checks.
Example: kubectl scale deployment/orders --replicas=4
Diagram / flow: Deployment -> ReplicaSet -> Pods
Syntax
kubectl scale deployment/orders --replicas=4
// Architecture flow
Deployment -> ReplicaSet -> Pods
Example
kubectl scale deployment/orders --replicas=4
// Architecture flow
Deployment -> ReplicaSet -> Pods
Code example
kubectl scale deployment/orders --replicas=4
// Architecture flow
Deployment -> ReplicaSet -> Pods
Diagram
Diagram / flow: Deployment -> ReplicaSet -> Pods
Key Points
- Kubernetes schedules containers, reconciles desired replicas, and provides service networking, rollout, and health checks.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q27Deployment
What are liveness and readiness probes?
Readiness determines whether a pod receives traffic
Answer
Readiness determines whether a pod receives traffic; liveness detects a stuck process and can trigger a restart. Avoid failing liveness on transient dependencies.
Example: readinessProbe: {httpGet: {path: /ready, port: 8080}}
Diagram / flow: LB -> Ready Pods only
Syntax
readinessProbe: {httpGet: {path: /ready, port: 8080}}
// Architecture flow
LB -> Ready Pods only
Example
readinessProbe: {httpGet: {path: /ready, port: 8080}}
// Architecture flow
LB -> Ready Pods only
Code example
readinessProbe: {httpGet: {path: /ready, port: 8080}}
// Architecture flow
LB -> Ready Pods only
Diagram
Diagram / flow: LB -> Ready Pods only
Key Points
- Readiness determines whether a pod receives traffic; liveness detects a stuck process and can trigger a restart.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q28Resilience
What is a circuit breaker?
A circuit breaker stops calls to a failing dependency after a threshold and probes recovery after a cool-down, preventing cascading failures.
Answer
A circuit breaker stops calls to a failing dependency after a threshold and probes recovery after a cool-down, preventing cascading failures.
Example: Closed -> Open -> HalfOpen -> Closed
Diagram / flow: Caller -> Breaker -X-> Failed Service
Syntax
Closed -> Open -> HalfOpen -> Closed
// Architecture flow
Caller -> Breaker -X-> Failed Service
Example
Closed -> Open -> HalfOpen -> Closed
// Architecture flow
Caller -> Breaker -X-> Failed Service
Code example
Closed -> Open -> HalfOpen -> Closed
// Architecture flow
Caller -> Breaker -X-> Failed Service
Diagram
Example: Closed -> Open -> HalfOpen -> Closed
Key Points
- A circuit breaker stops calls to a failing dependency after a threshold and probes recovery after a cool-down, preventing cascading failures.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q29Resilience
What are retries and exponential backoff?
Retries handle transient failures, but require bounded attempts, jitter, and idempotent operations to avoid amplifying overload.
Answer
Retries handle transient failures, but require bounded attempts, jitter, and idempotent operations to avoid amplifying overload.
Example: delay_ms = min(5000, 100 * 2**attempt) + jitter
Diagram / flow: Call -> Fail -> Wait -> Retry
Syntax
delay_ms = min(5000, 100 * 2**attempt) + jitter
// Architecture flow
Call -> Fail -> Wait -> Retry
Example
delay_ms = min(5000, 100 * 2**attempt) + jitter
// Architecture flow
Call -> Fail -> Wait -> Retry
Code example
delay_ms = min(5000, 100 * 2**attempt) + jitter
// Architecture flow
Call -> Fail -> Wait -> Retry
Diagram
Diagram / flow: Call -> Fail -> Wait -> Retry
Key Points
- Retries handle transient failures, but require bounded attempts, jitter, and idempotent operations to avoid amplifying overload.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q30Resilience
What is a timeout budget?
A timeout caps how long a dependency can hold resources
Answer
A timeout caps how long a dependency can hold resources; propagate an end-to-end deadline and reserve time for upstream processing.
Example: request_deadline_ms = 800; db_timeout_ms = 150
Diagram / flow: Gateway 800ms -> API 500ms -> DB 150ms
Syntax
request_deadline_ms = 800; db_timeout_ms = 150
// Architecture flow
Gateway 800ms -> API 500ms -> DB 150ms
Example
request_deadline_ms = 800; db_timeout_ms = 150
// Architecture flow
Gateway 800ms -> API 500ms -> DB 150ms
Code example
request_deadline_ms = 800; db_timeout_ms = 150
// Architecture flow
Gateway 800ms -> API 500ms -> DB 150ms
Diagram
Diagram / flow: Gateway 800ms -> API 500ms -> DB 150ms
Key Points
- A timeout caps how long a dependency can hold resources; propagate an end-to-end deadline and reserve time for upstream processing.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q31Resilience
What is bulkhead isolation?
Bulkheads allocate separate concurrency pools or resources per dependency or tenant, preventing one failing path from exhausting all capacity.
Answer
Bulkheads allocate separate concurrency pools or resources per dependency or tenant, preventing one failing path from exhausting all capacity.
Example: payment_pool=20; recommendation_pool=10
Diagram / flow: API -> Pool A / Pool B
Syntax
payment_pool=20; recommendation_pool=10
// Architecture flow
API -> Pool A / Pool B
Example
payment_pool=20; recommendation_pool=10
// Architecture flow
API -> Pool A / Pool B
Code example
payment_pool=20; recommendation_pool=10
// Architecture flow
API -> Pool A / Pool B
Diagram
Diagram / flow: API -> Pool A / Pool B
Key Points
- Bulkheads allocate separate concurrency pools or resources per dependency or tenant, preventing one failing path from exhausting all capacity.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q32Consistency
What is eventual consistency?
Eventual consistency means replicas or services may temporarily disagree but converge if updates stop
Answer
Eventual consistency means replicas or services may temporarily disagree but converge if updates stop; design UX and workflows around staleness.
Example: OrderCreated -> InventoryReserved (later)
Diagram / flow: Orders -> Event -> Inventory
Syntax
OrderCreated -> InventoryReserved (later)
// Architecture flow
Orders -> Event -> Inventory
Example
OrderCreated -> InventoryReserved (later)
// Architecture flow
Orders -> Event -> Inventory
Code example
OrderCreated -> InventoryReserved (later)
// Architecture flow
Orders -> Event -> Inventory
Diagram
Example: OrderCreated -> InventoryReserved (later)
Key Points
- Eventual consistency means replicas or services may temporarily disagree but converge if updates stop; design UX and workflows around staleness.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q33Consistency
What is strong consistency?
Strong consistency ensures operations observe a single agreed order under the chosen model, often increasing coordination costs.
Answer
Strong consistency ensures operations observe a single agreed order under the chosen model, often increasing coordination costs.
Example: transaction { debit(); credit(); }
Diagram / flow: Client -> Leader/Quorum -> Commit
Syntax
transaction { debit(); credit(); }
// Architecture flow
Client -> Leader/Quorum -> Commit
Example
transaction { debit(); credit(); }
// Architecture flow
Client -> Leader/Quorum -> Commit
Code example
transaction { debit(); credit(); }
// Architecture flow
Client -> Leader/Quorum -> Commit
Diagram
Diagram / flow: Client -> Leader/Quorum -> Commit
Key Points
- Strong consistency ensures operations observe a single agreed order under the chosen model, often increasing coordination costs.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q34Distributed Systems
What is the CAP theorem?
Under a network partition, a distributed data system must trade off availability of responses against linearizable consistency
Answer
Under a network partition, a distributed data system must trade off availability of responses against linearizable consistency; CAP does not say choose only two in normal operation.
Example: partition: choose reject stale writes OR accept divergent writes
Diagram / flow: Node A -X- Node B (partition)
Syntax
partition: choose reject stale writes OR accept divergent writes
// Architecture flow
Node A -X- Node B (partition)
Example
partition: choose reject stale writes OR accept divergent writes
// Architecture flow
Node A -X- Node B (partition)
Code example
partition: choose reject stale writes OR accept divergent writes
// Architecture flow
Node A -X- Node B (partition)
Diagram
Diagram / flow: Node A -X- Node B (partition)
Key Points
- Under a network partition, a distributed data system must trade off availability of responses against linearizable consistency; CAP does not say choose only two in normal operation.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q35Transactions
What is a distributed transaction?
A distributed transaction coordinates changes across independent participants
Answer
A distributed transaction coordinates changes across independent participants; it adds latency and failure complexity, so prefer local transactions plus workflows when feasible.
Example: prepare -> vote -> commit/abort
Diagram / flow: Coordinator -> DB A + DB B
Syntax
prepare -> vote -> commit/abort
// Architecture flow
Coordinator -> DB A + DB B
Example
prepare -> vote -> commit/abort
// Architecture flow
Coordinator -> DB A + DB B
Code example
prepare -> vote -> commit/abort
// Architecture flow
Coordinator -> DB A + DB B
Diagram
Example: prepare -> vote -> commit/abort
Key Points
- A distributed transaction coordinates changes across independent participants; it adds latency and failure complexity, so prefer local transactions plus workflows when feasible.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q36Transactions
What is the Saga pattern?
A saga coordinates local transactions through events or commands and uses compensating actions to recover from partial failure.
Answer
A saga coordinates local transactions through events or commands and uses compensating actions to recover from partial failure.
Example: ReserveStock -> ChargeCard -> Ship; failure -> Refund
Diagram / flow: Order -> Stock -> Payment -> Shipping
Syntax
ReserveStock -> ChargeCard -> Ship; failure -> Refund
// Architecture flow
Order -> Stock -> Payment -> Shipping
Example
ReserveStock -> ChargeCard -> Ship; failure -> Refund
// Architecture flow
Order -> Stock -> Payment -> Shipping
Code example
ReserveStock -> ChargeCard -> Ship; failure -> Refund
// Architecture flow
Order -> Stock -> Payment -> Shipping
Diagram
Example: ReserveStock -> ChargeCard -> Ship; failure -> Refund
Key Points
- A saga coordinates local transactions through events or commands and uses compensating actions to recover from partial failure.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q37Transactions
Choreography vs orchestration in sagas?
Choreography reacts to events without a central controller
Answer
Choreography reacts to events without a central controller; orchestration uses a workflow coordinator, improving visibility at the cost of central coordination.
Example: on OrderCreated -> ReserveInventory
Diagram / flow: Events <-> Services OR Orchestrator -> Services
Syntax
on OrderCreated -> ReserveInventory
// Architecture flow
Events <-> Services OR Orchestrator -> Services
Example
on OrderCreated -> ReserveInventory
// Architecture flow
Events <-> Services OR Orchestrator -> Services
Code example
on OrderCreated -> ReserveInventory
// Architecture flow
Events <-> Services OR Orchestrator -> Services
Diagram
Example: on OrderCreated -> ReserveInventory
Key Points
- Choreography reacts to events without a central controller; orchestration uses a workflow coordinator, improving visibility at the cost of central coordination.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q38Messaging
What is the outbox pattern?
The transactional outbox stores an event in the same database transaction as business state
Answer
The transactional outbox stores an event in the same database transaction as business state; a relay later publishes it, preventing dual-write gaps.
Example: BEGIN; UPDATE orders ...; INSERT INTO outbox ...; COMMIT;
Diagram / flow: Service -> DB(order + outbox) -> Relay -> Broker
Syntax
BEGIN; UPDATE orders ...; INSERT INTO outbox ...; COMMIT;
// Architecture flow
Service -> DB(order + outbox) -> Relay -> Broker
Example
BEGIN; UPDATE orders ...; INSERT INTO outbox ...; COMMIT;
// Architecture flow
Service -> DB(order + outbox) -> Relay -> Broker
Code example
BEGIN; UPDATE orders ...; INSERT INTO outbox ...; COMMIT;
// Architecture flow
Service -> DB(order + outbox) -> Relay -> Broker
Diagram
Diagram / flow: Service -> DB(order + outbox) -> Relay -> Broker
Key Points
- The transactional outbox stores an event in the same database transaction as business state; a relay later publishes it, preventing dual-write gaps.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q39Messaging
What is the inbox pattern?
An inbox records processed message identifiers so a consumer can ignore redeliveries and apply business changes once per key.
Answer
An inbox records processed message identifiers so a consumer can ignore redeliveries and apply business changes once per key.
Example: INSERT INTO inbox(message_id) ON CONFLICT DO NOTHING;
Diagram / flow: Broker -> Consumer -> Inbox dedupe -> DB
Syntax
INSERT INTO inbox(message_id) ON CONFLICT DO NOTHING;
// Architecture flow
Broker -> Consumer -> Inbox dedupe -> DB
Example
INSERT INTO inbox(message_id) ON CONFLICT DO NOTHING;
// Architecture flow
Broker -> Consumer -> Inbox dedupe -> DB
Code example
INSERT INTO inbox(message_id) ON CONFLICT DO NOTHING;
// Architecture flow
Broker -> Consumer -> Inbox dedupe -> DB
Diagram
Diagram / flow: Broker -> Consumer -> Inbox dedupe -> DB
Key Points
- An inbox records processed message identifiers so a consumer can ignore redeliveries and apply business changes once per key.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q40Messaging
At-most-once vs at-least-once delivery?
At-most-once may lose messages but avoids redelivery
Answer
At-most-once may lose messages but avoids redelivery; at-least-once retries and can duplicate, so consumers must be idempotent.
Example: ack after durable commit => at-least-once behavior
Diagram / flow: Broker -> Delivery -> Ack / Retry
Syntax
ack after durable commit => at-least-once behavior
// Architecture flow
Broker -> Delivery -> Ack / Retry
Example
ack after durable commit => at-least-once behavior
// Architecture flow
Broker -> Delivery -> Ack / Retry
Code example
ack after durable commit => at-least-once behavior
// Architecture flow
Broker -> Delivery -> Ack / Retry
Diagram
Diagram / flow: Broker -> Delivery -> Ack / Retry
Key Points
- At-most-once may lose messages but avoids redelivery; at-least-once retries and can duplicate, so consumers must be idempotent.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q41Messaging
Exactly-once processing: what does it mean?
Exactly-once is scoped to a system boundary
Answer
Exactly-once is scoped to a system boundary; end-to-end effects usually require transactions, deduplication, and idempotency rather than trusting a broker label.
Example: unique(event_id) + business transaction
Diagram / flow: Message -> Dedupe -> Transaction -> Effect
Syntax
unique(event_id) + business transaction
// Architecture flow
Message -> Dedupe -> Transaction -> Effect
Example
unique(event_id) + business transaction
// Architecture flow
Message -> Dedupe -> Transaction -> Effect
Code example
unique(event_id) + business transaction
// Architecture flow
Message -> Dedupe -> Transaction -> Effect
Diagram
Diagram / flow: Message -> Dedupe -> Transaction -> Effect
Key Points
- Exactly-once is scoped to a system boundary; end-to-end effects usually require transactions, deduplication, and idempotency rather than trusting a broker label.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q42Architecture
What is event-driven architecture?
Services publish facts about completed state changes and subscribe to relevant events, reducing temporal coupling but complicating tracing and schema evolution.
Answer
Services publish facts about completed state changes and subscribe to relevant events, reducing temporal coupling but complicating tracing and schema evolution.
Example: event: {type:'OrderPlaced',version:1,orderId:'o1'}
Diagram / flow: Orders -> Event Bus -> Billing / Analytics
Syntax
event: {type:'OrderPlaced',version:1,orderId:'o1'}
// Architecture flow
Orders -> Event Bus -> Billing / Analytics
Example
event: {type:'OrderPlaced',version:1,orderId:'o1'}
// Architecture flow
Orders -> Event Bus -> Billing / Analytics
Code example
event: {type:'OrderPlaced',version:1,orderId:'o1'}
// Architecture flow
Orders -> Event Bus -> Billing / Analytics
Diagram
Diagram / flow: Orders -> Event Bus -> Billing / Analytics
Key Points
- Services publish facts about completed state changes and subscribe to relevant events, reducing temporal coupling but complicating tracing and schema evolution.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q43Data
What is event sourcing?
Event sourcing stores an append-only history of state-changing events and derives current state by replay
Answer
Event sourcing stores an append-only history of state-changing events and derives current state by replay; projections and schema evolution require care.
Example: AccountOpened; MoneyDeposited; MoneyWithdrawn
Diagram / flow: Events -> Projection -> Read Model
Syntax
AccountOpened; MoneyDeposited; MoneyWithdrawn
// Architecture flow
Events -> Projection -> Read Model
Example
AccountOpened; MoneyDeposited; MoneyWithdrawn
// Architecture flow
Events -> Projection -> Read Model
Code example
AccountOpened; MoneyDeposited; MoneyWithdrawn
// Architecture flow
Events -> Projection -> Read Model
Diagram
Diagram / flow: Events -> Projection -> Read Model
Key Points
- Event sourcing stores an append-only history of state-changing events and derives current state by replay; projections and schema evolution require care.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q44Data
What is CQRS?
CQRS separates command handling from query models when read and write needs differ
Answer
CQRS separates command handling from query models when read and write needs differ; it adds synchronization and operational complexity.
Example: POST /orders -> write; GET /orders -> read projection
Diagram / flow: Commands -> Write DB -> Events -> Read DB
Syntax
POST /orders -> write; GET /orders -> read projection
// Architecture flow
Commands -> Write DB -> Events -> Read DB
Example
POST /orders -> write; GET /orders -> read projection
// Architecture flow
Commands -> Write DB -> Events -> Read DB
Code example
POST /orders -> write; GET /orders -> read projection
// Architecture flow
Commands -> Write DB -> Events -> Read DB
Diagram
Example: POST /orders -> write; GET /orders -> read projection
Key Points
- CQRS separates command handling from query models when read and write needs differ; it adds synchronization and operational complexity.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q45API
What is API versioning?
Versioning manages breaking changes while supporting existing consumers
Answer
Versioning manages breaking changes while supporting existing consumers; prefer additive changes and a published deprecation policy.
Example: GET /v2/orders/{id}
Diagram / flow: v1 clients -> v1 API; v2 clients -> v2 API
Syntax
GET /v2/orders/{id}
// Architecture flow
v1 clients -> v1 API; v2 clients -> v2 API
Example
GET /v2/orders/{id}
// Architecture flow
v1 clients -> v1 API; v2 clients -> v2 API
Code example
GET /v2/orders/{id}
// Architecture flow
v1 clients -> v1 API; v2 clients -> v2 API
Diagram
Diagram / flow: v1 clients -> v1 API; v2 clients -> v2 API
Key Points
- Versioning manages breaking changes while supporting existing consumers; prefer additive changes and a published deprecation policy.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q46Communication
REST vs gRPC?
REST commonly uses HTTP resources and JSON
Answer
REST commonly uses HTTP resources and JSON; gRPC uses protobuf contracts and HTTP/2, often suited to internal typed RPC and streaming.
Example: rpc GetOrder(GetOrderRequest) returns (Order);
Diagram / flow: Client -> REST/JSON OR gRPC/Protobuf
Syntax
rpc GetOrder(GetOrderRequest) returns (Order);
// Architecture flow
Client -> REST/JSON OR gRPC/Protobuf
Example
rpc GetOrder(GetOrderRequest) returns (Order);
// Architecture flow
Client -> REST/JSON OR gRPC/Protobuf
Code example
rpc GetOrder(GetOrderRequest) returns (Order);
// Architecture flow
Client -> REST/JSON OR gRPC/Protobuf
Diagram
Diagram / flow: Client -> REST/JSON OR gRPC/Protobuf
Key Points
- REST commonly uses HTTP resources and JSON; gRPC uses protobuf contracts and HTTP/2, often suited to internal typed RPC and streaming.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q47Networking
What is service mesh?
A service mesh uses proxies and a control plane to standardize service-to-service traffic security, telemetry, and routing
Answer
A service mesh uses proxies and a control plane to standardize service-to-service traffic security, telemetry, and routing; it adds operational overhead.
Example: mTLS between service sidecars
Diagram / flow: Service A -> Proxy A -> Proxy B -> Service B
Syntax
mTLS between service sidecars
// Architecture flow
Service A -> Proxy A -> Proxy B -> Service B
Example
mTLS between service sidecars
// Architecture flow
Service A -> Proxy A -> Proxy B -> Service B
Code example
mTLS between service sidecars
// Architecture flow
Service A -> Proxy A -> Proxy B -> Service B
Diagram
Diagram / flow: Service A -> Proxy A -> Proxy B -> Service B
Key Points
- A service mesh uses proxies and a control plane to standardize service-to-service traffic security, telemetry, and routing; it adds operational overhead.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q48Security
What is zero-trust security?
Zero trust authenticates and authorizes each access regardless of network location
Answer
Zero trust authenticates and authorizes each access regardless of network location; use identity, least privilege, and short-lived credentials.
Example: allow if principal=orders && action=inventory.read
Diagram / flow: Identity -> Policy -> Service
Syntax
allow if principal=orders && action=inventory.read
// Architecture flow
Identity -> Policy -> Service
Example
allow if principal=orders && action=inventory.read
// Architecture flow
Identity -> Policy -> Service
Code example
allow if principal=orders && action=inventory.read
// Architecture flow
Identity -> Policy -> Service
Diagram
Diagram / flow: Identity -> Policy -> Service
Key Points
- Zero trust authenticates and authorizes each access regardless of network location; use identity, least privilege, and short-lived credentials.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q49Security
OAuth 2.0 vs OpenID Connect?
OAuth 2.0 delegates API authorization
Answer
OAuth 2.0 delegates API authorization; OpenID Connect adds identity authentication with an ID token on top of OAuth.
Example: Authorization: Bearer <access_token>
Diagram / flow: User -> IdP -> Access Token -> API
Syntax
Authorization: Bearer <access_token>
// Architecture flow
User -> IdP -> Access Token -> API
Example
Authorization: Bearer <access_token>
// Architecture flow
User -> IdP -> Access Token -> API
Code example
Authorization: Bearer <access_token>
// Architecture flow
User -> IdP -> Access Token -> API
Diagram
Diagram / flow: User -> IdP -> Access Token -> API
Key Points
- OAuth 2.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q50Security
What is JWT validation?
Validate signature, issuer, audience, expiry, and allowed algorithm before trusting claims
Answer
Validate signature, issuer, audience, expiry, and allowed algorithm before trusting claims; do not treat a decoded token as verified.
Example: verify(jwt,{issuer:'https://idp',audience:'orders-api'})
Diagram / flow: Client -> JWT Validator -> Endpoint
Syntax
verify(jwt,{issuer:'https://idp',audience:'orders-api'})
// Architecture flow
Client -> JWT Validator -> Endpoint
Example
verify(jwt,{issuer:'https://idp',audience:'orders-api'})
// Architecture flow
Client -> JWT Validator -> Endpoint
Code example
verify(jwt,{issuer:'https://idp',audience:'orders-api'})
// Architecture flow
Client -> JWT Validator -> Endpoint
Diagram
Diagram / flow: Client -> JWT Validator -> Endpoint
Key Points
- Validate signature, issuer, audience, expiry, and allowed algorithm before trusting claims; do not treat a decoded token as verified.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q51Security
What is mTLS?
Mutual TLS authenticates both ends of a connection using certificates, useful for workload identity inside a trusted PKI.
Answer
Mutual TLS authenticates both ends of a connection using certificates, useful for workload identity inside a trusted PKI.
Example: client cert + server cert -> TLS handshake
Diagram / flow: Service A <== mTLS ==> Service B
Syntax
client cert + server cert -> TLS handshake
// Architecture flow
Service A <== mTLS ==> Service B
Example
client cert + server cert -> TLS handshake
// Architecture flow
Service A <== mTLS ==> Service B
Code example
client cert + server cert -> TLS handshake
// Architecture flow
Service A <== mTLS ==> Service B
Diagram
Example: client cert + server cert -> TLS handshake
Key Points
- Mutual TLS authenticates both ends of a connection using certificates, useful for workload identity inside a trusted PKI.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q52Security
What is secrets management?
Store credentials in a managed secret store, restrict access, rotate secrets, and avoid embedding them in images or source control.
Answer
Store credentials in a managed secret store, restrict access, rotate secrets, and avoid embedding them in images or source control.
Example: DB_PASSWORD <- secret manager at runtime
Diagram / flow: Pod -> Identity -> Secret Store
Syntax
DB_PASSWORD <- secret manager at runtime
// Architecture flow
Pod -> Identity -> Secret Store
Example
DB_PASSWORD <- secret manager at runtime
// Architecture flow
Pod -> Identity -> Secret Store
Code example
DB_PASSWORD <- secret manager at runtime
// Architecture flow
Pod -> Identity -> Secret Store
Diagram
Diagram / flow: Pod -> Identity -> Secret Store
Key Points
- Store credentials in a managed secret store, restrict access, rotate secrets, and avoid embedding them in images or source control.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q53Observability
What is observability?
Observability combines metrics, logs, and traces to explain internal behavior from outputs
Answer
Observability combines metrics, logs, and traces to explain internal behavior from outputs; correlate using trace and request IDs.
Example: trace_id=abc123 span=payment.charge duration_ms=42
Diagram / flow: Service -> Metrics / Logs / Traces
Syntax
trace_id=abc123 span=payment.charge duration_ms=42
// Architecture flow
Service -> Metrics / Logs / Traces
Example
trace_id=abc123 span=payment.charge duration_ms=42
// Architecture flow
Service -> Metrics / Logs / Traces
Code example
trace_id=abc123 span=payment.charge duration_ms=42
// Architecture flow
Service -> Metrics / Logs / Traces
Diagram
Diagram / flow: Service -> Metrics / Logs / Traces
Key Points
- Observability combines metrics, logs, and traces to explain internal behavior from outputs; correlate using trace and request IDs.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q54Observability
What is distributed tracing?
Distributed tracing links spans across service boundaries to reveal critical path latency and failures
Answer
Distributed tracing links spans across service boundaries to reveal critical path latency and failures; propagate trace context.
Example: traceparent: 00-<traceid>-<spanid>-01
Diagram / flow: Gateway -> Orders(span) -> Billing(span)
Syntax
traceparent: 00-<traceid>-<spanid>-01
// Architecture flow
Gateway -> Orders(span) -> Billing(span)
Example
traceparent: 00-<traceid>-<spanid>-01
// Architecture flow
Gateway -> Orders(span) -> Billing(span)
Code example
traceparent: 00-<traceid>-<spanid>-01
// Architecture flow
Gateway -> Orders(span) -> Billing(span)
Diagram
Diagram / flow: Gateway -> Orders(span) -> Billing(span)
Key Points
- Distributed tracing links spans across service boundaries to reveal critical path latency and failures; propagate trace context.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q55Reliability
What are SLI, SLO, and SLA?
SLI is a measured indicator, SLO its target, and SLA a contractual commitment with consequences
Answer
SLI is a measured indicator, SLO its target, and SLA a contractual commitment with consequences; define an error budget for SLO breaches.
Example: SLO: 99.9% successful requests over 30 days
Diagram / flow: Requests -> SLI -> SLO -> Error budget
Syntax
SLO: 99.9% successful requests over 30 days
// Architecture flow
Requests -> SLI -> SLO -> Error budget
Example
SLO: 99.9% successful requests over 30 days
// Architecture flow
Requests -> SLI -> SLO -> Error budget
Code example
SLO: 99.9% successful requests over 30 days
// Architecture flow
Requests -> SLI -> SLO -> Error budget
Diagram
Diagram / flow: Requests -> SLI -> SLO -> Error budget
Key Points
- SLI is a measured indicator, SLO its target, and SLA a contractual commitment with consequences; define an error budget for SLO breaches.
- Discuss trade-offs, failure modes, and operational impact.
- Validate assumptions against latency, throughput, and reliability requirements.
Q82Distributed services
What is service discovery in a microservices system?
Service discovery lets clients or proxies locate healthy service instances without hardcoding ephemeral addresses. Discovery may be client-side o
Answer
Service discovery lets clients or proxies locate healthy service instances without hardcoding ephemeral addresses. Discovery may be client-side or server-side and is often integrated with a platform or service mesh.
Example: Orders API → DNS/service registry → currently healthy Payments endpoint.
Diagram / flow: Caller → service name → discovery layer → healthy instance
Syntax
service-name → registry/DNS → healthy endpoint
Example
Orders API → DNS/service registry → currently healthy Payments endpoint.
Code example
service-name → registry/DNS → healthy endpoint
Diagram
Caller → service name → discovery layer → healthy instance
Key Points
- Service discovery lets clients or proxies locate healthy service instances without hardcoding ephemeral addresses.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q85Caching
Why is cache invalidation difficult in distributed systems?
Cached copies can become stale after writes, and invalidation messages can be delayed or lost. Define freshness requirements, use bounded TTLs an
Answer
Cached copies can become stale after writes, and invalidation messages can be delayed or lost. Define freshness requirements, use bounded TTLs and versioning, and consider outbox-driven invalidation when stronger delivery guarantees are needed.
Example: Update product price → commit DB and outbox event → consumer invalidates product key.
Diagram / flow: Database commit → event delivery → cache eviction; TTL bounds stale lifetime
Syntax
write DB → publish invalidation event → evict/update cache
Example
Update product price → commit DB and outbox event → consumer invalidates product key.
Code example
write DB → publish invalidation event → evict/update cache
Diagram
Database commit → event delivery → cache eviction; TTL bounds stale lifetime
Key Points
- Cached copies can become stale after writes, and invalidation messages can be delayed or lost.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q86Caching
How do you choose Redis data structures?
Strings suit simple values/counters, hashes suit field collections, sets suit uniqueness, sorted sets suit ranking, and streams support append-or
Answer
Strings suit simple values/counters, hashes suit field collections, sets suit uniqueness, sorted sets suit ranking, and streams support append-oriented event consumption. Select by operations and memory behavior, not familiarity alone.
Example: Use a sorted set for a leaderboard ranked by score.
Diagram / flow: Application operation → appropriate Redis structure → query/update
Syntax
SET key value; HSET user:1 name Ava; ZADD rank 10 user1
Example
Use a sorted set for a leaderboard ranked by score.
Code example
SET key value; HSET user:1 name Ava; ZADD rank 10 user1
Diagram
Application operation → appropriate Redis structure → query/update
Key Points
- Strings suit simple values/counters, hashes suit field collections, sets suit uniqueness, sorted sets suit ranking, and streams support append-oriented event consumption.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q90Resilience
Explain the Bulkhead pattern.
Bulkheads isolate resource pools or dependencies so saturation in one area does not consume all capacity. Separate connection pools, concurrency
Answer
Bulkheads isolate resource pools or dependencies so saturation in one area does not consume all capacity. Separate connection pools, concurrency limits, and queues can prevent cascading failures.
Example: Limit report-generation concurrency separately from checkout traffic.
Diagram / flow: Checkout pool isolated from reporting pool; reporting saturation does not exhaust checkout
Syntax
perDependencyConcurrencyLimit = N
Example
Limit report-generation concurrency separately from checkout traffic.
Code example
perDependencyConcurrencyLimit = N
Diagram
Checkout pool isolated from reporting pool; reporting saturation does not exhaust checkout
Key Points
- Bulkheads isolate resource pools or dependencies so saturation in one area does not consume all capacity.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q91Resilience
How should retries with exponential backoff be designed?
Retry only transient failures and operations safe to repeat, cap attempts, add jitter, and honor deadlines/cancellation. Unbounded or synchronize
Answer
Retry only transient failures and operations safe to repeat, cap attempts, add jitter, and honor deadlines/cancellation. Unbounded or synchronized retries can amplify an outage.
Example: Retry a transient 503 up to three times with randomized increasing delay.
Diagram / flow: Transient error → bounded backoff+jitter → retry until success or budget exhausted
Syntax
delay = min(cap, base × 2^attempt) + jitter
Example
Retry a transient 503 up to three times with randomized increasing delay.
Code example
delay = min(cap, base × 2^attempt) + jitter
Diagram
Transient error → bounded backoff+jitter → retry until success or budget exhausted
Key Points
- Retry only transient failures and operations safe to repeat, cap attempts, add jitter, and honor deadlines/cancellation.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q93Resilience
What are the states of a circuit breaker?
Closed allows calls while tracking failures; open rejects calls temporarily; half-open permits limited probes. Configure thresholds and recovery
Answer
Closed allows calls while tracking failures; open rejects calls temporarily; half-open permits limited probes. Configure thresholds and recovery windows using observed dependency behavior.
Example: Repeated payment provider failures open the circuit; a later probe tests recovery.
Diagram / flow: Failures exceed threshold → Open → wait → Half-open probe → recover or reopen
Syntax
Closed → Open → Half-open → Closed/Open
Example
Repeated payment provider failures open the circuit; a later probe tests recovery.
Code example
Closed → Open → Half-open → Closed/Open
Diagram
Failures exceed threshold → Open → wait → Half-open probe → recover or reopen
Key Points
- Closed allows calls while tracking failures; open rejects calls temporarily; half-open permits limited probes.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q96Messaging
How can a consumer safely handle duplicate messages?
Assign a stable message ID and record processed IDs atomically with the business change. If the ID has already been applied, acknowledge without
Answer
Assign a stable message ID and record processed IDs atomically with the business change. If the ID has already been applied, acknowledge without repeating the side effect.
Example: Unique constraint on ProcessedMessages.MessageId prevents duplicate application.
Diagram / flow: Message → deduplication check → apply transaction once → acknowledge
Syntax
if processed(messageId) then ack else apply + record atomically
Example
Unique constraint on ProcessedMessages.MessageId prevents duplicate application.
Code example
if processed(messageId) then ack else apply + record atomically
Diagram
Message → deduplication check → apply transaction once → acknowledge
Key Points
- Assign a stable message ID and record processed IDs atomically with the business change.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q99Resilience
How should distributed APIs implement rate limiting?
Choose a key such as API consumer, user, or tenant; select fixed-window, sliding-window, token-bucket, or leaky-bucket semantics; return 429 with
Answer
Choose a key such as API consumer, user, or tenant; select fixed-window, sliding-window, token-bucket, or leaky-bucket semantics; return 429 with retry guidance. Multi-instance systems need shared or coordinated state when global limits matter.
Example: Tenant A has 100 requests/minute across all API instances, not 100 per instance.
Diagram / flow: Request identity → shared limiter state → allow or HTTP 429
Syntax
token bucket: tokens = min(capacity, tokens + elapsed × refillRate)
Example
Tenant A has 100 requests/minute across all API instances, not 100 per instance.
Code example
token bucket: tokens = min(capacity, tokens + elapsed × refillRate)
Diagram
Request identity → shared limiter state → allow or HTTP 429
Key Points
- Choose a key such as API consumer, user, or tenant; select fixed-window, sliding-window, token-bucket, or leaky-bucket semantics; return 429 with retry guidance.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q101Scalability
What is backpressure in a distributed service?
Backpressure communicates that a consumer cannot safely accept more work. Bounded queues, demand-aware streams, and producer throttling keep memo
Answer
Backpressure communicates that a consumer cannot safely accept more work. Bounded queues, demand-aware streams, and producer throttling keep memory and latency from growing without bound.
Example: A worker pool slows message intake when its queue reaches capacity.
Diagram / flow: Producer → bounded queue → workers; full queue slows or rejects producer
Syntax
boundedQueue(capacity=N); producer waits or rejects when full
Example
A worker pool slows message intake when its queue reaches capacity.
Code example
boundedQueue(capacity=N); producer waits or rejects when full
Diagram
Producer → bounded queue → workers; full queue slows or rejects producer
Key Points
- Backpressure communicates that a consumer cannot safely accept more work.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q102Architecture
What problems can a service mesh solve, and what are its trade-offs?
A service mesh can centralize service-to-service mTLS, traffic policy, telemetry, and retries at the proxy layer. It adds sidecar/proxy resources
Answer
A service mesh can centralize service-to-service mTLS, traffic policy, telemetry, and retries at the proxy layer. It adds sidecar/proxy resources, configuration complexity, and another operational control plane.
Example: Apply mTLS and traffic shifting consistently without duplicating all transport code in services.
Diagram / flow: Service A → proxy/control policies → proxy → Service B
Syntax
service A proxy ⇄ mTLS ⇄ service B proxy
Example
Apply mTLS and traffic shifting consistently without duplicating all transport code in services.
Code example
service A proxy ⇄ mTLS ⇄ service B proxy
Diagram
Service A → proxy/control policies → proxy → Service B
Key Points
- A service mesh can centralize service-to-service mTLS, traffic policy, telemetry, and retries at the proxy layer.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q104Microservices
Why do microservices often own their databases?
Database ownership limits schema coupling and lets services evolve independently. Cross-service queries and transactions become harder, so use AP
Answer
Database ownership limits schema coupling and lets services evolve independently. Cross-service queries and transactions become harder, so use APIs, events, and read projections rather than direct shared-table access.
Example: Orders publishes OrderCreated; Analytics builds its own read projection.
Diagram / flow: Orders Service → Orders DB; Billing Service → Billing DB; events connect them
Syntax
Service A → database A; Service B → database B
Example
Orders publishes OrderCreated; Analytics builds its own read projection.
Code example
Service A → database A; Service B → database B
Diagram
Orders Service → Orders DB; Billing Service → Billing DB; events connect them
Key Points
- Database ownership limits schema coupling and lets services evolve independently.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q105Observability
How does distributed tracing help debug latency?
Trace context connects spans across service boundaries. Traces reveal where time is spent and which dependency adds latency; sampling, propagatio
Answer
Trace context connects spans across service boundaries. Traces reveal where time is spent and which dependency adds latency; sampling, propagation, and sensitive-data controls must be configured.
Example: Gateway span contains order, inventory, and payment child spans; payment span shows delay.
Diagram / flow: Gateway span → Orders span → Inventory/Payment spans
Syntax
traceId + parentSpanId propagated in request context
Example
Gateway span contains order, inventory, and payment child spans; payment span shows delay.
Code example
traceId + parentSpanId propagated in request context
Diagram
Gateway span → Orders span → Inventory/Payment spans
Key Points
- Trace context connects spans across service boundaries.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q107Resilience
How should a service shut down gracefully?
Stop accepting new work, mark the instance unready, allow in-flight requests or messages to finish within a deadline, then release resources. Han
Answer
Stop accepting new work, mark the instance unready, allow in-flight requests or messages to finish within a deadline, then release resources. Handle cancellation and forced termination as fallbacks.
Example: Worker stops pulling messages, finishes current handler, commits acknowledgement, and exits.
Diagram / flow: Termination signal → stop intake → drain in-flight work → shutdown
Syntax
SIGTERM → readiness false → drain → dispose resources
Example
Worker stops pulling messages, finishes current handler, commits acknowledgement, and exits.
Code example
SIGTERM → readiness false → drain → dispose resources
Diagram
Termination signal → stop intake → drain in-flight work → shutdown
Key Points
- Stop accepting new work, mark the instance unready, allow in-flight requests or messages to finish within a deadline, then release resources.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q109API design
How should API versioning be handled in distributed systems?
Version public contracts deliberately and keep old and new versions compatible during migration. Versioning can use URL paths, headers, or media
Answer
Version public contracts deliberately and keep old and new versions compatible during migration. Versioning can use URL paths, headers, or media types; communicate deprecation and monitor old-version usage.
Example: Deploy v2 alongside v1, migrate clients gradually, then retire v1 after usage falls.
Diagram / flow: Client versions → routing/compatibility layer → matching API contract
Syntax
GET /v2/orders or version header
Example
Deploy v2 alongside v1, migrate clients gradually, then retire v1 after usage falls.
Code example
GET /v2/orders or version header
Diagram
Client versions → routing/compatibility layer → matching API contract
Key Points
- Version public contracts deliberately and keep old and new versions compatible during migration.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q111Messaging
When would you choose a work queue versus an event stream?
A work queue distributes tasks among workers, often with one successful consumer per message. A retained event stream supports replay and multipl
Answer
A work queue distributes tasks among workers, often with one successful consumer per message. A retained event stream supports replay and multiple independent consumer groups; semantics depend on the platform.
Example: Send image-resize jobs to a queue; publish OrderCreated to a retained event stream for multiple projections.
Diagram / flow: Producer → queue/workers OR append-only stream → independent consumer groups
Syntax
Queue: task → worker; Stream: event log → consumer groups
Example
Send image-resize jobs to a queue; publish OrderCreated to a retained event stream for multiple projections.
Code example
Queue: task → worker; Stream: event log → consumer groups
Diagram
Producer → queue/workers OR append-only stream → independent consumer groups
Key Points
- A work queue distributes tasks among workers, often with one successful consumer per message.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q114Data architecture
What trade-offs come with database read replicas?
Read replicas can scale read-heavy workloads but may lag behind the primary. Route consistency-sensitive reads to the primary or use an explicit
Answer
Read replicas can scale read-heavy workloads but may lag behind the primary. Route consistency-sensitive reads to the primary or use an explicit read-your-writes strategy when replica lag is unacceptable.
Example: After changing profile data, read from primary until replication catches up.
Diagram / flow: Write → primary DB → replication lag → read replica
Syntax
write primary → async replication → read replica
Example
After changing profile data, read from primary until replication catches up.
Code example
write primary → async replication → read replica
Diagram
Write → primary DB → replication lag → read replica
Key Points
- Read replicas can scale read-heavy workloads but may lag behind the primary.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q116Scalability
How do you estimate service capacity?
Measure representative throughput and latency under realistic load, identify bottlenecks, and apply headroom for bursts and failures. Little's La
Answer
Measure representative throughput and latency under realistic load, identify bottlenecks, and apply headroom for bursts and failures. Little's Law relates concurrency, throughput, and latency; estimates must be validated by load tests.
Example: At 200 requests/s and 0.15s average latency, expected in-flight requests are about 30.
Diagram / flow: Load test → measure throughput/latency/resource use → capacity model → headroom
Syntax
concurrency ≈ throughput × average latency
Example
At 200 requests/s and 0.15s average latency, expected in-flight requests are about 30.
Code example
concurrency ≈ throughput × average latency
Diagram
Load test → measure throughput/latency/resource use → capacity model → headroom
Key Points
- Measure representative throughput and latency under realistic load, identify bottlenecks, and apply headroom for bursts and failures.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q117Resilience
What is graceful degradation?
The system preserves core functionality when optional dependencies fail, such as hiding recommendations while checkout remains available. Define
Answer
The system preserves core functionality when optional dependencies fail, such as hiding recommendations while checkout remains available. Define criticality and fallback behavior in advance; avoid silently returning misleading data.
Example: Checkout returns order confirmation even when a non-critical personalization service is unavailable.
Diagram / flow: Dependency fails → fallback/default for optional feature → core flow continues
Syntax
if recommendation service fails → omit recommendation panel
Example
Checkout returns order confirmation even when a non-critical personalization service is unavailable.
Code example
if recommendation service fails → omit recommendation panel
Diagram
Dependency fails → fallback/default for optional feature → core flow continues
Key Points
- The system preserves core functionality when optional dependencies fail, such as hiding recommendations while checkout remains available.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.
Q119Architecture
What is an anti-corruption layer?
An anti-corruption layer translates an external or legacy model into the domain model so upstream concepts and inconsistencies do not leak into a
Answer
An anti-corruption layer translates an external or legacy model into the domain model so upstream concepts and inconsistencies do not leak into a new service. It adds code but protects domain boundaries.
Example: Convert legacy status codes and date formats at the integration boundary.
Diagram / flow: Legacy API → translation layer → clean domain model
Syntax
Legacy DTO → mapper/adapter → domain command
Example
Convert legacy status codes and date formats at the integration boundary.
Code example
Legacy DTO → mapper/adapter → domain command
Diagram
Legacy API → translation layer → clean domain model
Key Points
- An anti-corruption layer translates an external or legacy model into the domain model so upstream concepts and inconsistencies do not leak into a new service.
- Make trade-offs explicit and test failure scenarios.
- Monitor behavior under representative load.