N2CMS性能优化方法集锦

 N2CMS性能优化方法集锦

colindoug  2011-9-30

 

1.在安装完成后,在web.config中设置checkInstallationStatus="false",这样可以减少启动时查询数据库。

2.如果你有自己的权限系统,凡是继承自 Page/Part 类型的类,覆盖IsAuthorized方法,该方法会从数据库查找当前页面的访问权限信息,通过覆盖以替代N2的默认实现,可减少数据库访问。

AbstractPage and AbstractItem usually.

public override bool IsAuthorizedSystem.Security.Principal.IPrincipal user
{
return true;
}

3.避免使用Find.Items.All,或者Find.Items.Where.Filters() 。

4.对数据库使用cache,这是改善性能最重要的一项。这里具体讲讲怎么做:

   (1)确保NHibernate.Caches.SysCache2.dll在bin 目录下;

   (2) 打开web.config,对数据库部分进行修改:确保caching="false" 改成caching="true"


     
       
     

 

 

N2cms社区的libardo提出了以下几种方法:

*.Use the query viewer part available in the sources and try to minimize queries (and use nhprof) .

* .Sometimes using the API isn't optimal, consider changing to nhibernate query with load hints .

*.If you notice listings causing extra queries consider using the [Peristable] attribute to move details into the n2item table .

*.Using parts is slower than "hard coding" into a template .

 

对于访问量很大的网站,比如一天pv在300万以上,这里还介绍两大利器:

其一是动态页面静态化。

其二是在硬件架构上想办法,使用负载均衡网关,将系统部署在多台服务器上。

 

 

你可能感兴趣的:(CMS,N2CMS)