feat: scale Postgres memory settings with instance RAM#100
Draft
tonychang04 wants to merge 1 commit into
Draft
Conversation
postgresql.conf ships nano-safe values (shared_buffers=32MB, work_mem=2MB, maintenance_work_mem=16MB, effective_cache_size=128MB) and every tier ran them — a large (8G) instance got nano-tuned Postgres. Follow the #98 pattern: auto-scale-memory.sh picks per-tier values and writes them to .env; the compose command passes them as -c flags (command line overrides config_file). Without the env vars the -c defaults equal the conf values, so behavior on existing hosts is unchanged until auto-scale re-runs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J9NtiFkU34HQQgRSffNb4k
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
docker-init/db/postgresql.confships nano-safe memory values (shared_buffers=32MB,work_mem=2MB,maintenance_work_mem=16MB,effective_cache_size=128MB) and every instance tier runs them — #98 mademax_connections/pool scale with RAM, but the memory settings stayed fixed, so alarge(8G) orxl(16G) instance runs nano-tuned Postgres and leaves most of its RAM unused by the planner and buffer cache.Change
Same mechanism as #98:
auto-scale-memory.shpicks per-tier values (nano tier = current conf values, unchanged) and writesPG_SHARED_BUFFERS/PG_EFFECTIVE_CACHE_SIZE/PG_WORK_MEM/PG_MAINTENANCE_WORK_MEMto.env-cflags (command line wins overconfig_file); the-cdefaults equal the conf values, so hosts without the env vars behave exactly as beforeshared_buffers stays ~15–25% of the postgres container limit (not host RAM) since the host is shared with the API; work_mem is bounded per tier against worst-case
work_mem × max_connections.Verification
bash -n+ real run ofauto-scale-memory.sh(24G host → xl tier written to .env correctly)docker compose configrenders the-cflags for both the scaled case and the no-env default case (defaults = conf values, no behavior change)Notes
auto-scale-memory.shruns (provision + instance resize). Existing running instances are untouched until their next auto-scale + compose up.🤖 Generated with Claude Code
https://claude.ai/code/session_01J9NtiFkU34HQQgRSffNb4k
Summary by cubic
Scale Postgres memory settings with instance RAM so larger tiers don’t run nano defaults and can better use available memory.
docker-compose.ymlnow passes these settings via-cflags with safe defaults, so behavior is unchanged until auto-scale runs.New Features
auto-scale-memory.shwritesPG_SHARED_BUFFERS,PG_EFFECTIVE_CACHE_SIZE,PG_WORK_MEM,PG_MAINTENANCE_WORK_MEMto.envbased on RAM tiers.docker-compose.ymlapplies them with-cflags; defaults equal currentpostgresql.confvalues.shared_buffers~15–25% of the Postgres container limit;work_membounded per tier.Migration
auto-scale-memory.shanddocker compose up. Existing instances keep current behavior until then.Written for commit 419f78b. Summary will update on new commits.