Go down


Post  DM Ramen on Sat Dec 13, 2008 1:22 pm

Quoted from Galruthe


This is essentially a server optimization listing that highlights recommendations based on what the bioware aurora engine is designed to handle. I didn't write this i got it off the official forums. Obviously many of the points are simply unavoidable, but here it is anywho:


1.1. Server Hardware:

1.1.1. As a rule of thumb, you can host 1 player reliably per 50 mhz of CPU. A 2.0 GHZ processor can host 40 players. This of course is highly dependent on the design of your module.

1.1.2. Get the fastest Ram possible. 512 - 1024 mb is recommended.

1.1.3. I have had the 50% CPU bug (with no players on the server) only on a generic VIA chipset board so I would recommend a quality motherboard. I have never seen that issue with the nforce2 chipset and the performance increase was dramatic.

1.1.4. An overlooked part of the server hardware is the NIC. Buy a Server NIC if possible. Server NICs have onboard memory and also do onboard processing. This will save your CPU some cycles. You will notice that your ping time is slightly lower and that it stays lower even when more players join your server. Response time is also faster in game.

1.1.5. Get a fast hard drive. ATA 133, 7200 RPM, 8MB Cache, or better is recommended.

1.2. Operating System:

1.2.1. Server 2000 is the best performing and most stable OS in my experiences. Windows XP did not perform as well as the server line. Reports in the forums suggest Advanced Server 2000 is the optimal OS to host NWN with. I’m sure the Linux folks will have something to say about that.

1.3. Bandwidth:

1.3.1. Download is not as important as upload. You will use twice the upload then you do download when hosting a server.

1.3.2. Upload - I have run several tests for a few weeks straight (moved over 70gbits of NWN traffic) with some bandwidth tool. My module uses about 100 “KBITS” (on average) of upload to host 30 players. It can use twice that, in heavy battles.

1.3.3. A Clean Line ? If you have a huge upload but a the line is plagued with packet collisions and constant dropped packets then most likely your server will suffer from it.

1.3.4. I have used Cable Internet (1.5/256), ADSL 768/384, and ADSL 1.5/768. I suggest ADSL as the lines are cleaner and they are more affordable (kbit upload per $). Cable pings fluctuate way too much. To host 64+ players WITH heavy combat you will need at least a plan with 768 kbit upload.

1.4. Network Tweaks:

1.4.1. Go to to learn about bandwidth and the Internet. I suggest doing a few tweaks with their tool DR TCP. Adjust numbers like TTL, RWIN, Selective ACKS, and MTU.

1.5. Operating System Tweaks

1.5.1. I suggest turning of all the services that you don’t need, Messenger (don’t confuse this with instant messenger), IIS, etc.

1.5.2. You may also want to turn off your page file (virtual memory). Set it to 0mb. This will force the cache to sit in your ram (fast) vs. sitting on your hard drive, which is much slower. Only do this if you have a lot of Ram and a stable server.

1.6. Other:

1.6.1. When setting up your home network always use SHORT cables, very high quality cables, and kept the cables away from any electrical interference.

1.6.2. It is also a good idea to reboot your modems on occasion as errors build up in the modem’s memory.

1.6.3. Reboot your server on occasion.

1.6.4. Backup your server vault onto a separate hard drive.

1.6.5. Use Firedeamon to reboot your server every 8 hours or so.

1.6.6. Look in your servervault folder. There is a folder called “Lost + Found”. All the corrupted character files go there. Delete them and search your entire vault deleting those exact files every time you see them. If you don’t they may cause your module to crash.
DM Ramen
DM Ramen

Male Number of posts : 354
Registration date : 2008-12-04

View user profile

Back to top Go down


Post  DM Ramen on Sat Dec 13, 2008 1:23 pm


2.1. Area Design:

2.1.1. Keep areas under 16x16. This will lower loading times for players. There are also suggestions that any size larger then this causes lag. I cannot confirm it but I can see how a large area that is constantly being traversed by some scripts can cause performance problems.

2.1.2. Do not use bridges, corridors, or tiles with complicated turns in high combat zones. This can cause more object collision and more pathfinding calls thus hurting the server’s performance.

2.2. Max Areas and Module Size:

