[{"data":1,"prerenderedAt":159},["ShallowReactive",2],{"project:postgres-ha":3,"project-index":88},{"id":4,"title":5,"aTitle":6,"body":7,"categories":67,"description":69,"extension":70,"image":71,"images":72,"link":71,"meta":73,"navigation":74,"order":75,"path":76,"role":77,"seo":79,"slug":80,"stem":81,"summary":82,"tags":83,"team":86,"thumb":71,"__hash__":87},"projects\u002Fprojects\u002F1023_postgres_ha.md","PostgreSQL high availability platform - Imraan","PostgreSQL high availability platform",{"type":8,"value":9,"toc":63},"minimark",[10,14,17,46,53,60],[11,12,13],"p",{},"Most of the systems I build eventually depend on one database staying up. This is the platform that stops that being a single point of failure — a two-node PostgreSQL 18 cluster with automatic failover, connection pooling and backups that live off the host.",[15,16],"ha-diagram",{},[11,18,19,20,24,25,28,29,32,33,36,37,41,42,45],{},"The application never talks to a database node directly. It connects to ",[21,22,23],"strong",{},"HAProxy",", which routes to whichever node is currently the leader, and through ",[21,26,27],{},"PgBouncer"," for connection pooling — so a failover is a routing change rather than something every client has to know about. ",[21,30,31],{},"Patroni"," runs on both nodes and owns the promotion decision; it keeps cluster state in ",[21,34,35],{},"etcd",", so leadership is agreed rather than assumed. ",[38,39,40],"code",{},"pg02"," follows ",[38,43,44],{},"pg01"," by streaming replication.",[11,47,48,49,52],{},"Backups are handled by ",[21,50,51],{},"pgBackRest",", with WAL archiving and base backups written to NAS. A replica protects against a node failing; it does not protect against a bad migration or a deletion, and those are the failures that actually happen. Restore is the point of a backup, so the archive exists to be replayed, not just to accumulate.",[11,54,55,56,59],{},"The part worth doing properly was the failover testing. It is easy to stand up a cluster that looks correct in ",[38,57,58],{},"patronictl list"," and then discover, the first time a node actually goes down, that HAProxy was health-checking the wrong thing or that the firewall never allowed the replication port from the right subnet. Killing the primary deliberately — and watching what the application sees while the promotion happens — is the only part of this that tells you whether it works.",[11,61,62],{},"This is infrastructure work rather than product work, so there is no interface to show. The topology above is the deliverable.",{"title":64,"searchDepth":65,"depth":65,"links":66},"",2,[],[68],"Infrastructure","A replicated PostgreSQL cluster with automatic failover, pooling and off-host backups","md",null,[],{},true,1023,"\u002Fprojects\u002F1023_postgres_ha",[78],"Infrastructure engineer",{"title":5,"description":69},"postgres-ha","projects\u002F1023_postgres_ha","A replicated PostgreSQL cluster with automatic failover and off-host backups",[84,31,35,23,27,51,85],"PostgreSQL","Linux",[],"mcaCZnUo5Zo5OAIabfvmSyl1DbgdUq7ZmJJAxe1Mw-Y",[89,92,95,96,99,102,105,108,111,114,117,120,123,126,129,132,135,138,141,144,147,150,153,156],{"slug":90,"aTitle":91},"wc2026-predictions","ADK Synergy World Cup 2026 predictions",{"slug":93,"aTitle":94},"pabx-cdr-analysis","PABX call record analysis",{"slug":80,"aTitle":6},{"slug":97,"aTitle":98},"ai-narration","AI narration and text-to-speech platform",{"slug":100,"aTitle":101},"cloud-player","Cloud Player",{"slug":103,"aTitle":104},"brainspine-app","Maldives BrainSpine conference app",{"slug":106,"aTitle":107},"adk-token-display","ADK Hospital doctors room token display",{"slug":109,"aTitle":110},"adk-signage","ADK Hospital signage TV app",{"slug":112,"aTitle":113},"adk-qms","ADK Hospital queue management system",{"slug":115,"aTitle":116},"adk-hbot","ADK Hospital Hyperbaric Oxygen Therapy",{"slug":118,"aTitle":119},"clinical-incident-report-portal","ADK Hospital clinical incidents portal",{"slug":121,"aTitle":122},"porter-app","ADK Hospital porter app",{"slug":124,"aTitle":125},"majeedi-run","Majeedi Run portal",{"slug":127,"aTitle":128},"cmca-website","China Maldivian Cultural Association website",{"slug":130,"aTitle":131},"brainspine23","Brain & Spine conference 2023 website",{"slug":133,"aTitle":134},"sih-e-library","Shafi’a Institute of Health e-library",{"slug":136,"aTitle":137},"adk-lucky-draw","ADK Hospital lucky draw app",{"slug":139,"aTitle":140},"acc-cms","Anti-Corruption Commission Case Management System",{"slug":142,"aTitle":143},"brainspine22","Brain & Spine conference 2022 website",{"slug":145,"aTitle":146},"icom-tours","iCom Tours website and portal",{"slug":148,"aTitle":149},"dhuvaahithun-app","Dhuvaahithun app",{"slug":151,"aTitle":152},"jsc-cms","Judicial Service Commission Case Management System",{"slug":154,"aTitle":155},"motca","Ministry of Transport and Civil Aviation website",{"slug":157,"aTitle":158},"aonews","AO News",1786359403314]