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.

Joomla Admin Fix

After adding more clients to my list, I noticed that I began getting problems with Joomla. Recently I upgraded to Joomla 1.0.14 from Joomla 1.0.13.

I host web sites on two separate servers that are connected by a link. In the case that the server goes down either from a hardware issue or a problem with the Internet line, the other server will pickup without missing a beat! All web space is replicated and database information is replicated.

However, I started to get "Invalid Session" errors when logging into the admin ports for Joomla. After doing some research, everyone was stating to ensure that you have the session data in the php.ini file to use "files" and also have the path writeable to everyone. Of course, the path also needs to exist! Everything checked out fine there.

Well, after more digging, I discovered that this sessiondata folder was stored on the regular drive of each server and was not in a location that allowed for replication. I then updated the path in the php.ini file and created a new directory that existed within the replication partition. Restarted IIS on both servers after updating the files. Now, I see the session files being created and seconds later, transferred and showing up on the other server. No more "Invalid Session" errors with Joomla.

This is something that many other people may have trouble with as well with some of these big-name web hosters. If the data is not replicated immediately and you jump to another server – POOF! You will get "Invalid Session" from your Joomla administration portal when attempting to login.