2.2.1. The Bioware developers have said many times that modules were not meant to be very large. Bioware has stated that modules over 30mb with hundreds of areas will push the limits of the NWN engine. This suggests that you may run into some performance issue if your module exceeds “some limit”. My server has 150 areas and is 16mb and I don’t see any noticeable performance issues. I do remember a server FragHaus Krynn that used to host 80-96 players constantly, but they only had 40 areas so go figure.

2.2.2. I have a new world with several hundred areas and is about 40mb, the CPU does jump from 0 to 5% with no scripts executing so I know size takes a toll on CPU not just memory.

2.2.3. Keep your module as small and as simple as possible.

2.2.4. If your module exceeds 30 mb I suggest breaking it into two parts over 2 servers.

2.3. Shops

2.3.1. Keep the shops small so that the amount of information that needs to be sent to the client can be minimized.

2.3.2. Cleanup all item in the merchant shops that are not there by default.

2.4. Specific Scripts and Functions That Need Optimization:

2.4.1. Bioware AI scripts - I suggest commenting out all the ambient animations, silent shouts, and any other miscellaneous checks.

2.4.2. Bioware Henchmen AI scripts ( Tomi) ? comment out the checks that you don’t need. Henchmen AI can be more expensive then the standard AI as there are a lot more checks made. Remove what you don’t need.

2.4.3. I would suggest disabling all the fancy features like speaking and ambient movements in the nw_c2_default9 script. They can be quite expensive especially if you have an NPC that is stuck in a corner and is constantly making pathfinding calls. These also break the perception of creatures on occasion making them blind.

2.4.4. All spell scripts that do area damage need to be fixed. I suggest placing a delay when damaging an object in the script. I have altered the way damage is done because if the server tries to synchronize damage with everyone in the screen and gets overloaded with tasks it can start to lag.

2.4.5. George has also stated that a DelayCommand must be placed in the GetFirstObjectInShape() loop when applying damage to an object or it may crash the server. Example, “DelayCommand(0.1, ApplyEffectToObject(duration, damage effect, object));” .

2.4.6. The perception script for monsters is by far the most executed script in NWN. It executes every time something is perceived, dies, vanishes, etc. If anything you may want to make that script shorter and don’t spawn mobs.

2.4.7. Change any spell script that adds the OnHitCastSpell property to an item. This property causes performance issues. This is on a few spells, like bless, darkfire, flame weapon, deafening clang, and alchemist’s fire. Change these effects to dynamic temporary properties like fire damage 1d6.

2.4.8. You may want to verify any default scripts that are executing, make sure they are not expensive. You can verify this with the NWNX Profiler.

2.4.9. Bioware wrote a few scripts that use recursive calls. Recursion is not a bad thing if its written properly, but it must be tail recursive so that it simulates a for loop on the stack. A few scripts like combust and bigby’s and some of your dying scripts may be recursive. I suggest you place some debug statements in them to make sure they are not going out of control.

2.4.10. Creature AI can take up a good chunk of your processor’s time. Try lowering the AI’s priority to low, “SetAILevel(OBJECT_SELF, AI_LEVEL_LOW);”. It will automatically (if set to default) set itself to very low when all players have left the area.

2.5. Specific Scripts and Functions That Need To Be Removed:

2.5.1. If you have a huge module and don’t mind having NPCs standing still I suggest you remove any reference to WalkWaypoints(). Also disable it in script nw_walk_wp, which executes after conversations with NPC’s end. WalkWaypoint is also found in the default AI and inside the core AI include files.

2.5.2. Never ever never ever use the flag SetSpawnInCondition ( NW_FLAG_SHOUT_ATTACK_MY_TARGET ) in the nw_c2_defaul9. Comment it out.

2.5.3. In x2_sig_state comment out sendforhelp() and comment it out of any other script you find it in. If you don’t then creatures under effects like charm, confuse, fear, etc will call for help on heartbeat to every creature in the module in the same faction. Bad!

2.6. Mandatory Scripts

2.6.1. Place a cleanup script in your OnExitArea event handler to run when no players are in that area. Cleanup items on the ground, items in placeables, close doors, cleanup Area of Effect spells, disable traps on the ground and on placeables, delete any invisible object that you may have used for your scripts, and delete any variables that you no longer need

2.7. Scripting Miscellaneous

2.7.1. Never use 2da calls in a loop

2.7.2. Do not store a lot of variables on a single object.

2.7.3. Set limits on how many times your loops can execute.

