Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
aikko
@aikko
Member
NO. 6560 / 2013-04-07

yy
广州
3 Topics / 55 Replies
3 Followers
0 Following
0 Favorites
GitHub Public Repos
  • stratum-mining 1

    AIO Stratum mining server for POS, POW, sha256, scrypt, and scrypt jane coins

  • robbin_site 1

    robbin's website

  • jekyll-wardrobe 1

  • f2pool_monitor 1

    f2pool.com idle worker monitor

  • nginx-init-ubuntu 0

    Tried and true Nginx init script - got enhancements? Send a pull!

  • php-mpos 0

    MPOS stands for Mining Frontend Open Source. A unified mining interface for various Scrypt and SH...

  • iwakuang-web 0

    爱挖矿首页

  • bootstrappers 0

    Bootstrappers is the base Rails application using Bootstrap template and other goodies.

  • igetui-ruby 0

    个推 ruby sdk

  • weiciyuan 0

    Sina Weibo Android Client

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #27 楼 @Rei 恩,主要还是 render 太耗 cpu,我想是否可以尽量降低 render 的数量来降低一些 cpu 的使用。

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #28 楼 @xhj6 这个问题我后面加上 counter cache 应该可以解决,整个访问的 active record 的耗时会降下来,可是 render 的耗时还是比较难降下来,而且非常耗 cpu,内存,io 都不是瓶颈,主要是 cpu。

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #29 楼 @nihaokid 这个方法不错,我试一下

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #25 楼 @luikore 这个我原来的想法是意义不大了,不过我尝试下,测试下提升了多大的空间

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #22 楼 @luikore 主要是获取最近的 5 条,所以这些部分不能直接缓存了,不过@Rei 的方法,我研究下。

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #21 楼 @Rei 多谢,我研究下

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #18 楼 @hooopo 恩,是的,正逐步加上 counter cache,本来想着我已经在很多地方用到了 cache,所以就不会去数据库读,我理解错了。 def wooers Rails.cache.fetch("show_#{self.id}_wooers_#{self.updated_at}", expires_in: 1.hour) do self.original_wooers end end

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #13 楼 @ywjno 会取出这个 post 的所有 comments 然后去后面 5 条,这是个问题

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #14 楼 @luikore 这个地方不会的,对于 N+1 问题不大,因为用了 @hooopo 大神的 https://github.com/csdn-dev/second_level_cache

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #10 楼 @aikko 目前的压力还是没有问题的,我部署了 2 台机,一样的配置,可以抗住 400 reqs/s 的访问,不过很快就会抗不住了,所以再找优化方案。

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #9 楼 @zj0713001 这个里面干的事情看我 5 楼的回复

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #7 楼 @Rei

    <div class="comments" >
          <ul id="comments_<%=post.id%>">
            <% post.comments.last(5).each_with_index do |comment,index| %>
                <li>
                  <span datetime="<%= comment.created_at %>" class="time"></span>
                  <span class="num"><%= floor_num(post.comments.count,5, index) %>.</span>
                  <p><strong><%= comment.user.nickname %>:</strong> <%= comment.content %></p>
                </li>
            <% end %>
          </ul>
        </div>
    

    其实空间也不大,时间用的就是 timeago,评论显示最近 5 条,所以不能整理都 cache 住,

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #3 楼 @Rei cache 我尽量做了了,由于动态数据,不好 cache

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #2 楼 @luikore Read fragment views/user_28274_medals (0.5ms) Rendered shared/_medals.html.erb (1.5ms) Rendered shows/_user.html.erb (46.8ms) Rendered shows/show/_operate.html.erb (1.7ms) Rendered posts/_zhan.html.erb (3.9ms) Read fragment views/post_82397_comments (0.7ms) (9.9ms) SELECT COUNT(*) FROM comments WHERE comments.post_id = 82397 Rendered shows/_comments.html.erb (377.2ms) Rendered shows/_first_floor.html.erb (453.8ms)

    上面的加起来就是它啦,Rendered shows/_comments.html.erb (377.2ms) 这个耗时比较久。不过其实也就 10 条以内,因为分页了。

  • 如何降低页面 render 时的耗时以及 CPU 资源 at June 26, 2013

    #1 楼 @Levan 是生产环境

  • 一个 utf-16 的 byte array 怎么转换成 string? at June 26, 2013

    #4 楼 @Saito 多谢,测试可行,但中文会乱码

  • 一个 utf-16 的 byte array 怎么转换成 string? at June 25, 2013

    #1 楼 不知是否有其他办法~请教 @robbin @luikore

  • 一个 utf-16 的 byte array 怎么转换成 string? at June 25, 2013

    #1 楼 @luikore undefined method `force_encoding' for #Array:0x2584830 这样不行,我最后通过把这个 byte array 写到一个文件里面再读出来。

    f = File.open("tmp.txt", "wb") do |output| result.each do | byte | output.print byte.chr end end

    fd = File.open("tmp.txt", "rb:UTF-16LE") while line = fd.gets line = line.encode("UTF-8") puts line end

    其中 result 即我获得的 byte_array

  • 项目中用了 active_admin 后怎么样彻底去掉它 at June 09, 2013

    我自己觉得 active_admin 比 rails_admin 好用,可配置性强,另外也好看些~

  • 求职:Ruby 新手求带走 at June 08, 2013

    简历不错,嘿嘿,时间线的确反过来更好

  • 关于 jQuery file upload 多文件上传 at June 08, 2013

    #2 楼 @raymondos 单独一个 action 或者 controller 都可

  • 关于 jQuery file upload 多文件上传 at June 08, 2013

    #2 楼 @raymondos 使用 jquery file upload 多文件上传一般应该都是异步上传后,返回地址,之后再作为 form 表单内容提交即可。

  • 有关 ruby 进程的内存性能优化 at June 08, 2013

    #3 楼 @iamroody 我用 rails 做了一个项目,现在是 cpu 是瓶颈,2,3 百 reqs/s 的访问后,cpu 基本是 80% 左右了。(ngnix +passenger+redis+mysql(ssd))

  • 关于 jQuery file upload 多文件上传 at June 08, 2013

    其实这个地方我不建议和 active_view 搅到一起,单独是去实现更简洁明了

  • Prev
  • 1
  • 2
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English