Wave 5 performance work reduces RPC load, caps in-memory read-cache growth, tunes the Postgres pool, and fixes RPC retry behavior so transient Soroban failures recover correctly.
| Priority | Change | Files |
|---|---|---|
| High | Bounded TTL read cache (max entries + expiry) | backend/src/services/read-cache.ts, stellar.ts |
| High | Fix executeWithRetry to await Promise.race (retries actually run) |
backend/src/services/stellar.ts |
| Medium | Configurable cache and pool via env | backend/src/config/env.ts, backend/.env.example |
| Medium | Postgres connection pool max via TypeORM extra |
backend/src/services/database.ts |
| Medium | Unit tests for cache behavior | backend/src/services/read-cache.test.ts |
- Before: Unbounded
Mapfor simulation reads; risk of memory growth on long-lived processes. - After: Default max 500 entries, TTL 30s (configurable). Oldest entry evicted when full.
- Tuning:
READ_CACHE_TTL_MS,READ_CACHE_MAX_ENTRIESin environment. - Invalidation: Unchanged — write routes still call
invalidateCache/invalidateCacheByPrefix.
- Default:
DATABASE_POOL_MAX=10connections per process. - Tuning: Raise for high concurrency; lower for small containers.
- Transient errors now retry with exponential backoff (structured
logger.warn).
- Revert the merge commit and redeploy the previous image.
- No schema migrations in this wave.
- Remove optional env vars to restore prior defaults (30s TTL, unbounded cache behavior replaced by bounded — revert code to restore old semantics).
- Process RSS / heap (cache cap should stabilize growth)
- Soroban RPC request rate (should drop on read-heavy endpoints)
- API p95 latency on
GETsplit/project routes - Postgres active connections vs
DATABASE_POOL_MAX
export CI=true NODE_ENV=test \
DATABASE_URL=postgresql://splitnaira:splitnaira@localhost:5432/splitnaira_ci \
HORIZON_URL=https://horizon-testnet.stellar.org \
SOROBAN_RPC_URL=https://soroban-testnet.stellar.org \
SOROBAN_NETWORK_PASSPHRASE="Test SDF Network ; September 2015" \
CONTRACT_ID=CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \
SIMULATOR_ACCOUNT=GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF \
NEXT_PUBLIC_CONTRACT_ID=CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
npm ci
npm run deps:check -w backend
npm run migration:run -w backend # requires Postgres on :5432
npm run lint -w backend
npm run build -w backend
npm run test:compat -w backend
npm run test -w backend- Full backend test suite green
- Set
READ_CACHE_*/DATABASE_POOL_MAXin staging if defaults are insufficient - Confirm no regression on write paths (cache invalidation still called)