Database Settings
Configuring and running the optional Redis-backed payload cache. For the internal mechanism this enables (why routing a key instead of the full payload matters), see Backends โ Redis Storage.
What use_db Doesโ
- Type:
boolean - Values:
trueorfalse - Default:
true - Description: When
true, payloads are stored in a Redis database. The message key is routed through NSB, and the receiving client retrieves the full payload from Redis. Useful for large payloads. Whenfalse, payloads are transmitted directly through NSB without persistent storage.
database:
use_db: true
When to Use true vs falseโ
Use true when... | Use false when... |
|---|---|
| Payloads may exceed network buffer sizes | Payloads are small and simple |
| You want to decouple payload size from transport performance | You want the absolute simplest setup (e.g. first-time Quickstart) |
| You're running a production-scale simulation | You're testing or prototyping locally |
The Quickstart deliberately uses use_db: false so first-time users don't need to start Redis at all.
Redis Connection Fieldsโ
db_addressโ
- Type:
string - Default:
127.0.0.1 - Description: The IP address or hostname of the Redis server.
db_portโ
- Type:
integer - Default:
5050 - Description: The port on which the Redis server is running.
Redis defaults to port 6379, but NSB examples and guides use port 5050. Be sure your redis-server startup command and your config.yaml db_port value match โ a mismatch here is one of the most common first-time setup errors.
db_numโ
- Type:
integer - Default:
0 - Description: Redis database number to use. Redis supports multiple logical databases (0โ15 by default). Use
0unless you have a specific reason to separate data.
Starting the Redis Serverโ
redis-server --port 5050
Or as a background daemon:
redis-server --port 5050 --daemonize yes
Verify it's running:
redis-cli -p 5050 ping # Should return: PONG
Startup Orderโ
When use_db: true, start services in this order:
- Redis server
- NSB Daemon
- Network Simulator (with
NSBSimClientcode) - Application (with
NSBAppClientcode)
In most cases the simulator should be started before the application so it's ready to fetch() messages when the application begins send()-ing.
Go Deeperโ
- Backends โ Redis Storage โ the payload caching mechanism this setting enables
- Configuration Reference โ full field table including defaults
- Get Started โ installing Redis as a prerequisite