Configuration File
Use the or --stan_config
command line parameter to specify the file to use.
For the embedded NATS Server, you can use another configuration file and pass it to the Streaming Server using -c
or --config
command line parameters.
Since most options do not overlap, it is possible to combine all options into a single file and specify this file using either the -sc
or -c
command line parameter.
However, the option named tls
is common to NATS Server and NATS Streaming Server. If you plan to use a single configuration file and configure TLS, you should have all the streaming configuration included in a streaming
map. This is actually a good practice regardless if you use TLS or not, to protect against possible addition of new options in NATS Server that would conflict with the names of NATS Streaming options.
For instance, you could use a single configuration file with such content:
Note the order in which options are applied during the start of a NATS Streaming server:
- Start with some reasonable default options.
If a configuration file is specified, override those options
with all options defined in the file. This includes options that are defined
but have no value specified. In this case, the zero value for the type of the
option will be used.
In general the configuration parameters are the same as the command line arguments. Below is the list of NATS Streaming parameters:
Note: You may need to scroll horizontally to see all columns.
Notes:
(1) The seed file contains the NKey seed from which the Streaming server can extract the public key and the private key used to sign the nonce sent by the NATS Server when accepting connections from the Streaming server. The file is read during the connection process, the key is used to sign but then wiped from memory. The file must contain the seed file with the following format:
Note that the Streaming Server uses a connection to a NATS Server, and so the NATS Streaming TLS Configuration is in fact a client-side TLS configuration.
Parameter | Meaning | Possible Values | Usage Example | Default Value | Since |
---|---|---|---|---|---|
client_cert | Client key for the streaming server | File path | client_cert: "/path/to/client/cert_file" |
N/A | All |
client_key | Client certificate for the streaming server | File path | client_key: "/path/to/client/key_file" |
N/A | All |
client_ca | Client certificate CA for the streaming server | File path | client_ca: "/path/to/client/ca_file" |
N/A | All |
server_name | Expected hostname returned in the NATS Server certificate | String | server_name: "theserverhostname" |
N/A | v0.17.0 |
insecure | Skips the NATS server’s certificate chain and host name verification. Should not be used in production | true or false |
insecure: true |
false |
v0.17.0 |
Store Limits Configuration
For a given channel, the possible parameters are:
Parameter | Meaning | Possible Values | Usage Example | Default Value | Since |
---|---|---|---|---|---|
max_subs | Maximum number of subscriptions per channel, 0 means unlimited | Number >= 0 | max_subs: 100 |
Inherit from global settings | All |
max_msgs | Maximum number of messages per channel, 0 means unlimited | Number >= 0 | max_msgs: 10000 |
Inherit from global settings | All |
max_bytes | Total size of messages per channel, 0 means unlimited | Bytes | max_bytes: 1GB |
Inherit from global settings | All |
max_age | How long messages can stay in the log | Duration | max_age: "24h" |
Inherit from global settings | All |
max_inactivity | How long without any subscription and any new message before a channel can be automatically deleted | Duration | max_inactivity: "24h" |
Inherit from global settings | v0.9.0 |
File Options Configuration
Parameter | Meaning | Possible Values | Usage Example | Default Value | Since |
---|---|---|---|---|---|
node_id | ID of the node within the cluster if there is no stored ID | String (no whitespace) | node_id: "node-a" |
N/A | v0.9.0 |
bootstrap | Bootstrap the cluster if there is no existing state by electing self as leader | true or false |
bootstrap: true |
false |
v0.9.0 |
peers | List of cluster peer node IDs to bootstrap cluster state | List of node IDs | peers: ["node-b", "node-c"] |
N/A | v0.9.0 |
log_path | Directory to store log replication data | File path | log_path: "/path/to/storage" |
N/A | v0.9.0 |
log_cache_size | Number of log entries to cache in memory to reduce disk IO | Number >= 0 | log_cache_size: 1024 |
512 |
v0.9.0 |
log_snapshots | Number of log snapshots to retain | Number >= 0 | log_snapshots: 1 |
2 |
v0.9.0 |
trailing_logs | Number of log entries to leave after a snapshot and compaction | Number >= 0 | trailing_logs: 256 |
10240 |
v0.9.0 |
sync | Do a file sync after every write to the replication log and message store | true or false |
sync: true |
false |
v0.9.0 |
raft_logging | Enable logging from the Raft library (disabled by default) | true or false |
raft_logging: true |
false |
v0.9.0 |
raft_heartbeat_timeout | Specifies the time in follower state without a leader before attempting an election | Duration | raft_heartbeat_timeout: "2s" |
2s |
v0.11.2 |
raft_election_timeout | Specifies the time in candidate state without a leader before attempting an election | Duration | raft_election_timeout: "2s" |
2s |
v0.11.2 |
raft_lease_timeout | Specifies how long a leader waits without being able to contact a quorum of nodes before stepping down as leader | Duration | raft_lease_timeout: "1s" |
1s |
v0.11.2 |
raft_commit_timeout | Specifies the time without an Apply() operation before sending an heartbeat to ensure timely commit. Due to random staggering, may be delayed as much as 2x this value | Duration | raft_commit_timeout: "100ms" |
100ms |
v0.11.2 |
proceed_on_restore_failure | Allow a non leader node to proceed with restore failures, do not use unless you understand the risks! | true or false |
proceed_on_restore_failure: true |
false |
v0.17.0 |
allow_add_remove_node | Enable the ability to send NATS requests to the leader to add/remove cluster nodes | true or false |
allow_add_remove_node: true |
false |
v0.19.0 |
bolt_free_list_sync | Causes the RAFT log to synchronize the free list on write operations. Reduces performance at runtime, but makes the recovery faster | true or false |
bolt_free_list_sync: true |
false |
v0.21.0 |
bolt_free_list_map | Sets the backend freelist type to use a map instead of the default array type. Improves performance for large RAFT logs, with fragmented free list | true or false |
bolt_free_list_map: true |
false |
v0.21.0 |
nodes_connections | Enable creation of dedicated NATS connections to communicate with other nodes | true or false |
nodes_connections: true |
false |
v0.21.0 |