Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# dagda1 12/13/2006 8:31 AM
Hi,

We have just released:

http://www.closerdiets.com which used Cuyahoga.

We found some performance sore points which I would be willing to share when I have recovered.

Cheers

Paul
# martijnb 12/13/2006 2:03 PM
dagda1We have just released:

http://www.closerdiets.com which used Cuyahoga.

Very nice!
We found some performance sore points which I would be willing to share when I have recovered.

You mean, you're still recovering from making the deadline? :)

Anyway, I and probably many more people are very interested in some details of the performance issues. It's a good opportunity to make some improvements. All sites that I've done myself have such a low traffic that I've never met the limits (except at our previous host, but everybody has problems over there).
# dagda1 12/14/2006 11:17 AM
Hi,

Closer for those who do not know is quite a large UK based magazine. Unfortunately they are still using quite low spec servers running on windows 2000 servers.

We got quite a shock when we went from our high spec servers to their archaic ones. One page request was running at 50% cpu. We discovered this not long before the go live date. We then started examining the code.

One strange performance hit we found was in the UrlRewriter class with the following line causing a massive performance hit:

Regex regEx = new Regex(matchExpression, RegexOptions.IgnoreCase|RegexOptions.Singleline|RegexOptions.CultureInvariant|RegexOptions.Compiled);

The RegexOptions.Compiled option was very processor intensive. We have since removed this option from all references to the code.

We also found the module loading to be a very expensive process and added the module classes to the ~/Config/Services.config file and did away with the ModuleAdded event.

We also raised the CacheDuration to be recorded in minutes instead of seconds and duplicated the InvalidateCache and placed it in ModuleBase. We then placed checks for cached content in the Page_Load of each module’s .ascx. This finally gave us a reasonably well performing site.

Each node has about 10 sections with a couple of standalone sections for things like the footer which may have caused the performance issues.

Also the client wanted a better way of creating nodes where by they did not have to re-add new sections and their content for each page they created. We came up with a way of replicating sections from level 1 nodes to their child nodes. We also give them the ability to clone content from existing nodes of the same template.

We created a preview functionality that was based on the cloning capabilities outlined above and an asset manager for uploading and displaying the images.

We also had to employ 2 different authentication schemes. One for Cuyahoga users and one for Closerdiets members. Both used forms authentication and we updated the authentication model to cater for both types of user. I think this is quite a common request and something to maybe bear in mind for future development.

Cheers

Paul


# martijnb 12/14/2006 2:42 PM (edited 12/14/2006 2:44 PM)
Thanks Paul, this is very valuable information.

Btw, you're talking about services.config, so this must be the current SVN version. That's really interesting!
# dagda1 12/15/2006 3:36 AM
The RegexOptions.Compiled is the one that suprised us the most.

It was hitting the cpu bad.

# martijnb 12/15/2006 6:35 AM
dagda1The RegexOptions.Compiled is the one that suprised us the most.

It was hitting the cpu bad.

Yeah, I thought that option is particularly meant to reduce the CPU load. Of course, you get a hit at the first time, but then it should be fast. We'll have a look at it.
# martijnb 12/26/2006 6:24 PM (edited 12/26/2006 6:26 PM)
The UrlRewriter is now changed in SVN.

The problem wasn't really the RegexOptions.Compiled flag, but much more the fact that every request recreated new Regex instances for every rewrite rule. Of course you get an extra hit in this case with RegexOptions.Compiled, but it is not necessary at all to create those regex instances every time.

The reason that you encountered this issue lies in the fact that .NET 2.0 doen't cache regex instances anymore, but only regexes that are called via the static Regex methods. In 1.1 the instances were also cached, so we didn't notice the performance hit then.

Now, the UrlRewriter uses the static methods and it makes a huge difference! Roughly said, a page now loads twice as fast.

Thanks for reporting this one!
# dagda1 1/22/2007 3:53 AM
Hi,

I just wanted to post a follow up to avoid other users having the same problems as us.

Calling the static Regex methods was indeed a great saving. A lot of our problems stemmed from the fact that the client gave us a crappy box running iis 5.0.

Our site (www.closerdiets.com) is a diet site and January being January a lot of people wanted to lose weight. Once the site started getting reasonable high traffic, we experienced some NHibernate 1.0.2.0 errors to do with the Syscache and Castle.Dynamic proxy.

We switched to NHibernate 1.0.3.0 and upgraded to the latest Castle.Dynamic proxy that comes with that release. The thing to bear in mind is that the Castle guys did not upgrade the version number for some reason best known to themselves.

