Tier 0 scalability: PgBouncer, Redis split, DB split, workers
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m14s

T0.1: Separate redis-auth service (64mb, noeviction) for auth state
T0.2: Bump data Redis from 256mb to 1gb
T0.3: Per-app DATABASE_URL via PgBouncer to per-domain databases
T0.4: PgBouncer service (transaction mode, pool=20, max_conn=300);
      session.py pools reduced to 3+5 with timeout and recycle
T0.5: Hypercorn --workers 2 --keep-alive 75 on all 6 entrypoints

Deploy requires running split-databases.sh first to create per-domain
databases from the existing appdb.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-25 10:10:18 +00:00
parent 0ccf897f74
commit 961067841e
9 changed files with 62 additions and 18 deletions

View File

@@ -15,8 +15,10 @@ _engine = create_async_engine(
future=True,
echo=False,
pool_pre_ping=True,
pool_size=5,
max_overflow=10,
pool_size=int(os.getenv("DB_POOL_SIZE", "3")),
max_overflow=int(os.getenv("DB_MAX_OVERFLOW", "5")),
pool_timeout=10,
pool_recycle=1800,
)
_Session = async_sessionmaker(
@@ -57,7 +59,8 @@ _account_engine = (
else create_async_engine(
DATABASE_URL_ACCOUNT,
future=True, echo=False, pool_pre_ping=True,
pool_size=3, max_overflow=5,
pool_size=2, max_overflow=3,
pool_timeout=10, pool_recycle=1800,
)
)
_AccountSession = async_sessionmaker(
@@ -71,7 +74,8 @@ _federation_engine = (
else create_async_engine(
DATABASE_URL_FEDERATION,
future=True, echo=False, pool_pre_ping=True,
pool_size=3, max_overflow=5,
pool_size=2, max_overflow=3,
pool_timeout=10, pool_recycle=1800,
)
)
_FederationSession = async_sessionmaker(