2.7.4. Unused global variable take up memory so use constants.

2.7.5. If you really need to use a heartbeat script that is expensive make it a Pseudo-heartbeat that executes every other heartbeat or longer.

2.8. Event Handlers That Execute Frequently

2.8.1. OnAcquire script fires for both creatures and players. This is also executed for every single item that a player has in their inventory when they enter the module.

2.8.2. OnAreaEnter and OnAreaExit handlers fire every time a player or creature enters/leaves/dies/is summoned in an area.

2.8.3. The OnPerception event fires twice for every single creature, every time a new object enters their perception radius. This includes summons, players, and monsters. It also fires every time something vanishes or dies. But that’s not the problem, it actually traverses every single creature every single time one creature appears/disappears. So don't spawn mobs!!

2.8.4. OnHeartbeat event fires every six seconds or longer depending on the server’s performance. This can be bad if there are numerous heartbeats executing. Heartbeats may execute on creatures, on areas, on the modules, on placeables, and on persistent area of effect spells. If all possible try not to use this event.

2.8.5. The OnCoversation event fires every time a creature does a shout. This includes silent shouts.

2.8.6. OnHitCastSpell event can be very expensive if placed on a weapon that a player is swinging 9 times per round x say 10 players. You should remove it from your module.

2.9. Potentially Expensive Functions If Used Frequently Or In Loops

2.9.1. All GetFirst/Next Functions

2.9.2. All Database Functions

2.9.3. Destroy and CreateObject

2.9.4. GetCreatureTalentBest/Random

2.9.5. LineOfSightObject or LineOfSightVector

2.9.6. ApplyingEffectToObject if applying way too many effects.

2.10. Area Design and Placeables:

2.10.1. There are suggests that placeables cause lag. This is usually linked to placeables with high polygon counts. So don’t spawn large, flashy, high quality placeables unless you need them.

2.10.2. Don’t put heartbeat scripts in your placeables, unless its only for a very few.

2.10.3. Are you using hidden doors in your modules. OMG they use a heartbeat script. Its better to make a generic trigger to spawn the hidden door.

2.10.4. Placeables can cause a number of pathfinding issues for creatures and players. Don’t put placeables on the corners of a turn. Also don’t use placeables in high combat zones.

2.10.5. Bioware’s internal rule is not to use more then 2 placeables per tile. I think all builders should follow that rule.

2.10.6. Don’t ever put a placeable on the seems or corners of a tile as it causes issues with pathfinding.

2.11. Comments on sounds:

2.11.1. All I can say is keep them to a minimum.

2.12. Comments on 2da’s, HakPaks, 3rd party software, and other custom content:

2.12.1. There are suggestions that large HakPaks cause performance issues for players and the server.

2.13. NPC’s

2.13.1. Don’t spawn mass mobs. Keep spawn far apart and in small numbers. Its better to have 2 strong goblins, then 15 weak ones attacking a player.

2.13.2. Don’t give your monsters a ton of Area of Effect spells.

2.14. Module Corruption

2.14.1. Did you ever restore your module from a backup when the toolset crashed, maybe multiple times in it's lifetime? If so, there is a chance that files inside your module have been corrupted. So never use a backup if your module crashes in the toolset.

2.14.2. If your module won’t startup or you believe it is corrupted, you may want to check for 0 byte large files (especially .itp files) inside the module (i.e. in the temp0 directory in nwn\modules when you have the module open in the toolset).

2.15. Scripts That Should Be Cached

2.15.1. A few scripts should be cached: All monster AI scripts, all henchmen AI scripts (look for Tomi in the toolset), all the Module Event scripts, x2_s2_whirlwind, the most frequently used spells, your treasure scripts, OnEnterArea and OnExitArea scripts, polymorph scripts, turn undead script, and other scripts that are called quite frequently. You can determine this by using the NWNX profiler.

2.16. Other

2.16.1. Do not enable script debugging in the toolset or your module will permanently double in size. There is no way to reverse it.
DM Ramen
DM Ramen

Male Number of posts : 354
Registration date : 2008-12-04

View user profile

Back to top Go down


Post  DM Ramen on Sat Dec 13, 2008 1:24 pm


3.1. Events guaranteed to crash a server:

3.1.1. Be careful when deleting items. On occasion if the item is being handled by 2 objects its may crash the server.

