N2CMS性能优化方法集锦

2 篇文章 0 订阅

 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"

<database connectionStringName="N2CMS" flavour="AutoDetect" caching="true" cacheProviderClass="NHibernate.Caches.SysCache2.SysCacheProvider, NHibernate.Caches.SysCache2">
      <hibernateProperties>
        <add name="hbm2ddl.keywords" value="none"/>
      </hibernateProperties>
</database> 

 

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万以上,这里还介绍两大利器:

其一是动态页面静态化。

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

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值