Skip to content

feat(postgres): database read-replica autoscaling via KEDA #3953

Closed

Description

@scooby87

What

Implement automatic horizontal autoscaling of a managed database's read replicas in response to load, for the PostgreSQL (CloudNativePG) MVP. The mechanism is entirely stock: the app chart renders a KEDA ScaledObject next to the database; KEDA queries VictoriaMetrics for the read load, computes the desired count with a plain HPA it manages, and drives the CNPG Cluster scale subresource (.spec.instances). There is no bespoke operator and no new CRD.

Design

This implements the merged design proposal cozystack/community: Database Horizontal Autoscaler (community#44), including the PoC finding (community#53) that pins the hard precondition CNPG ≥ 1.28.4 — the Cluster scale subresource must serve status.selector or the HPA rejects it with InvalidSelector. That version floor is delivered separately by the postgres-operator bump to CNPG 1.30.0 (#3951).

Scope

  • In scope: PostgreSQL read-replica horizontal autoscaling — KEDA as an optional platform package, the chart change (omit replicas under autoscaling), a cozy-lib helper that renders the ScaledObject, the autoscaling values block + schema, the two-phase enable/disable migration, and a dashboard/alert bundle.
  • Out of scope (follow-ups): MariaDB (once its chart supports on-the-fly scale-out), Redis/MongoDB (no scale subresource — need a thin actuation shim), vertical and storage autoscaling.

Depends on

Activity

  1. added
    kind/featureCategorizes issue or PR as related to a new feature
    area/databaseIssues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse)
    triage/not-reproducibleIndicates an issue can not be reproduced as described
    and removed
    triage/needs-triageIndicates an issue needs triage by a maintainer
    on Sep 23, 2026
  2. lexfrei commented on Sep 23, 2026

    @lexfrei
    Contributor

    Done in #3954, with follow-ups in #4188: the postgres chart renders a KEDA ScaledObject, and KEDA ships as a platform package. MariaDB, Redis and MongoDB can get their own issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/databaseIssues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse)kind/featureCategorizes issue or PR as related to a new featuretriage/not-reproducibleIndicates an issue can not be reproduced as described

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions