Railway

Deploy 🚀 PostgreSQL 18 HA Cluster (AI & GIS Ready)

🚀 Postgres 18 HA Cluster with AI, GIS, and Cron Extensions. Ready to scale

Deploy 🚀 PostgreSQL 18 HA Cluster (AI & GIS Ready)

Just deployed

/var/lib/postgresql/data

Just deployed

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

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

ExtensionPurpose
pgvectorAI/ML vector similarity search
postgisGeospatial data and queries
pg_cronScheduled background jobs
pg_partmanAutomatic table partitioning
pg_stat_statementsQuery performance monitoring
pg_trgmFuzzy text search
uuid-osspUUID 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! ☕

Support Me


Template Content

More templates in this category

View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
View Template
(v1) Simple Medusa Backend
Deploy an ecommerce backend and admin using Medusa

Shahed Nasser
View Template
peppermint
Docker-compose port for peppermint.sh

HamiltonAI