We also found our site performed better if we cached the user controls in minutes rather than seconds. We just added a method to the module base to invalidate the cache.

Closerdiets is quite a busy site and they have a team who perform the updates to the site and a preview was the first thing they asked for. That was the first change to the source we made and I highly recommend you add one to Cuyahoga.

Cuyahoga has really opened my eyes to a different way of developing. I am such a fan of NHibernate and Castle’s ioc. I really loathe to write ADO.NET code now and O/R is great. I really do not think that Microsoft’s DLinq will even come close to NHibernate. I use MSBuilds difficult to use implementation to NAnt’s ease of use. Has anyone seen MSBuilds delete task?? What is that all about?

Thanks for a great architecture that really allowed us to meet a tight schedule to get the site out on time.

Paul
# martijnb 1/22/2007 9:11 AM (edited 1/22/2007 9:24 AM)
Thanks for the update!
We switched to NHibernate 1.0.3.0 and upgraded to the latest Castle.Dynamic proxy that comes with that release. The thing to bear in mind is that the Castle guys did not upgrade the version number for some reason best known to themselves.

I'm very curious: did this entirely solve the SysCache issues?
Closerdiets is quite a busy site and they have a team who perform the updates to the site and a preview was the first thing they asked for. That was the first change to the source we made and I highly recommend you add one to Cuyahoga.

Yes, previewing functionality is on our list for the next generation of the admin interface. Did you add specific previewing functionality for every type of module, or is it generic?
I use MSBuilds difficult to use implementation to NAnt’s ease of use. Has anyone seen MSBuilds delete task?? What is that all about?

You build CloserDiets with MSBuild?
Thanks for a great architecture that really allowed us to meet a tight schedule to get the site out on time.

That's very nice to hear. Now let's hope it keeps working well for a long period. I just browsed the site and it 'feels' very fast now.
# dagda1 1/23/2007 3:01 AM
Hi,
I'm very curious: did this entirely solve the SysCache issues?
.

I'll have to get back to you on that one, I only released the correct version of CastleProxy last Friday, I did not realise the CastleProxy that came with the NHibernate 1.0.3.0 build was a different version. We could only tell we had the correct version by doing a comparison on the file size. It does however mention this in the release, so I guess we were in the wrong. Before then we were getting deadlocks in the code when the site was under high use. We have no access to the box and getting the eventlogs sent to us is steeped in bureaucracy. The site is performing well on a reasonably low spec box. At least now it is anyway.
Yes, previewing functionality is on our list for the next generation of the admin interface. Did you add specific previewing functionality for every type of module, or is it generic?

We wanted to do it genrically but in the end we made every module implement an interface that we used to preview. Also the users were not happy about starting every page and adding the same modules to sections etc. to create a page that looked like other pages. So we changed the code so that the user could select sections from level 1 nodes via the admin tools that would be replicated whenever you created a child node of that level 1 node. That way they could either override it or stick with the inherited content. We also gave them ability to clone nodes from existing nodes. Then they could easily create a page with the same look and feel as the rest and change the content they needed. All this sort of hung together with the same replication interfaces and was not a lot of code to write.
I use MSBuilds difficult to use implementation to NAnt’s ease of use. Has anyone seen MSBuilds delete task?? What is that all about?

We do not use MSBuild but it is on my list of things to do. We use TFS (Team Foundation Server) as our source control so unfortunately we could not use NAnt (easily anyway) to perform builds. I was trying to use the analogy of how hard to use MSBuild is compared to now easy to use NAnt is. I reckon DLinq will be a poor man's NHiberate. let us not forget NHibernate has been round the block. Also anybody who has seen Microsoft's Application block for logging compared to Log4Net will know just what I am talking about. Sorry rant over.

I do think this site has been a good run out for Cuyahoga as it is reasonably high key and we do get high level's of traffic.

Another thing we had to do which I am sure others will come across is that we have a members area where by users pay a fee and can use the members area of the site. So we needed to enhance the authentication scheme to know who was an authenticated user but not a cms user and who was a cms user but not a members user.

Thanks for the quick answers to the queries also.

Paul




# qcdieu 2/22/2007 12:26 AM
dagda1Hi,

We have just released:

http://www.closerdiets.com which used Cuyahoga.

We found some performance sore points which I would be willing to share when I have recovered.

Cheers

Paul

