Near Immediate Replication with NT File Replication Service / NTFRS

After fixing the sessiondata issue with php with multiple servers, I then noticed that replication between the two servers was very slow and sluggish – but not because of this issue.

Replication would take place on the average – every 15 minutes by default.

I use the built-in Windows 2000 NT File Replication Service – or ntfrs – to replicate files between the two computers. This way, it keeps everything identical between the servers. Before, 15 minutes for replication wasn't a problem – but when dealing with session data and changes, this was becoming an issue and giving "Invalid Session" messages in Joomla if the session file had not replicated yet.

After doing more research, I discovered that by adding two registry entries to the ntfrs parameters.

Here is where they are added: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTFrs\Parameters

Add these two DWORD Entries: "DS Polling Short Interval in Minutes" "DS Polling Long Interval in Minutes"

The minimum for these values are 1 minute; the default (which means these entries don't exist) is five minutes. I set BOTH of them to one minute. Replication now happens sometimes within seconds – but no more than one minute from my tests.

Basically the difference between the two entries above is this – Whenever the file replication service notices that there are a consecutive eight short polling times with no changes, it will change over to the long interval and continue checking with the long interval time. During the long interval time if a change is noted, the change will be replicated at the end of the long interval – and then the service will revert back to the short interval for eight consecutive times. The process starts over again.

By setting both of the above entries to one minute each, they basically are the same thing and the interval remains constant – and your files are replicated every one minute. Of course, if you have a huge file that takes more than one minute to transfer, that won't happen. These intervals are just the periods for how long the service will check for file changes in the replication share.

This is not real-time replication; it isn't exactly immediate, but it definitely is a speed up and boosts the performance of replication. I have a very odd use of this replication feature with moving web spaces between servers, but it works.