- PM2 cluster mode (2 API workers + 1 Next.js) - Nginx reverse proxy with SSL, rate limiting, security headers - Automated backup script with daily/weekly rotation - PostgreSQL production tuning script (300 connections, 4GB shared_buffers) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
1020 B
Bash
Executable File
28 lines
1020 B
Bash
Executable File
#!/bin/bash
|
||
# PostgreSQL Production Tuning for Horux360
|
||
# Server: 32GB RAM, 8 cores
|
||
# Target: 50 tenants, PM2 cluster ×2
|
||
#
|
||
# Run once: sudo bash scripts/tune-postgres.sh
|
||
|
||
set -euo pipefail
|
||
|
||
echo "=== PostgreSQL Production Tuning ==="
|
||
|
||
sudo -u postgres psql -c "ALTER SYSTEM SET max_connections = 300;"
|
||
sudo -u postgres psql -c "ALTER SYSTEM SET shared_buffers = '4GB';"
|
||
sudo -u postgres psql -c "ALTER SYSTEM SET work_mem = '16MB';"
|
||
sudo -u postgres psql -c "ALTER SYSTEM SET effective_cache_size = '16GB';"
|
||
sudo -u postgres psql -c "ALTER SYSTEM SET maintenance_work_mem = '512MB';"
|
||
sudo -u postgres psql -c "ALTER SYSTEM SET checkpoint_completion_target = 0.9;"
|
||
sudo -u postgres psql -c "ALTER SYSTEM SET wal_buffers = '64MB';"
|
||
sudo -u postgres psql -c "ALTER SYSTEM SET random_page_cost = 1.1;"
|
||
|
||
echo "Settings applied. Restarting PostgreSQL..."
|
||
sudo systemctl restart postgresql
|
||
|
||
echo "Verifying settings..."
|
||
sudo -u postgres psql -c "SHOW max_connections; SHOW shared_buffers; SHOW work_mem;"
|
||
|
||
echo "=== Done ==="
|