Skip to content

Environment Variables Reference

Complete configuration reference for Queen MQ server. These variables control all aspects of server behavior.

Quick Reference

VariableDefaultDescription
PORT6632HTTP server port
NUM_WORKERS10Worker threads (max: CPU cores)
DB_POOL_SIZE150CRITICAL - Connection pool size
PG_HOSTlocalhostPostgreSQL host
LOG_LEVELinfoLog level (debug, info, warn, error)

Server Configuration

Basic Settings

VariableTypeDefaultDescription
PORTint6632HTTP server port
HOSTstring0.0.0.0HTTP server host
WORKER_IDstringcpp-worker-1Unique identifier for this worker
APP_NAMEstringqueen-mqApplication name
NUM_WORKERSint10Number of worker threads (capped at CPU core count)
WEBAPP_ROOTstringauto-detectPath to webapp/dist directory for dashboard

Example:

bash
export PORT=6632
export HOST=0.0.0.0
export NUM_WORKERS=10
./bin/queen-server

Database Configuration

Connection Settings

VariableTypeDefaultDescription
PG_USERstringpostgresPostgreSQL username
PG_HOSTstringlocalhostPostgreSQL host
PG_DBstringpostgresPostgreSQL database name
PG_PASSWORDstringpostgresPostgreSQL password
PG_PORTstring5432PostgreSQL port

SSL Configuration

VariableTypeDefaultDescription
PG_USE_SSLboolfalseEnable SSL connection
PG_SSL_REJECT_UNAUTHORIZEDbooltrueReject unauthorized SSL certificates

SSL Mode Mapping:

  • PG_USE_SSL=true + PG_SSL_REJECT_UNAUTHORIZED=truesslmode=require
  • PG_USE_SSL=true + PG_SSL_REJECT_UNAUTHORIZED=falsesslmode=prefer
  • PG_USE_SSL=falsesslmode=disable

Example for Production (Cloud SQL, RDS, Azure):

bash
export PG_HOST=your-db.cloud.provider.com
export PG_PORT=5432
export PG_USER=queen
export PG_PASSWORD=secure_password
export PG_DB=queen_production
export PG_USE_SSL=true
export PG_SSL_REJECT_UNAUTHORIZED=true

Pool Configuration

VariableTypeDefaultDescription
DB_POOL_SIZEint150CRITICAL - Total connection pool size
DB_IDLE_TIMEOUTint30000Idle timeout in milliseconds
DB_CONNECTION_TIMEOUTint2000Connection timeout in milliseconds
DB_POOL_ACQUISITION_TIMEOUTint10000Pool acquisition timeout (wait for available connection)
DB_STATEMENT_TIMEOUTint30000Statement timeout in milliseconds
DB_QUERY_TIMEOUTint30000Query timeout in milliseconds
DB_LOCK_TIMEOUTint10000Lock timeout in milliseconds
DB_MAX_RETRIESint3Maximum connection retry attempts

CRITICAL: DB_POOL_SIZE

This is the most important tuning parameter. The pool is split:

  • AsyncDbPool: 95% (142 connections at default) - for PUSH/POP/ACK/TRANSACTION
  • Background Pool: 5% (8 connections at default) - for metrics, retention, eviction

Scale with workers: DB_POOL_SIZE = NUM_WORKERS × 15 is a good starting point.

Example Configurations:

bash
# Light load
export DB_POOL_SIZE=50
export NUM_WORKERS=4

# Medium load (default)
export DB_POOL_SIZE=150
export NUM_WORKERS=10

# High load
export DB_POOL_SIZE=300
export NUM_WORKERS=20

# Very high load
export DB_POOL_SIZE=500
export NUM_WORKERS=30

Queue Processing

Pop Operation Defaults

VariableTypeDefaultDescription
DEFAULT_TIMEOUTint30000Default timeout for pop operations (ms)
MAX_TIMEOUTint60000Maximum allowed timeout (ms)
DEFAULT_BATCH_SIZEint1Default batch size for pop operations
BATCH_INSERT_SIZEint1000Batch size for bulk inserts

