နားလည်ထားရမယ့် အချက်
PostgreSQL connection တစ်ခုစီက server resources သုံးလို့ application instance တစ်ခုစီ pool အကြီးကြီးဖွင့်ရင် `max_connections` အမြန်ပြည့်ပါတယ်။ Total pool budget ကို app instances၊ workers၊ admin နဲ့ failover headroom အလိုက်တွက်ရပါတယ်။ Network allowlist၊ TLS certificate verification၊ SCRAM password နှင့် least privilege role တို့ကိုအတူသုံးပါ။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
API pool ကို small maximum၊ acquire timeout၊ statement timeout နှင့် idle-in-transaction timeout ဖြင့်ထားမယ်။ PgBouncer လို external pooler သုံးလျှင် transaction pooling နဲ့ session-level features compatibility ကိုစစ်ရပါတယ်။
အတူတူ စမ်းရေးကြည့်မယ်
Connection budget example
-------------------------
Database safe budget: 100
Reserved admin/failover: -20
Background workers: -10
Available to app: 70
7 app instances → max 10 connections per instance
Session safety:
statement_timeout = 5s
lock_timeout = 2s
idle_in_transaction_session_timeout = 30sApplication scale နဲ့ကိုက်ညီသော connection budget နှင့် timeout policy ရမည်။၅ မိနစ် စမ်းကြည့်
App instances 12 ခု၊ worker 4 ခုနှင့် database budget 120 ရှိလျှင် admin headroom ပါ pool plan တွက်ပါ။
သတိလေးတစ်ချက်
Connection error တွေ့တိုင်း `max_connections` တိုးခြင်းက memory pressure နှင့် contention ကိုပိုဆိုးစေနိုင်ပါတယ်။
PostgreSQL — Client Authentication — PostgreSQL Global Development Group