The SPQR Router configuration can be specified in JSON, TOML, or YAML format. The configuration file passing as a parameter to run command:

spqr-router run --config ./examples/router.yaml

Refer to the pkg/config/router.go file for the most up-to-date configuration options.

General Settings

SettingDescriptionPossible Values
log_levelThe level of logging output.debug, info, warning, error, fatal
daemonizeWhether to run the router as a daemon.true, false
reuse_portWhether to create a socket with SO_REUSEPORT and SO_REUSEADDR optionstrue, false
use_systemd_notifierWhether to use systemd notifier.true, false
systemd_notifier_debugWhether to run systemd notifier in debug mode.true, false
with_coordinatorWhether to run the router in a special coordinator mode.true, false

Network Settings

SettingDescriptionPossible Values
hostThe host address the router listens on.Any valid hostname
router_portThe port number for the router.Any valid port number
router_ro_portThe port number for the read-only queries router.Any valid port number
admin_console_portThe port number for the admin console.Any valid port number
grpc_api_portThe port number for the gRPC API.Any valid port number

Frontend Rules

Frontend rule is a specification of how clients connect to the router.

Refer to the FrontendRule struct in the pkg/config/router.go file for the most up-to-date configuration options.

SettingDescriptionPossible Values
dbThe database name to which the rule appliesAny valid database name
usrThe user name for which the rule is applicableAny valid username
search_pathThe search path used for the database connectionAny valid search path
auth_ruleSee General Auth SettingsObject of AuthCfg
pool_modeThe mode of connection pooling usedSESSION, TRANSACTION
pool_discardDetermines if connections are discarded from the pool under certain conditionstrue, false
pool_rollbackSpecifies whether to execute a rollback on connections returned to the pooltrue, false
pool_prepared_statementIndicates if prepared statements should be pooledtrue, false
pool_defaultIf set to true, uses the default pool settings defined elsewheretrue, false

Backend Rules

Backend Rule is a global setting that determines how the router connects to every shard.

Refer to the BackendRule struct in the pkg/config/router.go and pkg/config/auth_backend.go file for the most up-to-date configuration options.

SettingDescriptionPossible Values
dbThe database name to connect to.Any valid database name
usrThe username for database authentication.Any valid username
auth_rulesA map of authentication rules for backend connections.Map of string keys to AuthBackendCfg objects.
auth_ruleThe default auth rule. On object with usr and password fieldsAn AuthBackendCfg object
pool_defaultIndicates if the connection should use the default pool settings.true or false
connection_limitThe maximum number of connections allowed to the backend.Any integer value
connection_retriesThe number of retries for a failed connection attempt.Any integer value

Shards

Map of string to Shard objects. Refer to the Shard struct in the pkg/config/router.go file for the most up-to-date configuration options.

SettingDescriptionPossible Values
hostsA list of host addresses for the shard.Array of host addresses
typeUse DATA alwaysDATA, WORLD
tlsSee auth.mdxObject of TLSConfig

Statistics Settings

SettingDescriptionPossible Values
time_quantilesThe list of time quantiles to show querry time statistics. When empty, no statistics is collectedArray of floats. For example, [0.8]

Feature Flags

SettingDescriptionPossible Values
maintain_paramsWhether to maintain parameters flag.true, false
query_routing.default_route_behaviourWhether to explicitly block multishard queries.BLOCK, ALLOW
with_jaegerWhether to integrate with Jaeger for tracing.true, false
world_shard_fallbackWhether to enable fallback to world shard.true, false

Mode Settings

SettingDescriptionPossible Values
pool_modeDefines the pool modes.SESSION, TRANSACTION
shard_typeDefines the shard types.DATA, WORLD
router_modeTL;DR Use PROXY always. Defines the router modes. Local mode acts like a connection pooler, Proxy mode acts like a query router in sharded installation.LOCAL, PROXY

Debug Settings

SettingDescriptionPossible Values
show_notice_messagesWhether to show notice messages.true, false
pid_file_nameThe file name to store the process ID.Any valid filepath
log_file_nameThe file name for logging output.Any valid filepath
pgproto_debugPostgreSQL protocol debug flag.true, false

QDB Settings

SettingDescriptionPossible Values
use_init_sqlWhether to execute commands from Init SQL filetrue, false
use_coordinator_initWhether to execute commands from Init SQL file on Routertrue, false
init_sqlPath to SQL file that router will execute before the startAny valid file path
memqdb_backup_pathMemQDB backup state path. MemQDB’s state restored if a file backup exists during the router startup. If there is no file, init.sql will be usedAny valid file path
memqdb_persistentWhether to persist router configuration in non-clustered setuptrue, false

Was this page helpful?