Configuring JetStream

Configuring JetStream

Enabling JetStream for a nats-server

To enable JetStream in a server we have to configure it at the top level first:
1
jetstream: enabled
Copied!
You can also use the -js, --jetstream and -sd, --store_dir <dir> flags from the command line

Multi-tenancy & Resource Mgmt

JetStream is compatible with NATS 2.0 Multi-Tenancy using Accounts. A JetStream enabled server supports creating fully isolated JetStream environments for different accounts.
This will dynamically determine the available resources. It's recommended that you set specific limits though:
1
jetstream {
2
store_dir: /data/jetstream
3
max_mem: 1G
4
max_file: 100G
5
}
Copied!

Setting account resource limits

At this point JetStream will be enabled and if you have a server that does not have accounts enabled, all users in the server would have access to JetStream
1
jetstream {
2
store_dir: /data/jetstream
3
max_mem: 1G
4
max_file: 100G
5
}
6
7
accounts {
8
HR: {
9
jetstream: enabled
10
}
11
}
Copied!
Here the HR account would have access to all the resources configured on the server, we can restrict it:
1
jetstream {
2
store_dir: /data/jetstream
3
max_mem: 1G
4
max_file: 100G
5
}
6
7
accounts {
8
HR: {
9
jetstream {
10
max_mem: 512M
11
max_file: 1G
12
max_streams: 10
13
max_consumers: 100
14
}
15
}
16
}
Copied!
Now the HR account is limited in various dimensions.
If you try to configure JetStream for an account without enabling it globally you'll get a warning and the account designated as System cannot have JetStream enabled.

Operator mode account resources limits using the nsc CLI tool

If your setup is in operator mode, JetStream specific account configuration can be stored in account JWT. The earlier account named HR can be configured as follows:
1
nsc add account --name HR
2
nsc edit account --name HR --js-mem-storage 1G --js-disk-storage 512M --js-streams 10 --js-consumer 100
Copied!
Last modified 10d ago