Long Polling Configuration

The system uses managed ThreadPools for all long-polling operations to ensure proper resource management and visibility.

Worker Configuration

VariableTypeDefaultDescription
POLL_WORKER_COUNTint2Number of dedicated poll worker threads (reserved in DB ThreadPool)
STREAM_POLL_WORKER_COUNTint2Number of dedicated stream poll worker threads (reserved in DB ThreadPool)
STREAM_CONCURRENT_CHECKSint10Maximum concurrent window check jobs per stream worker
DB_THREAD_POOL_SERVICE_THREADSint5Threads for background service DB operations

ThreadPool Architecture:

All worker threads run in the DB ThreadPool with the following allocation:

DB ThreadPool Size = P + S + (S × C) + T

Where:
  P = POLL_WORKER_COUNT (regular poll workers)
  S = STREAM_POLL_WORKER_COUNT (stream poll workers)
  C = STREAM_CONCURRENT_CHECKS (concurrent checks per stream worker)
  T = DB_THREAD_POOL_SERVICE_THREADS (service DB operations)

Default: 2 + 2 + (2 × 10) + 5 = 29 threads

Scaling Guidelines:

  • Low load (< 20 clients): 2-5 poll workers, 2 stream workers
  • Medium load (20-100 clients): 5-10 poll workers, 4 stream workers
  • High load (100-200 clients): 10-20 poll workers, 8 stream workers
  • Very high load (200+ clients): 20-50 poll workers, 12 stream workers

Each poll worker can efficiently handle ~5-10 active consumer groups.

Polling Intervals

VariableTypeDefaultDescription
POLL_WORKER_INTERVALint50How often workers check for new client requests (ms) - in-memory operation
POLL_DB_INTERVALint100Initial DB query interval (ms) - aggressive first attempt
STREAM_POLL_WORKER_INTERVALint100How often stream workers check registry (ms)
STREAM_POLL_INTERVALint1000Min time between stream checks per group (ms)

How it works:

  1. Workers check registry every 50ms (cheap in-memory check)
  2. First DB query at 100ms (aggressive)
  3. If no messages, exponential backoff kicks in

Adaptive Exponential Backoff

When queues are consistently empty, the system automatically backs off to reduce DB load:

VariableTypeDefaultDescription
QUEUE_BACKOFF_THRESHOLDint1Consecutive empty pops before backoff (1 = immediate)
QUEUE_BACKOFF_MULTIPLIERdouble2.0Exponential backoff multiplier
QUEUE_MAX_POLL_INTERVALint2000Maximum poll interval after backoff (ms)
QUEUE_BACKOFF_CLEANUP_THRESHOLDint3600Cleanup inactive backoff state entries after N seconds

Stream Backoff Configuration (separate from regular poll workers):

VariableTypeDefaultDescription
STREAM_BACKOFF_THRESHOLDint5Stream: Consecutive empty checks before backoff
STREAM_BACKOFF_MULTIPLIERdouble2.0Stream: Exponential backoff multiplier
STREAM_MAX_POLL_INTERVALint5000Stream: Maximum poll interval after backoff (ms)

Example backoff sequence (regular poll workers, defaults):

Query 1: 100ms  (aggressive first attempt)
Empty 1: 200ms  (backoff starts)
Empty 2: 400ms
Empty 3: 800ms
Empty 4: 1600ms
Empty 5+: 2000ms (capped)
Messages arrive: Reset to 100ms immediately

Configuration Examples:

bash
# Low latency (higher CPU usage)
export POLL_WORKER_INTERVAL=25
export POLL_DB_INTERVAL=50
export QUEUE_MAX_POLL_INTERVAL=1000

# Balanced (default)
export POLL_WORKER_INTERVAL=50
export POLL_DB_INTERVAL=100
export QUEUE_MAX_POLL_INTERVAL=2000