The webpages are very nice !
# gvarela 2/26/2007 4:51 PM
We wanted to do it genrically but in the end we made every module implement an interface that we used to preview. Also the users were not happy about starting every page and adding the same modules to sections etc. to create a page that looked like other pages. So we changed the code so that the user could select sections from level 1 nodes via the admin tools that would be replicated whenever you created a child node of that level 1 node. That way they could either override it or stick with the inherited content. We also gave them ability to clone nodes from existing nodes. Then they could easily create a page with the same look and feel as the rest and change the content they needed. All this sort of hung together with the same replication interfaces and was not a lot of code to write.

I would be very interested to see how this was accomplished and if this could be added to the admin permanently. I think alot of people could benefit from this feature.
# dagda1 2/28/2007 2:52 AM
Hi,

I'll give you a quick run through, if you want to know more then let me know:

Basically every node that can synchronise implements this interface
public interface ISynchronisable
{
    void Synchronise(Section updateSection, IContent content);
    void SynchroniseSection(Section newSection);
}

Our IContent interface is simply a marker interface to tag content and not as defined as the one on svn:
public interface IContent
{
    int Id { get; set; }
}

Then each module implements it's own concrete implementation:

Then in the BaseModule we had:
        protected virtual void SynchroniseContent(IContent content)
        {
            if ((!(this is ISynchronisable)) || (Section.Node == null) || (!Section.Node.CanSynchronise) || (!Section.Synchronised) || (Section.Node.ChildNodes.Count == 0))
                return;
            foreach (Node childNode in Section.Node.ChildNodes)
            {
                if (childNode.ShowInNavigation)
                {
                    Section updateSection = childNode.GetSectionByModuleAndTitle(Section);
                    if (updateSection != null)
                        ((ISynchronisable)this).Synchronise(updateSection, content);
                }
                if (childNode.ChildNodes.Count > 0)
                    SynchroniseChildNodes(childNode.ChildNodes, content);
            }
        }

        protected virtual void SynchroniseChildNodes(IList childNodes, IContent content)
        {
            if (!(this is ISynchronisable))
                return;
            foreach (Node childNode in childNodes)
            {
                if (childNode.ShowInNavigation)
                {
                    Section updateSection = childNode.GetSectionByModuleAndTitle(Section);
                    if (updateSection != null)
                        ((ISynchronisable)this).Synchronise(updateSection, content);
                }
                if (childNode.ChildNodes.Count > 0)
                    SynchroniseChildNodes(childNode.ChildNodes, content);
            }
        }

Then whenever content is saved in a module it calls the base method passing in the new content like so:
SynchroniseContent(content);
and it replciates to all child nodes

We had to add the if(childNode.ShowInNavigation) conditional statement because the Closerdiets site has grown to such a size that an update to a section was causing SqlTimeOuts!! This was our best way round it.

As far as cloning nodes goes, we made node, section and any content that needs to be copied impliment IClonable to return a deep copy.

The user picks the node they want to clone from a modable window that is displayed when the user is in the NodeEdit.aspx page.

Then the following code runs:
[Transaction(TransactionMode.RequiresNew)]
public Node CloneNode(Node parentNode, Node nodeToClone, string newNodeTitle)
{
    Node clonedNode = (Node)nodeToClone.Clone();
    IList rootNodes = _nodeService.GetRootNodes(clonedNode.Site);
    clonedNode.ParentNode = parentNode;
    clonedNode.CalculateNewPosition(rootNodes);
    clonedNode.Title = newNodeTitle;
    clonedNode.CreateShortDescription();
    parentNode.ChildNodes.Add(nodeToClone);
    _nodeService.SaveNode(clonedNode);
    foreach (Section sectionToClone in nodeToClone.Sections)
    {
        ModuleBase module = _moduleLoader.GetModuleFromSection(sectionToClone);
        if (!(module is ISynchronisable))
            continue;
        Section clonedSection = (Section)sectionToClone.Clone();
        clonedSection.Node = clonedNode;
        clonedSection.CopyRolesFromNode();
        clonedSection.Node.Sections.Add(clonedSection);
        _sectionService.SaveSection(clonedSection);
        ((ISynchronisable)module).SynchroniseSection(clonedSection);
    }
    return clonedNode;
}

The preview facility worked something like this were we created a new node each time but it was in fact what we called a versioned node which was an NHibernate joined-subclass to stop it coming back in the normal list of nodes.

I am definitely not saying this is the best way of doing things but just how we got the project out.

I hope it gives people some thoughts about how to achieve things better and if you need to know more then let me know.

Paul


# dagda1 2/28/2007 5:42 AM
I just noticed this is wrong:
Basically every node that can synchronise

What I meant to say is every module.