.NET Architecture & System Design Interview

Transactions, CQRS, Event Sourcing & Distributed Consistency

Questions 76-100: Transactions, CQRS, Event Sourcing & Distributed Consistency.

25 Questions Filter by level

Interview questions

Open a question for the full answer, code and interview guidance.

25 Results
76
Mid-LevelIntermediate

What is a database transaction?

A database transaction groups one or more operations into a logical unit of work. The transaction either completes according to the database's commit rules or is rolled back when it cannot complete.

77
Mid-LevelIntermediate

What does ACID mean in database systems?

ACID stands for Atomicity, Consistency, Isolation, and Durability. Atomicity means a transaction's changes succeed as a unit. Consistency means valid database rules are preserved. Isolation controls how concurrent transactions interact. Durability means committed changes survive expected failures.

78
Mid-LevelIntermediate

What are transaction isolation levels?

Transaction isolation levels control how much one transaction can observe or interfere with concurrent transactions. Common relational levels include Read Uncommitted, Read Committed, Repeatable Read, and Serializable; some databases also provide snapshot-based isolation.

79
Mid-LevelIntermediate

What is a dirty read?

A dirty read occurs when one transaction reads data written by another transaction that has not yet committed. If the writer later rolls back, the reader has observed data that never became permanent.

80
Mid-LevelIntermediate

What is a non-repeatable read?

A non-repeatable read occurs when a transaction reads the same row twice and obtains different committed values because another transaction updated the row between the two reads.

81
Mid-LevelIntermediate

What is a phantom read?

A phantom read occurs when a transaction repeats a query and finds a different set of rows because another transaction inserted, deleted, or changed rows so they now match or stop matching the query.

82
Mid-LevelIntermediate

What is a database deadlock?

A database deadlock occurs when two or more transactions each hold resources that the others need, creating a cycle in which none can proceed. Database engines commonly detect the cycle and terminate one transaction as the deadlock victim.

83
Mid-LevelIntermediate

What is connection pooling?

Connection pooling reuses already-created database connections instead of creating a new physical connection for every operation. Opening a logical connection usually borrows a connection from the pool and closing it returns the connection for reuse.

84
Mid-LevelIntermediate

Why should database connections and DbContext instances be short-lived?

Database connections are limited resources, and EF Core DbContext represents a unit-of-work-oriented stateful component. Keeping them longer than necessary can increase resource usage, tracked entities, stale state, and concurrency problems.

85
Mid-LevelIntermediate

What is the N+1 query problem?

The N+1 query problem occurs when an application executes one query to obtain a collection and then executes an additional query for each item, creating many database round trips.

86
Mid-LevelIntermediate

What is CQRS from a system-design perspective?

CQRS separates operations that change state from operations that read state. The write and read sides can use different models, logic, or even data stores when their requirements differ significantly.

87
Mid-LevelIntermediate

When are separate read and write databases useful in CQRS?

Separate stores can be useful when read and write workloads have very different scaling, schema, performance, or technology requirements. A read model can be denormalized and optimized for queries while the write model protects transactional rules.

88
Mid-LevelIntermediate

What is Event Sourcing in system architecture?

Event Sourcing stores a sequence of state-changing events as the authoritative history instead of storing only the latest state. An aggregate's current state can be reconstructed by replaying its events.

89
Mid-LevelIntermediate

What is a projection in an event-sourced system?

A projection transforms events into a model optimized for a particular read or reporting requirement. Multiple projections can be built from the same event stream.

90
Mid-LevelIntermediate

What is a snapshot in Event Sourcing?

A snapshot stores an aggregate's state at a particular event version so the system does not need to replay the entire history every time it loads a long-lived aggregate.

91
Mid-LevelIntermediate

What is the Outbox Pattern?

The Outbox Pattern helps keep a local database update and the intent to publish a message consistent without requiring a distributed transaction. The application writes business data and an outbox record in the same local transaction.

92
Mid-LevelIntermediate

What problem does the Inbox Pattern solve?

The Inbox Pattern records incoming message identifiers or processing state so a consumer can recognize messages it has already handled. It is commonly used to make at-least-once message delivery safe.

93
Mid-LevelIntermediate

What is a distributed transaction?

A distributed transaction coordinates an atomic operation across multiple transactional resources or services. Traditional approaches such as two-phase commit attempt to make all participants commit or abort together.

94
Mid-LevelIntermediate

What is the Saga pattern in distributed systems?

A Saga coordinates a long-running business process as a sequence of local transactions. Each step commits independently, and failures may trigger compensating actions for previously completed steps.

95
Mid-LevelIntermediate

What is the difference between Saga orchestration and choreography?

In orchestration, a coordinator explicitly tells participants which action to perform and tracks the workflow. In choreography, services react to events and publish subsequent events without one central workflow controller.

96
Mid-LevelIntermediate

What is idempotency in an HTTP API?

An idempotent API operation can be repeated without creating additional unintended effects beyond the first successful application of that logical operation.

97
Mid-LevelIntermediate

What is an idempotency key?

An idempotency key is a client-supplied or workflow-generated identifier representing one logical operation. The server stores the key with the operation's result or processing state.

98
Mid-LevelIntermediate

What is optimistic locking in a REST API?

Optimistic locking prevents lost updates by requiring a client to update the version it previously read. The server accepts the update only if the resource has not changed in the meantime.

99
Mid-LevelIntermediate

What is eventual consistency between services?

Eventual consistency means separate services or data stores may temporarily hold different views of the same business change, but they converge as asynchronous propagation completes.

100
Mid-LevelIntermediate

How do you choose a consistency model for a distributed system?

Choose the consistency model from business invariants and user expectations rather than selecting strong or eventual consistency globally. Identify which operations must be immediately correct and which can tolerate temporary staleness.