# Conservative (lower CPU, higher latency)
export POLL_WORKER_INTERVAL=100
export POLL_DB_INTERVAL=200
export QUEUE_MAX_POLL_INTERVAL=5000

Partition Selection

VariableTypeDefaultDescription
MAX_PARTITION_CANDIDATESint100Candidate partitions for lease acquisition

Tuning:

  • Low partition count (<50): Keep at 100
  • High partition count (>200): Increase to 200-500
  • Very high (>1000): Increase to 1000

Batch Push - Size-Based Dynamic Batching

Queen uses intelligent size-based batching that dynamically calculates row sizes and optimizes for PostgreSQL performance.

VariableTypeDefaultDescription
BATCH_PUSH_USE_SIZE_BASEDbooltrueEnable size-based dynamic batching
BATCH_PUSH_TARGET_SIZE_MBint4Target batch size in MB (sweet spot: 4-6 MB)
BATCH_PUSH_MIN_SIZE_MBint2Minimum batch size in MB
BATCH_PUSH_MAX_SIZE_MBint8Maximum batch size in MB (hard limit)
BATCH_PUSH_MIN_MESSAGESint100Minimum messages per batch
BATCH_PUSH_MAX_MESSAGESint10000Maximum messages per batch
BATCH_PUSH_CHUNK_SIZEint1000LEGACY: Count-based chunk size (if size-based disabled)

How it works:

  • Estimates total row size for each message (payload + indexes + overhead)
  • Dynamically accumulates messages until reaching optimal batch size
  • Ensures batches stay within PostgreSQL's sweet spot of 2-8 MB
  • Falls back to legacy count-based batching if disabled

Recommended Settings by Workload:

WorkloadTARGET_SIZE_MBMIN_SIZE_MBMAX_SIZE_MBMIN_MESSAGESMAX_MESSAGES
Small messages (<1KB)631050020000
Medium messages (1-10KB)42810010000
Large messages (>10KB)326505000
Mixed workload42810010000

Response Queue

Response processing uses an adaptive batching system that automatically scales up under load to prevent backlog buildup.

VariableTypeDefaultDescription
RESPONSE_TIMER_INTERVAL_MSint25Response queue polling interval (ms)
RESPONSE_BATCH_SIZEint100Base number of responses to process per timer tick
RESPONSE_BATCH_MAXint500Maximum responses per tick under heavy backlog

How Adaptive Batching Works:

Under normal load, the system processes RESPONSE_BATCH_SIZE responses every timer tick. When backlog is detected, it automatically scales up:

Normal (< 100 items):     100 responses per tick
Moderate (200 items):     200 responses per tick (2x)
High (300 items):         300 responses per tick (3x)
Heavy (500+ items):       500 responses per tick (capped at max)

The system logs warnings when backlog exceeds 2x the base batch size.

Throughput Calculations:

At default settings (25ms interval):

  • Normal: 4,000 responses/sec per worker
  • Maximum: 20,000 responses/sec per worker

Configuration Examples:

bash
# Default balanced configuration
export RESPONSE_TIMER_INTERVAL_MS=25
export RESPONSE_BATCH_SIZE=100
export RESPONSE_BATCH_MAX=500

# Low latency (more responsive, higher CPU)
export RESPONSE_TIMER_INTERVAL_MS=10
export RESPONSE_BATCH_SIZE=50
export RESPONSE_BATCH_MAX=200

# High throughput (handles large backlogs)
export RESPONSE_TIMER_INTERVAL_MS=25
export RESPONSE_BATCH_SIZE=200
export RESPONSE_BATCH_MAX=1000

# Conservative (lower CPU, can backlog under load)
export RESPONSE_TIMER_INTERVAL_MS=50
export RESPONSE_BATCH_SIZE=50
export RESPONSE_BATCH_MAX=200

