A quick page on some settings that can affect nwserver performance.
Primary Game Options
Example: You run NWN as a server, with NWNX, on a machine with 4 cores, and 16GB RAM.
Relevant game options:
[server.tweaks]
2da-engine-cache-size = 1000
2da-user-cache-size = 1000
game-object-cache-size = 20
threaded-timers-resolution = 1
use-threaded-timers = true
[server.tweaks.power-saving]
clients-required-to-disable = 1
[server.tweaks.resman]
max-memory-usage = 0.5000000000000000
This essentially will maximise the RAM usage for:
- 2da caching - the lines 2da-engine-cache-size and 2da-user-cache-size - this should mean any Get2DAString or extensive otherwise uncached base 2das are cached when read once. The default values are 11 and 10 which are really low, 1000 is the maximum.
- Object caching - the game-object-cache-size is at the maximum of 20 which can store up to 1048576 entries. The default is 16.
- Resman caching - the max-memory-usage is set to 0.5 or 50% of total physical RAM (rather than 12.5% of RAM), in this example case 8GB will be assigned. Resman controls which general data files (eg creature and item blueprints, conversation files, player BICs, or area files, or whatever) are loaded into memory.
It also utilises the most CPU possible:
- Threaded timers - The only real major use of another thread you can control, use-threaded-timers is enabled and threaded-timers-resolution is set to 1 (default is 100) - for the most performant timer reads. NWN will use a bit of a second thread. Your other cores can be used for the OS and other tasks (eg backups). The reason this should increase performance is asking the OS for the time takes time and many objects in a large server means this happens a lot. A thread polling the OS for accurate time allows the game to run a bit faster.
- Power saving disabled - clients-required-to-disable should always be left at 1 and will make the game run continually and never run sleep() commands, meaning 100% CPU usage on one core will occur which can help stop hiccups. You should even on a low spec server never set this above 1.
You will have to monitor performance of the system especially RAM usage under this config. The max-memory-usage may need to be tweaked downwards if the OS and game uses more RAM than expected.
Logging
A note that there are a variety of additional log options in nwserver and these should be enabled on a case by case basis, but usually only a test server.
Proper server logging should utilise the NWNX available options.
For better tracing of problems in 8193.37 use Tracy, this can sometimes even be light enough to run continually but better to enable when required (which can be done when the server is running without restarts) for instance to get data during some bigger fights or instances you experience lag is best to trace issues.
Exporting Characters
The players can by default export their character using the menu. With characters having hundreds of items on them, a reasonably significant amount of client-initiated data transfer involved.
This can impact a larger server since many characters may export their BICs causing hiccups.
To block use NWNX NWNX_ON_CLIENT_EXPORT_CHARACTER_BEFORE event, subscribe to it and skip it. You could add functionality to allow a DM to unblock it for a period, or run a separate server on a shared vault to allow exports to not affect a primary server.
Message Update Limits
The server itself won't be made to run faster by altering these settings but these 4 settings can alter how fast clients get to see changes the server needs to send - eg creatures appearing, changing location, VFX's going off, placeables, doors, etc. - this improves the player experience immensely especially in any large fight involving lots of players seeing lots of other players and other creatures since everyone sees things happening nearly at the same time.
See Game Options for a writeup of them. The 200ms interval is usually adequate (5 updates per second) but the 400 byte message limit is potentially too low especially with NWN:EEs additional data sent (eg visual transforms) during bigger areas of action for players.
[server.tweaks] game-obj-update-interval = 200000 game-obj-update-interval-loading = 20000 message-limit = 400 message-limit-loading = 2000
The reason to leave them alone is unless you have clients notably being bonked on the head by "invisible creatures" who "pop out of nowhere" you probably won't need to update them.
If you tweak these make sure to test thoroughly and profile if possible.
Lag Busting
A semi-related topic is once a server is tuned in its settings, and you're still getting lag/hiccups which could be solved, what do you do? There is an article on the Lexicon about Lag Busting which can help. Primarily profiling in NWNX can assist in finding bad areas (high pathfinding times) huge amounts of objects causing issues (NWNX potentially can optimise this with tweaks) and other issues (such as certain scripts taking a long amount of time to run).