The skill's own detector (conorbronsdon/avoid-ai-writing) scored every README, doc, page and the extracted comment prose. Scores were already 0 to 3 out of 100; what it still flagged is fixed here: hollow intensifiers (genuinely, genuine), "in order to", "additionally", "the whole point" and "the entire point", bold sentences of seven words or more in the docs, and bold that had wrapped across comment lines. Comment prose now scores a maximum of 1 out of 100 across the repo. One rule in the sweep went wrong and was caught by reading the diff: "which is the entire point of X" lost its clause and left "of X" dangling in four comments. Repaired by hand; the rule now keeps the clause when it is followed by "of". Comments and strings only. 694 tests pass. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
78 lines
3.5 KiB
YAML
78 lines
3.5 KiB
YAML
# PgBouncer in front of Postgres (relay#29).
|
|
#
|
|
# An OVERLAY, not a replacement. Run it alongside the production file:
|
|
#
|
|
# docker compose -f docker-compose.prod.yml -f docker-compose.pooled.yml up -d
|
|
#
|
|
# Why this is worth doing. `docs/COST.md` measured one message at nine
|
|
# database round trips, so the round-trip rate is roughly nine times the message
|
|
# rate, and each one borrows a connection from the relay's pool for a few
|
|
# milliseconds. Postgres's default `max_connections` of 100 is the ceiling every
|
|
# one of those is drawn against, and a Postgres backend is a whole process with
|
|
# its own memory. A pooler makes the relay's connections cheap client
|
|
# connections and keeps the expensive backends few.
|
|
#
|
|
# What is proven and what is not. `PoolerCompatibilityTests` proves the
|
|
# relay uses nothing that transaction pooling breaks, and that is the thing that
|
|
# usually blocks this migration. The settings below have NOT been run under
|
|
# load here, see docs/POOLING.md for what is owed before this is switched on in
|
|
# production.
|
|
|
|
services:
|
|
pgbouncer:
|
|
image: edoburu/pgbouncer:v1.23.1-p3
|
|
restart: unless-stopped
|
|
environment:
|
|
DB_HOST: db
|
|
DB_PORT: "5432"
|
|
DB_NAME: flamenet
|
|
DB_USER: flamenet
|
|
DB_PASSWORD: "${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}"
|
|
# Transaction pooling, which is the mode that actually helps. Session
|
|
# pooling holds a backend for as long as the client is connected, so it
|
|
# would give the relay a nicer reconnect story and none of the
|
|
# multiplexing this exists for.
|
|
POOL_MODE: transaction
|
|
# Backends, not clients. This is the number that must stay well under
|
|
# Postgres's `max_connections`, because it is what actually reaches
|
|
# Postgres. Twenty against a default of a hundred leaves room for
|
|
# migrations, psql, backups and a second relay.
|
|
DEFAULT_POOL_SIZE: "20"
|
|
# Client connections the pooler will accept. Deliberately far larger than
|
|
# the pool: that gap IS the multiplexing.
|
|
MAX_CLIENT_CONN: "500"
|
|
# Reserve pool off. A reserve that opens extra backends under pressure
|
|
# quietly raises the real ceiling above `DEFAULT_POOL_SIZE`, which is the
|
|
# one number this whole file exists to bound.
|
|
RESERVE_POOL_SIZE: "0"
|
|
# Server-side prepared statements are NOT used by this relay,
|
|
# postgres-nio's ordinary query path is the unnamed extended-query
|
|
# protocol, so this stays at zero rather than being tuned. See
|
|
# PoolerCompatibilityTests, which fails if that changes.
|
|
MAX_PREPARED_STATEMENTS: "0"
|
|
AUTH_TYPE: scram-sha-256
|
|
networks: [internal]
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -p 5432 -U flamenet"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
|
|
relay:
|
|
environment:
|
|
# The only change the relay needs: point at the pooler instead of the
|
|
# database. No protocol change, no code change.
|
|
FN_POSTGRES_URL: "postgres://flamenet:${POSTGRES_PASSWORD}@pgbouncer:5432/flamenet"
|
|
# Raised, not lowered. Behind a pooler the
|
|
# relay's connections are cheap client connections rather than Postgres
|
|
# backends, so the relay may hold many and the pooler keeps the real
|
|
# backends at DEFAULT_POOL_SIZE. Sixteen per loop on an 8-core box is 128
|
|
# client connections against 20 backends.
|
|
FN_PG_MAX_CONNECTIONS_PER_LOOP: "16"
|
|
depends_on:
|
|
pgbouncer:
|
|
condition: service_healthy
|