Tuning Guidelines

  • Increase RESPONSE_BATCH_SIZE if you frequently see backlog warnings
  • Increase RESPONSE_BATCH_MAX for burst traffic handling
  • Lower RESPONSE_TIMER_INTERVAL_MS for lower latency (increases CPU)
  • The system automatically adapts between base and max based on queue depth

Queue Defaults

Basic Defaults

VariableTypeDefaultDescription
DEFAULT_LEASE_TIMEint300Default lease time in seconds (5 minutes)
DEFAULT_RETRY_LIMITint3Default retry limit
DEFAULT_RETRY_DELAYint1000Default retry delay (ms)
DEFAULT_MAX_SIZEint10000Default maximum queue size
DEFAULT_TTLint3600Default message TTL in seconds
DEFAULT_PRIORITYint0Default message priority
DEFAULT_DELAYED_PROCESSINGint0Default delayed processing time (seconds)
DEFAULT_WINDOW_BUFFERint0Default window buffer size (seconds)

Dead Letter Queue

VariableTypeDefaultDescription
DEFAULT_DLQ_ENABLEDboolfalseEnable DLQ by default
DEFAULT_DLQ_AFTER_MAX_RETRIESboolfalseAuto-move to DLQ after max retries

Retention

VariableTypeDefaultDescription
DEFAULT_RETENTION_SECONDSint0Default retention period (0 = disabled)
DEFAULT_COMPLETED_RETENTION_SECONDSint0Retention for completed messages (0 = disabled)
DEFAULT_RETENTION_ENABLEDboolfalseEnable retention by default

Eviction

VariableTypeDefaultDescription
DEFAULT_MAX_WAIT_TIME_SECONDSint0Maximum wait time before eviction (0 = disabled)

Consumer Group Subscription

VariableTypeDefaultDescription
DEFAULT_SUBSCRIPTION_MODEstring""Default subscription mode for new consumer groups

Options:

  • "" (empty) - Process all messages including historical
  • "new" - Skip historical messages, only process messages after subscription
  • "new-only" - Same as "new"

Use Cases:

bash
# Real-time systems - skip historical backlog
export DEFAULT_SUBSCRIPTION_MODE="new"

# Batch processing - process everything
export DEFAULT_SUBSCRIPTION_MODE=""

TIP

Only applies when client doesn't explicitly specify .subscriptionMode(). Existing consumer groups are not affected.

Background Services

Lease Reclamation

VariableTypeDefaultDescription
LEASE_RECLAIM_INTERVALint5000Lease reclamation interval (ms)

Retention Service

VariableTypeDefaultDescription
RETENTION_INTERVALint300000Retention service interval (ms) - 5 minutes
RETENTION_BATCH_SIZEint1000Retention batch size
PARTITION_CLEANUP_DAYSint7Days before partition cleanup
METRICS_RETENTION_DAYSint90Days to keep metrics data

Eviction Service

VariableTypeDefaultDescription
EVICTION_INTERVALint60000Eviction service interval (ms) - 1 minute
EVICTION_BATCH_SIZEint1000Eviction batch size

WebSocket Updates

VariableTypeDefaultDescription
QUEUE_DEPTH_UPDATE_INTERVALint5000Queue depth update interval (ms)
SYSTEM_STATS_UPDATE_INTERVALint10000System stats update interval (ms)

File Buffer Configuration (QoS 0 & Failover)

Queen provides zero-message-loss failover using file-based buffers when PostgreSQL is unavailable.

VariableTypeDefaultDescription
FILE_BUFFER_DIRstringPlatform-specific*Directory for file buffers
FILE_BUFFER_FLUSH_MSint100How often to scan for complete buffer files (ms)
FILE_BUFFER_MAX_BATCHint100Maximum events per database transaction
FILE_BUFFER_EVENTS_PER_FILEint10000Create new buffer file after N events

Platform-specific defaults:

  • macOS: /tmp/queen
  • Linux: /var/lib/queen/buffers

How it works:

1. Client pushes with { buffer: true } or DB is down
2. Event written to: qos0_<uuid>.buf.tmp (active file)
3. File finalized when EITHER:
   - Reaches 10,000 events (high throughput), OR
   - 200ms passes with no new writes (low throughput)
