Deploy 🚀 PostgreSQL 18 HA Cluster (AI & GIS Ready)
🚀 Postgres 18 HA Cluster with AI, GIS, and Cron Extensions. Ready to scale
postgres-18-primary
Just deployed
/var/lib/postgresql/data
postgres-18-proxy
Just deployed
postgres-18-replica
Just deployed
/var/lib/postgresql/data
Deploy and Host PostgreSQL 18 HA Cluster (AI & GIS Ready) on Railway
PostgreSQL 18 HA Cluster is a production-ready, high-availability database setup featuring automatic failover, streaming replication, and load balancing via Pgpool-II. Pre-configured with pgvector for AI/ML embeddings, PostGIS for geospatial data, pg_cron for scheduled jobs, and pg_partman for table partitioning. Zero-config deployment — just set your password and go!
About Hosting PostgreSQL 18 HA Cluster (AI & GIS Ready)
This template deploys a complete 3-node PostgreSQL cluster: a Primary (read/write), a Replica (read-only with streaming replication), and a Proxy (Pgpool-II for load balancing and automatic failover). All nodes are pre-configured with enterprise-grade extensions and security settings. The setup handles replication slots, user synchronization, and health checks automatically. Simply configure POSTGRES_PASSWORD, and optionally POSTGRES_USER and POSTGRES_DB, then deploy. The cluster initializes itself, creates replication users, and starts streaming data between nodes within seconds.
Common Use Cases
- AI/ML Applications: Store and query vector embeddings with pgvector for similarity search, RAG pipelines, and recommendation systems
- Geospatial Applications: Build location-based services, mapping applications, and spatial analytics with PostGIS
- High-Traffic Production Databases: Scale read operations across multiple replicas with automatic load balancing
- Scheduled Data Processing: Run automated maintenance, ETL jobs, and data cleanup with pg_cron
- Enterprise Applications: Handle failover scenarios automatically without application changes
Dependencies for PostgreSQL 18 HA Cluster (AI & GIS Ready) Hosting
- POSTGRES_PASSWORD (Required): Your database password
- POSTGRES_USER (Optional): Database username (default:
postgres) - POSTGRES_DB (Optional): Database name (default:
postgres) - REPLICATION_USER (Optional): Replication username (default:
replicator)
Deployment Dependencies
- PostgreSQL 18 Official Documentation
- Pgpool-II Documentation
- pgvector Extension
- PostGIS Extension
- pg_cron Extension
Implementation Details
Connect via Proxy (Recommended - Load Balanced):
psql postgresql://postgres:YOUR_PASSWORD@postgres-18-proxy.railway.internal:5432/postgres
Connect directly to Primary (Read/Write):
psql postgresql://postgres:YOUR_PASSWORD@postgres-18-primary.railway.internal:5432/postgres
Connect directly to Replica (Read-Only):
psql postgresql://postgres:YOUR_PASSWORD@postgres-18-replica.railway.internal:5432/postgres
Example: Using pgvector for AI embeddings:
-- Create a table with vector column CREATE TABLE items ( id SERIAL PRIMARY KEY, content TEXT, embedding vector(1536) );
-- Find similar items SELECT * FROM items ORDER BY embedding <-> '[0.1, 0.2, ...]' LIMIT 5;
Example: Schedule a job with pg_cron:
-- Run a cleanup job every day at 3 AM SELECT cron.schedule('daily-cleanup', '0 3 * * *', 'DELETE FROM logs WHERE created_at < NOW() - INTERVAL ''30 days''');
Pre-installed Extensions
| Extension | Purpose |
|---|---|
| pgvector | AI/ML vector similarity search |
| postgis | Geospatial data and queries |
| pg_cron | Scheduled background jobs |
| pg_partman | Automatic table partitioning |
| pg_stat_statements | Query performance monitoring |
| pg_trgm | Fuzzy text search |
| uuid-ossp | UUID generation |
Why Deploy PostgreSQL 18 HA Cluster (AI & GIS Ready) on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying PostgreSQL 18 HA Cluster (AI & GIS Ready) on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Support This Project
If this template saves you time and money, consider supporting its development! ☕
Template Content
postgres-18-primary
icueth/railsway-timescaledb-replicapostgres-18-proxy
icueth/railsway-timescaledb-replicapostgres-18-replica
icueth/railsway-timescaledb-replica