<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d4684235500622716427\x26blogName\x3dCaiwangqin\x27s+blog\x26publishMode\x3dPUBLISH_MODE_HOSTED\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://blog.caiwangqin.com/search\x26blogLocale\x3dzh_CN\x26v\x3d2\x26homepageUrl\x3dhttp://blog.caiwangqin.com/\x26vt\x3d3393395200455623441', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Caiwangqin's blog

Focus on Life, Cloud Service, Smart Hardware, Architecture, 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, 05:08

0 Comments:

发表评论

订阅 博文评论 [Atom]

<< 主页