4. Atomic rename: .tmp → .buf
5. Background processor picks up .buf files every 100ms
6. Processes in batches of 100 events per DB transaction
7. Deletes file when complete

Configuration Examples:

bash
# High-throughput configuration
export FILE_BUFFER_DIR=/data/queen/buffers
export FILE_BUFFER_FLUSH_MS=50
export FILE_BUFFER_MAX_BATCH=1000
export FILE_BUFFER_EVENTS_PER_FILE=50000

# Low-latency configuration
export FILE_BUFFER_DIR=/data/queen/buffers
export FILE_BUFFER_FLUSH_MS=10
export FILE_BUFFER_MAX_BATCH=50
export FILE_BUFFER_EVENTS_PER_FILE=1000

Encryption Configuration

VariableTypeDefaultDescription
QUEEN_ENCRYPTION_KEYstring-Encryption key (64 hex characters for AES-256)

Generate a secure key:

bash
openssl rand -hex 32

Example:

bash
export QUEEN_ENCRYPTION_KEY=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef

Security

  • Uses AES-256-GCM encryption
  • Key must be exactly 64 hexadecimal characters (32 bytes)
  • Keep key secure and never commit to version control

API Configuration

General

VariableTypeDefaultDescription
MAX_BODY_SIZEint104857600Maximum request body size (bytes, default 100MB)

Pagination

VariableTypeDefaultDescription
API_DEFAULT_LIMITint100Default pagination limit
API_MAX_LIMITint1000Maximum pagination limit
API_DEFAULT_OFFSETint0Default pagination offset

CORS

VariableTypeDefaultDescription
CORS_MAX_AGEint86400CORS preflight cache duration (seconds)
CORS_ALLOWED_ORIGINSstring*Allowed CORS origins
CORS_ALLOWED_METHODSstringGET, POST, PUT, DELETE, OPTIONSAllowed HTTP methods
CORS_ALLOWED_HEADERSstringContent-Type, AuthorizationAllowed request headers

Analytics Configuration

VariableTypeDefaultDescription
ANALYTICS_RECENT_HOURSint24Hours for recent completion calculations
ANALYTICS_MIN_COMPLETEDint5Minimum completed messages for stats
RECENT_MESSAGE_WINDOWint60Recent message window (seconds)
RELATED_MESSAGE_WINDOWint3600Related message window (seconds)
MAX_RELATED_MESSAGESint10Maximum related messages to return

Monitoring Configuration

VariableTypeDefaultDescription
ENABLE_REQUEST_COUNTINGbooltrueEnable request counting
ENABLE_MESSAGE_COUNTINGbooltrueEnable message counting
METRICS_ENDPOINT_ENABLEDbooltrueEnable /metrics endpoint
HEALTH_CHECK_ENABLEDbooltrueEnable /health endpoint

Logging Configuration

VariableTypeDefaultDescription
ENABLE_LOGGINGbooltrueEnable logging
LOG_LEVELstringinfoLog level
LOG_FORMATstringjsonLog format (json, text)
LOG_TIMESTAMPbooltrueInclude timestamps in logs

Log Levels:

  • trace - Extremely verbose (development only)
  • debug - Detailed debugging information
  • info - General information (recommended for production)
  • warn - Warnings only
  • error - Errors only
  • critical - Critical errors only
  • off - Disable logging

Examples:

bash
# Development
export LOG_LEVEL=debug
export LOG_FORMAT=text

# Production
export LOG_LEVEL=info
export LOG_FORMAT=json

Inter-Instance Communication (Clustered Deployments)

In clustered deployments, Queen servers can notify each other when messages are pushed or acknowledged, allowing poll workers on all instances to respond immediately instead of waiting for their backoff timers.

Protocol Options

ProtocolLatencyReliabilityUse Case
UDP~0.1-0.3msFire-and-forgetRecommended for lowest latency
HTTP~2-5msGuaranteed deliveryFallback or when reliability is critical

