Tuesday, March 08, 2005

Creating scalable applications using the CmsApplicationContext By Stefan Goßner

Stefan Goßner has written a great article on Creating scalable applications using the CmsApplicationContext. I thought of doing a small testing on that (I was not very much happy of System.GC.Collect(); which I found in his code). So I've created three windows applications :

1. Same one which is given by Stefan with GC
2. Without GC
3. Another Application which uses the same CmsApplicationContext throughout its process and Dispose is called when it finishes its work (Without GC call).

I did the testing on four different machines which has different MCMS servers. I did two things.. Checked the memory usage as well as time taken(even though it is not important in Stefan's context) to run the application. The results are given bellow.

Results

Application-------Runs*--------Memory(kb)--------Time(s)
1--------------------1--------------12248----------------3.90
1--------------------2--------------588------------------1.34
1--------------------3--------------552------------------1.42
1--------------------4--------------504------------------1.52
2--------------------1--------------12668----------------3.50
2--------------------2--------------692------------------0.59
2--------------------3--------------596------------------0.58
2--------------------4--------------612------------------0.58
3--------------------1--------------12920----------------2.63
3--------------------2--------------644------------------1.47
3--------------------3--------------264------------------1.41
3--------------------4--------------284------------------1.44

* - Ran the same application without restarting (But the CMSA.Context was disposed at least after each and every run).

From this I felt that, better if we don't use GC. If the application is going for a long run and as Stefan said if we only care about memory then the good choice may be the first one. But if we think about the memory and time then the best choice seems to be the 2nd one.

Another important think I noticed is that in the 3rd application, it took less time on the first run and also after one or two runs it took very less memory than any other which I couldn't understand the reason!

N.B:
3rd Application Code :

static private void CollectChannel(CmsApplicationContext cmsContext)
{
while (StackItemsChannel.Count > 0)
{
string channelGuid = (string)StackItemsChannel.Pop();
Channel channel = cmsContext.Searches.GetByGuid(channelGuid) as Channel;
foreach (Posting po in channel.Postings)
{
//do something with posting
}
foreach (Channel ch in channel.Channels)
{
StackItemsChannel.Push(ch.Guid);
}
}
}

private static Stack StackItemsChannel = new Stack();

[STAThread]
static void Main(string[] args)
{
CmsApplicationContext cmsContext = new CmsApplicationContext();
cmsContext.AuthenticateAsCurrentUser(PublishingMode.Unpublished);
string channelGuid = cmsContext.RootChannel.Guid;
StackItemsChannel.Push(channelGuid);
CollectChannel(cmsContext);
cmsContext.Dispose();
}

0 Comments:

Post a Comment

<< Home