<body>

Caiwangqin's blog

Focus on Web2.0, Business, Architecture, Agile, Technic and beyond…

Improve rails performance for P1.cn

2008年4月2日 星期三

最近由于 P1.cn 业务的推广,我们的 rails application 在以下几个方面遇到考验,分享一下我们处理这个问题的方法。


1. rails performance


这方面的问题我们以从以下几个方面处理:




  1. rails 的相关 plugin 性能及差,如 acts_commentable ,去掉这类的 plugin

  2. 改变数据库结构,使部分数据冗余,如 nickname, 使数据库关联查询变少

  3. memcached: cache db query in memcached, use acts_as_cached, cached_model, QueryCache (like javaeye)

  4. action cache: action cache 所有show action

  5. fragment cache: 少部分 privacy 页面使用


2. db cluster

master/slave mysql database, 现在是 one master, one slave, 计划结合 MySQL Proxy 做 one master , multiple slave


3. distributed file storage


用户图片增长速度非常快,我们感觉到了 storage 的压力,这是个即将到来的问题,但我不确定使用哪种方式来分布文件存储,我了解以下几种方式,但没有应用经验:



  1. NFS (大部分人不建议使用)

  2. DRBD - raid 1, 没有使用经验

  3. mogile fs - 文档几乎没有

  4. SAN


4. Nginx + mongrel cluster or something else


我们现在使用的是 Nginx + mongrel cluster , 发现 mongrel 在处理时,如果发生了一次异常,后续的请求都会被阻塞。以下是我们的处理方式:



  1. Swiftiply event mongrel instead of mongrel

  2. more mongrel running on different servers


希望得到你更多的建议,谢谢。


标签:

posted by Caiwangqin, 上午5:08

<< 主页