This is a set of recommendations for running a persistent nwserver instance. See also Server Performance Settings for some advanced changes to make if more performance is needed.

NWServer Server Specification Recommendations

OS

Linux is recommended to run your nwserver, both because it is much more efficient (especially for disk access) but also because NWNX will not run on Windows. NWNX adds many tweaks and more functionality to the base nwserver and is almost a necessity for any reasonably sized persistent world.

On Windows you may be able to use the WSL subsystem to run the Linux server. You can use Docker to host nwnx/nwserver as well.

CPU

nwserver runs as mostly a headless single threaded executable, with some secondary threads for some timing functionality. It is therefore recommended to provide at least 2 CPUs to a main server, one for the OS and one for nwserver itself.

The speed of the CPU should be as fast as possible due to the main single thread that nwserver uses. IE: more GHz vs more cores, 3.0Ghz 6 core processor is better than a 2.1Ghz 24 core processor. The processor age can be relatively old since nwserver doesn't require the latest modern processor to run.

RAM

RAM is useful for caching a lot more data with NWNEE. See Server Performance Settings for how to cache more files/2das. It would be wise to test loading the entire module and running it for some time to gauge usage. Having 4GB of RAM would usually be sufficient for small amounts of players up to 16GB for bigger servers

Faster RAM is of course always better, and it would of course be wise to run ECC memory since it is expected the server will run 24/7 and any memory issues would otherwise crash a server.

Disk

An SSD should be used to host the nwserver instance. These files are usually the core game, module and hakpack files. Since not everything is cached at startup only on access this helps speed up accessing files and importantly writing files such as using ExportAllCharacters regularly which writes out all the player BICs, or for heavier SQL usage.

Note: The files the server loads can be stripped of some clientside only files (eg textures) by dummying them to be 0 size, and some server packages do this for the base game files, but the effort involved stripping or dummying these files usually isn't warranted for your hakpack files since it makes management of them much harder.

Network

A dedicated IP address with the right firewall ports open, and a reasonable amount of bandwidth is recommended. While the game was made for the late modem 56 kbit/s and early DSL speeds on the client end, the server still has to serve all those clients, additionally more bandwidth can allow the use of better settings for client updates.

Make sure to monitor bandwidth and latency of clients, some hosting companies are better than others in regards to UDP packets. Minimising the use of the master server relay is a good idea.

Specifications Summary

These are not hard rules and only recommendations.

  • OS: Linux (with NWNX)
  • CPU: Fast CPU speed, with 2 or more cores
  • RAM: 4GB minimum to 16GB maximum (heavily OS and module / hakpack size dependant, make sure to test!)
  • Disk: Fast SSD with enough space for uploading new versions of files (eg 30GB OS + nwserver base + 10GB hakpacks means you need around 60GB minimum for having 2 copies of the hakpacks at once).
  • Network: Dedicated IP address with sufficient bandwidth and appropriate UDP firewall ports open

NWServer Updates

Once you make your module start you will eventually want to update it; either the module or the TLK and hakpack files or both. Never change any files when nwserver is running and potentially accessing them. Changing an in use hakpack will cause the resource manager in NWN to start to throw errors as it cannot find the files it has indexed. Loose files may be easier to add or replace but may require advanced NWNX usage to make use of.

The cleanest process for updating a server is usually:

  • Upload new module, TLK and hakpack files to staging folder outside of the game directory
  • Shutdown nwserver
  • Move the new module, TLK and hakpack files to the proper locations (or delete what is there and then move them over)
    • Also any additional server maintenance (patching, restarts) can be done now
  • Start nwserver

Most server admins will script this work to do it cleanly and quickly.

Doing any other mixture of actions may cause the server to see ghost files or have read issues on files.

Multiple NWserver Setups

When you want to run multiple servers, either like shards, event servers or having a test server, there are some things to consider:

  • Make sure they get unique cryptographic secrets (in the cryptographic_secret file) do not share it across instances let it regenerate properly for individual cases
  • Serve the instances off different servers if at all possible
    • This benefits performance
    • If you do have 2 nwserver processes running on 1 server, do not share the module, TLK or hakpack files since these are not loaded into memory so there may be read conflicts as two instances of nwserver want to access the same files at the same time, plus issues if you restart them at different times meaning they need different versions of the files at the same time
  • If data needs to be shared consider going past the in-built sqlite to the NWNX MySQL plugin, or if the sqlite DB is being shared consider the performance impacts (since one nwserver instance accessing the sqlite file will block access to another accessing it)
  • If a shared server vault of character BICs is required this is most easily done by having some kind of NFS share between server instances if nwserver instances are running on different servers
    • Regardless of sharing method; make sure someone cannot log into both servers at the same time with the same character (or the same time to both regardless). This requires sharing data on the DB about who is connected to where.
    • You can use ActivatePortal to manage transitions between servers

NWSync

It is recommended to setup and use NWSync to avoid having players download hakpacks separately.

The files should be provided on a separate server instance than the one running nwserver if possible. This is because the web tech (apache etc.) serving nwsync directories is usually multithreaded and will heavily use the CPU, bandwidth and disk IO of the server, degrading nwserver performance when nwsync files are being served to clients, or potentially nwsync will fail to serve files properly to clients since nwserver is active at the same time.

Note one nwsync server can provide multiple repositories, eg if you have a test server and a live server, which is more efficient if many of the files are the same anyway.

Performance Monitoring

The latest versions of the game now include Tracy by default, which is a very helpful way to capture performance information and inspect it. This can find bottlenecks in nwscript coding, performance issues due to pathfinding or other issues (eg: massive inventories or stores being loaded from or written to disk causing stalling).

The game runs at 30FPS for the game logic, so all updates for a given frame should fit in around 33ms of time, meaning if a script runs for more than 33ms you'll get hiccups.

If you have performance issues clientside but the server is doing fine, this may be due to lack of update data - see Server Performance Settings for more information on advanced settings to change for this.

NWN:EE now runs for much longer periods of time with less memory leaks, so running NWServer for longer periods should be fine. If it is common you are restarting every day, you should capture performance metrics (Tracy and OS based metrics eg CPU/RAM/disk I/O) and check for issues with your module if you spot any (eg; pathfinding issues where NPCs are getting stuck on bad walkmesh or placeable setups, lots of leftover creature spawns, bloated stores).

Additionally if you are using a shared server hosting company, ie you are vying for resources from other servers, this is not recommended when performance is required since your nwserver instance may be needing more CPU but not getting it from the parent host.

  • No labels