dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.77k stars 439 forks source link

Replica support for PostgreSQL #4357

Open MadL1me opened 4 months ago

MadL1me commented 4 months ago

Overview

One of the biggest challanges in distributed systems is nodes failover and restarts. In my own experience, it is not very trivial and can be hard for begginers to setup replicated Postgres locally to test failover scenarios (for example, if Master node is down). Being able to debug those scenarious locally can be extremely helpful in many situations

This issue is related to https://github.com/dotnet/aspire/issues/992, but I think replicas should be defined granulary for each unique resource type (for Postgres or Kafka for example)

API

For Postgres specifically, I we should provide two distinct methods for configuring async and sync replicas. This will look something like this:

builder.AddPostgres("database")
    .WithImage("postgres:14.3")
    .WithAsyncReplicas(2)
    .WithSyncReplicas(1)
    .WithPgAdmin();

Risks

I'm new to Aspire, so I'm unaware if this proposal will somehow interfere with cloud/k8s support

davidfowl commented 4 months ago

Fine idea, but not something that is a priority in the short term.