.NET 10 How to implement it
| Library / API | Package | Use it for |
| Cosmos DB regions | Microsoft.Azure.Cosmos | CosmosClientOptions.ApplicationPreferredRegions to read from the nearest region; Session consistency gives read-your-writes per client |
| SQL read replicas | Microsoft.Data.SqlClient | ApplicationIntent=ReadOnly in the connection string sends reads to a readable secondary |
| EF Core read/write split | Microsoft.EntityFrameworkCore.SqlServer | Two DbContext registrations: one on the primary for writes, one on the read-only replica with AsNoTracking |
| Cassandra | CassandraCSharpDriver | Leaderless replication with per-query consistency (see 4.3) |
// Cosmos DB: read from the closest region first, fail over in order
var cosmos = new CosmosClient(endpoint, new DefaultAzureCredential(), new CosmosClientOptions
{
ApplicationPreferredRegions = [Regions.AustraliaEast, Regions.AustraliaSoutheast]
});
// SQL Server: a second connection string for replica reads
// "Server=tcp:myag-listener;Database=Bank;ApplicationIntent=ReadOnly;..."
builder.Services.AddDbContext<BankDb>(o => o.UseSqlServer(primaryCs));
builder.Services.AddDbContext<BankReadDb>(o => o.UseSqlServer(readOnlyCs)
.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking));
"I updated my email, refreshed, and it changed back." Not a bug in your code. It's replication lag 🔁
👑 Single-leader: one node takes writes, followers copy. Simple.
🌏 Multi-leader: write in every region, but now you resolve conflicts.
🕸 Leaderless: write to many, read from many, let quorums decide.
⚡ Async = fast but stale reads and possible loss on failover.
Fix the symptom with read-your-writes: read your own data from the leader for a few seconds.
#DistributedSystems #Databases #SystemDesign #Replication