3.1.2. Filter out the shifter weapons in the OnAcquire script of your module. If you don’t players may try to sell it and when that item is deleted it crashes the server.

3.1.3. If you delete too many objects at once your server will freeze with 100% CPU. To avoid this you can set a limit to how many times your while loops execute (assuming you use a loop). So your condition should be like “while (GetIsObjectValid (oThing) ) && iCount < 50)).

3.1.4. NWNX (profiler) causes my server to crash more frequently. On average my server crashes once every 2 days, but with NWNX enabled I would say about 6 times per day.

3.2. Events that start long debilitating lag:

3.2.1. This seems to be a problem that that hits my server on occasion. It usually happens when too many players are in the same area or when there is a big fight with a boss. Its best enforce a max party size and keep bosses from casting lots and lots of spells.

3.3. Events that start or create intermittent lag:

3.3.1. Whirlwind is expensive and can cause lag.
3.3.2. Spell casting
3.3.3. Combat
3.3.4. Too many Heartbeat scripts
3.3.5. Server overload

3.4. Events that are expensive to the server:

3.4.1. Object creations, like creatures spawning and treasure spawns.
3.4.2. Object deletion
3.4.3. General Combat and Creature AI

3.5. Events that are bandwidth intensive:

3.5.1. Players logging into the server. This can cause a fairly huge spike in upload. Remember I said my server uses 100kbits of upload for 30 players, well if one person logs in its spikes up to 250kbits for a few seconds. Keep your OnClientEnter script super simple. Also the OnAcquire script fires when a player enters the server. I suggest not giving away magic bags on your server especially the ones that give weight reduction.

3.5.2. Creature combat with players.

3.6. Other:

3.6.1. Never ever use the built in Auto Save. I can cause lag and crash your server.
DM Ramen
DM Ramen

Male Number of posts : 354
Registration date : 2008-12-04

View user profile

Back to top Go down


Post  DM Ramen on Sat Dec 13, 2008 1:25 pm


4.1. List of Aurora Engine features that hinder the hosting of large persistent worlds:

4.1.1. There are probably too many to list

4.2. List known internal Aurora Engine limitations that are out of the administrators/builders control:

4.2.1. There are probably too many to list

4.3. Other:

4.3.1. Doors and Traps cannot be respawned easily.

4.3.2. If 30 players stand in a single area next to eachother on a module with 1 area your server will lag. This suggests that there are a lot of calculations going on in the background to synchronize PCs that are doing absolutely nothing.
DM Ramen
DM Ramen

Male Number of posts : 354
Registration date : 2008-12-04

View user profile

Back to top Go down


Post  DM Ramen on Sat Dec 13, 2008 1:25 pm


5.1. Tools that help determine bottleneck/inefficiency on a physical server:

5.1.1. Use the build-in Perfmon tool for windows to determine what resources are being used most frequently.

5.2. Tools that help determine bottleneck/inefficiency in a module:

5.2.1. Download the NWNX profiler. It will show you how many times all your scripts have executed and how long it took. You will be amazed.
DM Ramen
DM Ramen

Male Number of posts : 354
Registration date : 2008-12-04

View user profile

Back to top Go down


Post  DM Ramen on Sat Dec 13, 2008 1:25 pm


6.1. Cleanup a dead corpse in combat. If you don’t the corpse will be considered as an ally to the creatures and will increase resource consumptions.

6.2. The OnSpellCastAt script does not fire all the time. It may not fire when a creature is hit by an aura.

6.3. Items in a player’s inventory uses up memory.
DM Ramen
DM Ramen

Male Number of posts : 354
Registration date : 2008-12-04

View user profile

Back to top Go down


Post  DM Ramen on Sat Dec 13, 2008 1:26 pm

7. Personal Theories
7.1. I have a theory that the Holy Avenger item property causes lag. Just image on every single hit the sword is trying to dispel every spell on the target. Try 8 players with 5-9 attacks per round attacking the same target. I say remove it and replace it will an item that does positive damage that that has some sort of dispel on it whether a spell or a custom script so the DC of the dispel can equal the paladin’s level.

7.2. I believe allowing placeables to have animations may cause some performance issues.
DM Ramen
DM Ramen

Male Number of posts : 354
Registration date : 2008-12-04

View user profile

Back to top Go down


Post  Sponsored content

Sponsored content

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum