Server

The server block configures global proxy settings including worker threads, connection limits, and process management.

Basic Configuration

server {
    worker-threads 0              // 0 = auto-detect CPU cores
    max-connections 10000
    graceful-shutdown-timeout-secs 30
}

Options Reference

Worker Threads

server {
    worker-threads 0
}
ValueBehavior
0Auto-detect (number of CPU cores)
1-NFixed number of worker threads

Recommendations:

  • General purpose: 0 (auto-detect)
  • CPU-bound workloads: Number of CPU cores
  • I/O-bound workloads: 2× number of CPU cores
  • Testing: 1 for predictable behavior

Connection Limits

server {
    max-connections 10000
}

Maximum total concurrent connections across all listeners. When reached, new connections are rejected.

Sizing guidelines:

DeploymentSuggested Value
Development1000
Small production10000
Large production50000+

Memory impact: ~10KB per connection.

Graceful Shutdown

server {
    graceful-shutdown-timeout-secs 30
}

When Sentinel receives SIGTERM or SIGINT:

  1. Stop accepting new connections
  2. Wait for in-flight requests to complete
  3. After timeout, forcefully close remaining connections

Default: 30 seconds

Trace ID Format

server {
    trace-id-format "tinyflake"  // or "uuid"
}

Format for request correlation IDs:

FormatExampleLengthNotes
tinyflake2kF8xQw4BnM11 charsDefault, operator-friendly
uuid550e8400-e29b-41d4-a716-44665544000036 charsStandard UUID v4

Trace IDs appear in:

  • Request headers (X-Correlation-Id)
  • Response headers
  • Access logs
  • Error logs

Auto Reload

server {
    auto-reload true
}

When enabled, Sentinel watches the configuration file and automatically reloads on changes.

Default: false

Reload triggers:

  • File modification
  • File creation (if watching a directory)

Process Management

Daemon Mode

server {
    daemon true
    pid-file "/var/run/sentinel.pid"
}

Run Sentinel as a background daemon:

  • Detaches from terminal
  • Writes PID to file for process management

User/Group

server {
    user "sentinel"
    group "sentinel"
}

Drop privileges after binding to ports. Useful when binding to privileged ports (< 1024):

  1. Start as root to bind port 443
  2. Drop to unprivileged user for request handling

Security best practice: Always run as non-root in production.

Working Directory

server {
    working-directory "/var/lib/sentinel"
}

Change working directory after startup. Affects relative paths in configuration.

Complete Example

server {
    // Performance
    worker-threads 0
    max-connections 50000

    // Shutdown
    graceful-shutdown-timeout-secs 60

    // Observability
    trace-id-format "uuid"

    // Hot reload
    auto-reload true

    // Process management (production)
    daemon true
    pid-file "/var/run/sentinel.pid"
    user "sentinel"
    group "sentinel"
    working-directory "/var/lib/sentinel"
}

Environment Variables

Server settings can be overridden via environment variables:

VariableSetting
SENTINEL_WORKERSworker-threads
SENTINEL_MAX_CONNECTIONSmax-connections

Environment variables take precedence over config file values.

Default Values

SettingDefault
worker-threads0 (auto)
max-connections10000
graceful-shutdown-timeout-secs30
trace-id-formattinyflake
auto-reloadfalse
daemonfalse

Tuning for Production

High-Traffic Deployment

server {
    worker-threads 0           // Use all cores
    max-connections 100000     // High connection limit
    graceful-shutdown-timeout-secs 120  // Long drain time
}

Resource-Constrained Environment

server {
    worker-threads 2           // Limited threads
    max-connections 5000       // Lower limit
    graceful-shutdown-timeout-secs 15   // Quick shutdown
}

Signals

SignalBehavior
SIGTERMGraceful shutdown
SIGINTGraceful shutdown
SIGHUPReload configuration
SIGUSR1Reopen log files

Next Steps

  • Listeners - Network binding and TLS
  • Limits - Request and connection limits