TimeBasedSyncHandler

I recently had to tweak my remote persistence server settings. I noticed that I had leaft the SyncHandler.HistoryLength at the default value of 10,000 items. This was overkill because my clients sync every 3 seconds. I thought maybe I should drop this down to about 100, that should be okay? Each client only does about one update every few minutes so I it should, right?

Problem is not all of my users are people. One user is a messenger service which looks for unsent messages, sends them one at a time, marking each in turn as sent and updating the database. This gets run every five minutes so probably sends about fifty messages at the most, but what if someone decides to change it to ten minutes, or thirty? So maybe I should increase the HistoryLength to about 200?

Then there is the other client, this one syncs with an external database. This could perform hundreds of updates every minute. If the messenger is set to run every thirty minutes...I'm not sure what a good HistoryLength would be! If I set it too low I fill it up quickly and my clients will have to deactivate/reactivate their EcoSpace instances. If I set it too high I might use up too much memory, especially if the messenger runs infrequently and the history gets filled up with "human" client updates which are much larger.

So, I wrote my own SyncHandler. This one accepts a TimeSpan property, which by default is five minutes but on my server I dropped it to two minutes (forty times longer than my clients' sync intervals.) The idea is that I keep changes for the specified period of time no matter how irregularly the updates occur. This way the server uses more memory during heavy usage but

A: Usage drops during lower activity, in fact it goes right down if there are no updates for the specified TimeSpan.
B: It wont run out of history length too quickly for the client.

If you'd like to try it for yourself take a look here.

Comments

Popular posts from this blog

Connascence

Convert absolute path to relative path

Printing bitmaps using CPCL