RAM Configuration
Advanced configuration options for RAM PostgreSQL clustering and high availability.
Cluster Configuration
ramd.conf Configuration
[cluster]
name = "production-cluster"
node_id = "node1"
data_dir = "/var/lib/ram"
[postgresql]
host = "localhost"
port = 5432
user = "postgres"
password = "secure_password"
database = "postgres"
[raft]
listen_addr = "0.0.0.0:8080"
heartbeat_interval = 100ms
election_timeout = 1000ms
snapshot_threshold = 1000
[monitoring]
metrics_port = 9090
health_check_interval = 5s
log_level = "info"
Environment Variables
export RAM_CLUSTER_NAME="production-cluster"
export RAM_NODE_ID="node1"
export RAM_LISTEN_ADDR="0.0.0.0:8080"
export RAM_METRICS_PORT="9090"
export RAM_LOG_LEVEL="info"
export RAM_DATA_DIR="/var/lib/ram"
PostgreSQL Configuration
postgresql.conf Settings
# Required for pgraft extension
shared_preload_libraries = 'pgraft'
# Connection settings
max_connections = 200
listen_addresses = '*'
port = 5432
# Memory settings
shared_buffers = 256MB
effective_cache_size = 1GB
work_mem = 4MB
# WAL settings
wal_level = replica
max_wal_senders = 10
wal_keep_size = 1GB
# Replication settings
hot_standby = on
max_standby_streaming_delay = 30s
max_standby_archive_delay = 30s
pg_hba.conf Configuration
# Local connections
local all postgres peer
local all all md5
# Host connections
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
# Replication connections
local replication postgres peer
host replication postgres 127.0.0.1/32 md5
host replication postgres ::1/128 md5
# Cluster internal connections
host all all 192.168.1.0/24 md5
pgraft Configuration
pgraft Parameters
# pgraft configuration in postgresql.conf
pgraft.listen_address = '0.0.0.0:5433'
pgraft.heartbeat_interval = 100ms
pgraft.election_timeout = 1000ms
pgraft.snapshot_threshold = 1000
pgraft.max_log_entries = 10000
pgraft.batch_size = 100
# Network settings
pgraft.network_buffer_size = 1MB
pgraft.max_connections_per_node = 100
pgraft.connection_timeout = 30s
# Performance settings
pgraft.compaction_interval = 5m
pgraft.gc_interval = 1m
Runtime Configuration
# View current configuration
SELECT * FROM pgraft_get_config('production-cluster');
# Update configuration
SELECT pgraft_set_config('production-cluster', 'heartbeat_interval', '50ms');
SELECT pgraft_set_config('production-cluster', 'election_timeout', '500ms');
SELECT pgraft_set_config('production-cluster', 'batch_size', '500');
Security Configuration
TLS/SSL Configuration
[security]
tls_enabled = true
tls_cert_file = "/etc/ram/tls/server.crt"
tls_key_file = "/etc/ram/tls/server.key"
tls_ca_file = "/etc/ram/tls/ca.crt"
tls_min_version = "1.2"
# PostgreSQL SSL settings
ssl = on
ssl_cert_file = '/etc/postgresql/ssl/server.crt'
ssl_key_file = '/etc/postgresql/ssl/server.key'
ssl_ca_file = '/etc/postgresql/ssl/ca.crt'
Authentication
[authentication]
auth_enabled = true
auth_method = "token"
token_secret = "your-secret-token"
token_expiry = "24h"
# Rate limiting
rate_limit_enabled = true
rate_limit_requests = 1000
rate_limit_window = "1m"
Monitoring Configuration
Prometheus Metrics
[monitoring]
metrics_enabled = true
metrics_port = 9090
metrics_path = "/metrics"
metrics_interval = 30s
# Custom metrics
custom_metrics_enabled = true
business_metrics_enabled = true
# Health checks
health_check_enabled = true
health_check_interval = 5s
health_check_timeout = 3s
Logging Configuration
[logging]
log_level = "info"
log_file = "/var/log/ram/ramd.log"
log_max_size = 100MB
log_max_files = 10
log_compress = true
# Structured logging
structured_logging = true
log_format = "json"
# Audit logging
audit_log_enabled = true
audit_log_file = "/var/log/ram/audit.log"
Performance Tuning
High Throughput Configuration
# RAM performance settings
heartbeat_interval = 50ms
election_timeout = 500ms
batch_size = 1000
network_buffer_size = 2MB
# PostgreSQL performance
shared_buffers = 512MB
effective_cache_size = 2GB
work_mem = 8MB
maintenance_work_mem = 128MB
# Connection pooling
max_connections = 300
connection_pool_size = 100
Low Latency Configuration
# RAM latency settings
heartbeat_interval = 25ms
election_timeout = 250ms
batch_size = 100
network_buffer_size = 512KB
# PostgreSQL latency
shared_buffers = 128MB
effective_cache_size = 1GB
work_mem = 2MB
synchronous_commit = on
# Fast failover
failover_timeout = 1s
health_check_interval = 2s
Configuration Validation
Validation Commands
# Validate RAM configuration
ramd --config-check
# Test PostgreSQL connectivity
ramctrl health --cluster production-cluster
# Validate pgraft configuration
SELECT * FROM pgraft_get_config('production-cluster');
# Test cluster operations
ramctrl status --cluster production-cluster
Configuration Testing
Load Testing
# Generate test load
pgbench -h leader-node -p 5432 -U postgres -T 300 -c 10 -j 2 postgres
# Monitor performance
ramctrl metrics --cluster production-cluster --format prometheus
Failover Testing
# Test manual failover
ramctrl failover --cluster production-cluster
# Test automatic failover
# Stop leader PostgreSQL service
sudo systemctl stop postgresql
# Monitor failover
ramctrl status --cluster production-cluster