You can use either protocol alone, or both simultaneously (UDP for speed, HTTP as backup).

Configuration

VariableTypeDefaultDescription
QUEEN_PEERSstring""HTTP peers: comma-separated URLs (e.g., http://queen2:6632,http://queen3:6632)
PEER_NOTIFY_BATCH_MSint10Batch HTTP notifications for N ms before sending
QUEEN_UDP_PEERSstring""UDP peers: comma-separated host:port or hostnames (e.g., queen2:6633,queen3:6633)
QUEEN_UDP_NOTIFY_PORTint6633Default UDP port for notifications (separate from HTTP API port)

Self-Detection

Each server automatically excludes itself from the peer list based on hostname matching, so you can use the same peer list on all instances in a StatefulSet.

Single Server (Default)

Local poll worker notification is automatic - no configuration needed:

bash
./bin/queen-server

Cluster with HTTP Only

bash
# Server A
export QUEEN_PEERS="http://queen-b:6632,http://queen-c:6632"
./bin/queen-server

# Server B
export QUEEN_PEERS="http://queen-a:6632,http://queen-c:6632"
./bin/queen-server

Cluster with UDP Only (Lowest Latency)

bash
# Server A
export QUEEN_UDP_PEERS="queen-b:6633,queen-c:6633"
export QUEEN_UDP_NOTIFY_PORT=6633
./bin/queen-server

# Server B
export QUEEN_UDP_PEERS="queen-a:6633,queen-c:6633"
export QUEEN_UDP_NOTIFY_PORT=6633
./bin/queen-server

Kubernetes StatefulSet (Both Protocols)

yaml
env:
  # HTTP - guaranteed delivery, batched
  - name: QUEEN_PEERS
    value: "http://queen-mq-0.queen-mq-headless.ns.svc.cluster.local:6632,http://queen-mq-1.queen-mq-headless.ns.svc.cluster.local:6632,http://queen-mq-2.queen-mq-headless.ns.svc.cluster.local:6632"
  # UDP - fire-and-forget, lowest latency
  - name: QUEEN_UDP_PEERS
    value: "queen-mq-0.queen-mq-headless.ns.svc.cluster.local:6633,queen-mq-1.queen-mq-headless.ns.svc.cluster.local:6633,queen-mq-2.queen-mq-headless.ns.svc.cluster.local:6633"
  - name: QUEEN_UDP_NOTIFY_PORT
    value: "6633"

Endpoints

EndpointDescription
POST /internal/api/notifyHTTP endpoint for peer notifications
UDP port 6633UDP listener (when QUEEN_UDP_PEERS is set)
GET /internal/api/inter-instance/statsPeer notification statistics

Statistics are also included in the /health endpoint response.

System Events Configuration

VariableTypeDefaultDescription
QUEEN_SYSTEM_EVENTS_ENABLEDboolfalseEnable system event propagation
QUEEN_SYSTEM_EVENTS_BATCH_MSint10Batching window for event publishing (ms)
QUEEN_SYSTEM_EVENTS_SYNC_TIMEOUTint30000Startup synchronization timeout (ms)

Configuration Examples

Development Environment

bash
export PORT=6632
export HOST=localhost
export PG_HOST=localhost
export PG_USER=postgres
export PG_PASSWORD=postgres
export PG_DB=queen_dev
export DB_POOL_SIZE=50
export NUM_WORKERS=4
export LOG_LEVEL=debug
export LOG_FORMAT=text

Production Environment

bash
export PORT=6632
export HOST=0.0.0.0
export PG_HOST=db.production.example.com
export PG_PORT=5432
export PG_USER=queen_user
export PG_PASSWORD=secure_password
export PG_DB=queen_production
export PG_USE_SSL=true
export PG_SSL_REJECT_UNAUTHORIZED=true
export DB_POOL_SIZE=300
export NUM_WORKERS=20
export LOG_LEVEL=info
export LOG_FORMAT=json
export QUEEN_ENCRYPTION_KEY=your_64_char_hex_key_here
export FILE_BUFFER_DIR=/var/lib/queen/buffers

High-Throughput Configuration

bash
export DB_POOL_SIZE=500
export NUM_WORKERS=30
export BATCH_INSERT_SIZE=2000
export BATCH_PUSH_TARGET_SIZE_MB=6
export BATCH_PUSH_MAX_SIZE_MB=10
export POLL_WORKER_INTERVAL=25
export POLL_DB_INTERVAL=50
export MAX_PARTITION_CANDIDATES=500
export RESPONSE_TIMER_INTERVAL_MS=25
export RESPONSE_BATCH_SIZE=200
export RESPONSE_BATCH_MAX=1000
export RETENTION_BATCH_SIZE=2000
export EVICTION_BATCH_SIZE=2000
export FILE_BUFFER_FLUSH_MS=50
export FILE_BUFFER_MAX_BATCH=1000
export FILE_BUFFER_EVENTS_PER_FILE=50000

Real-Time System (Skip Historical Messages)

bash
export PORT=6632
export HOST=0.0.0.0
export PG_HOST=db.production.example.com
export PG_USER=queen_user
export PG_PASSWORD=secure_password
export PG_DB=queen_production
export PG_USE_SSL=true
export DB_POOL_SIZE=200
export NUM_WORKERS=15
export DEFAULT_SUBSCRIPTION_MODE="new"  # New consumer groups skip historical
export LOG_LEVEL=info

Low-Latency Configuration

bash
export DB_POOL_SIZE=150
export NUM_WORKERS=10
export POLL_WORKER_INTERVAL=25
export POLL_DB_INTERVAL=50
export QUEUE_MAX_POLL_INTERVAL=1000
export RESPONSE_TIMER_INTERVAL_MS=10
export RESPONSE_BATCH_SIZE=50
export RESPONSE_BATCH_MAX=200
export FILE_BUFFER_FLUSH_MS=10

Notes

Boolean Values

Set to "true" to enable, any other value (including unset) is treated as false.

Integer Values

Must be valid integers, invalid values will fall back to defaults.

Encryption Key

Must be exactly 64 hexadecimal characters (32 bytes). Generate with: openssl rand -hex 32

Timeouts

All timeout values are in milliseconds unless specified as seconds.

Troubleshooting

Pool Exhaustion

Symptom: "Database connection pool timeout" errors

Solution:

bash
export DB_POOL_SIZE=300  # Increase pool
export DB_POOL_ACQUISITION_TIMEOUT=20000  # More patience

High CPU Usage

Symptom: CPU constantly high

Solution:

bash
export POLL_WORKER_INTERVAL=100  # Reduce registry checks
export POLL_DB_INTERVAL=200  # Less aggressive polling
export QUEUE_MAX_POLL_INTERVAL=5000  # Higher backoff ceiling

Slow Message Delivery

Symptom: Messages take long to be consumed

Solution:

bash
export POLL_WORKER_INTERVAL=25  # More responsive
export POLL_DB_INTERVAL=50  # Faster initial query
export QUEUE_MAX_POLL_INTERVAL=1000  # Lower ceiling

Database Connection Issues

Symptom: Can't connect to PostgreSQL

Solution:

bash
export DB_CONNECTION_TIMEOUT=5000  # More time to connect
export DB_STATEMENT_TIMEOUT=10000  # More time for queries
export DB_MAX_RETRIES=5  # More retry attempts

Response Queue Backlog

Symptom: "Response queue backlog detected" warnings in logs

Solution:

bash
export RESPONSE_BATCH_SIZE=200  # Process more per tick
export RESPONSE_BATCH_MAX=1000  # Higher ceiling for bursts
export RESPONSE_TIMER_INTERVAL_MS=10  # Check more frequently (higher CPU)

See Also

Built with ❤️ by Smartness