Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
李华顺
@huacnlee
Admin
NO. 2 / 2011-10-28

[email protected]
长桥证券 (Longbridge)
成都
502 Topics / 9058 Replies
959 Followers
53 Following
105 Favorites
Reward
GitHub Public Repos
  • autocorrect 1410

    A linter and formatter to help you to improve copywriting, correct spaces, words, and punctuation...

  • rails-settings-cached 1101

    Global settings for your Rails application.

  • rucaptcha 696

    Captcha Gem for Rails, which generates captcha image by Rust.

  • zed-theme-macos-classic 95

    A macOS native style theme for Zed, let it same like native app in macOS.

  • vscode-macos-classic.t... 21

    macOS Classic theme for Visual Studio Code

  • zed-extension-action 19

    GitHub Action for automatically bump Zed Extensions version after a release.

  • autocorrect-action 11

    GitHub action for use AutoCorrect as lint

  • zed-autocorrect 6

    AutoCorrect for Zed

  • gpui-workspace 4

    Dock layout UI component for GPUI, that extracted from Zed project.

  • zed-lalrpop 3

    LALRPOP parser grammar support for Zed.

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 记录一次排查 Puma 内存占用过高的问题 at March 14, 2018

    不是啊 我验证的结果确实是每次调用 GC.start 内存一定能回收降低到 79M 的。

    多进程下你调用 GET /gc 回收的只是其中一个进程。

  • 记录一次排查 Puma 内存占用过高的问题 at March 14, 2018

    你用 Linux 试试,我刚才又在 macOS 上验证了一下

    GET /gc (GC.start)不会释放,内存还是 GET / 后的样子,单线程 100M 的场景,最后固定在 473MB

  • 记录一次排查 Puma 内存占用过高的问题 at March 14, 2018

    我刚才调整了一下配置,Puma 单线程跑,每次请求 100m 内存

    环境:

    • Docker 内的 Ubuntu 14.04 64bit
    • Ruby 2.5, Rails 5.2.0.rc1, Puma 3.11.3
    • 无任何 Ruby GC 配置
    • 最简单的 Controller
    class WelcomeController < ApplicationController
      # GET /
      def index
        foo = '0' * 1024 * 1024 * 100
        memory = `ps -o rss= -p #{$$}`.to_i
        render plain: "hello, #{memory / 1024}MB\n #{GC.stat} \n"
      end
    
      # GET /gc
      # 手动调用 GC.start
      def gc
        GC.start
        memory = `ps -o rss= -p #{$$}`.to_i
        render plain: "hello, #{memory / 1024}MB\n #{GC.stat} \n"
      end
    end
    

    单线程测试

    Puma starting in single mode...
    * Version 3.11.3 (ruby 2.5.0-p0), codename: Love Song
    * Min threads: 1, max threads: 1
    * Environment: production
    * Daemonizing...
    

    并发跑下去,最后稳定在 279M

    /gc 里面有个手动的 GC.start

    $ siege -c 100 http://localhost:3000/
    $ curl http://localhost:3000/
    hello, 279M
    $ curl http://localhost:3000/
    hello, 178MB
    $ curl http://localhost:3000/gc
    hello, 78MB
    $  curl http://localhost:3000/
    hello, 178MB
    $ curl http://localhost:3000/gc
    hello, 78MB
    

    调整为 5 个 threads

    Puma starting in single mode...
    * Version 3.11.3 (ruby 2.5.0-p0), codename: Love Song
    * Min threads: 5, max threads: 5
    * Environment: production
    * Daemonizing...
    

    结果:

    $ curl http://localhost:3000/
    hello, 783MB
    $ curl http://localhost:3000/gc
    hello, 78MB
    $ curl http://localhost:3000/
    hello, 178MB
    $ curl http://localhost:3000/
    hello, 279MB
    $ curl http://localhost:3000/
    hello, 178MB
    $ curl http://localhost:3000/gc
    hello, 78MB
    

    以上测试说明,这是能正确回收的

  • 关于 RoR 内存问题的讨论 at March 14, 2018

    引入一些相关的讨论,Sidekiq 的作者的分析:

    https://github.com/puma/puma/issues/1047#issuecomment-257904428

  • 记录一次排查 Puma 内存占用过高的问题 at March 14, 2018

    做了个例子,在 Linux 上 Rails 5.2,Ruby 2.5, Puma 以及 production 环境。

    配置:

    • Ubuntu
    • Rails 5.2 + Ruby 2.5 + production env
    • Puma 3.11 + 1 worker, 5 threads

    结果

    并发 (10 并) 用工具跑一段时间观察内存

    • 每次 100M,最后内存稳定在 560M 左右,不会变动
    • 每次 10M,最后内存稳定在 300M 左右
    • 什么都不做,最后内存稳定在 80M,无论跑多久
  • 记录一次排查 Puma 内存占用过高的问题 at March 14, 2018

    我来实际试试,确实是之前的应用没有发现这样的情况,一些跑了好几个月的应用,内存最终都是稳定在一个位置的。

  • 新增 “打赏” 功能 at March 14, 2018

    已修复,未发布

  • 记录一次排查 Puma 内存占用过高的问题 at March 14, 2018

    你一个接口要消耗 100M 内存?做了什么事情,载入大文件么?

    GC 的机制,你请求结束以后,内存是不会立刻释放的,要等 GC 触发。如果 GC 触发以后还没回收,那就是可能有内存泄漏。

  • Rails App 有地方配置软件的版本吗,还是要自己写一个类来实现? at March 14, 2018

    http://github.com/huacnlee/rails-settings-cached

  • Devise 提交验证不错,不知这是哪个 Gem 搞的鬼 at March 14, 2018

    教你一个调试方法:

    $ bundle open devise
    

    在编辑器里面找到 app/controllers/devise/registrations_controller.rb

    def create
      # 末尾增加 puts 将 resource 打印出来,就能看到错误信息了
      puts resource.inspect
    end
    

    或者你可以用 rails g devise:views 命令,生成出 Devise 的 views,并修改 devise/registrations/new.html.erb

    <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
      <% if resource.errors.any? %>
      <ul>
        <% resource.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
      </ul>
      <% end %>
    
  • Ruby China iOS 客户端发布 2.2.0 at March 13, 2018

    重新登录一次,评论和客户端的 Session 不一定是同步的,协调可能存在问题

  • 使用 Rails 开发 API 引用,如何去掉 Rails 默认页面 at March 12, 2018

    那个默认页面?

    你把 root_to 指向一个 API 不就可以了 或者删除 public/index.html

  • 你也可以实现的 React 小插件 at March 09, 2018

    颇有朋友圈风格的标题

  • Puma 的线程数量与数据库连接池的关系 at March 08, 2018

    ... 标题里面有个看不见的字符 <BS> 结果导致编辑的时候,浏览器 Input 组件 Bug 了,看不到 input 输入的内容

  • 服务器负载过高怎样优化? at March 07, 2018

    一言不合就换语言的态度,哪怕用来 Go 改写结果也一样

    先要分析好资源耗费在哪里


    你 3 台,撑 1 亿多动态请求/天(约 1000 QPS,或者更高峰值),已经很不错了!

  • 如何调整已经创建的 model 的 column 的顺序 at March 06, 2018

    http://ruby-journal.com/how-to-add-new-column-after-existing-column-with-mysql-in-rails/


    貌似已经去掉这个功能了,API 里面没有看到 http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_column

  • 虽然我很菜,但也尝试去写了一个 gem at March 06, 2018

    多写写就成为老鸟了

  • [深圳] DJI 大疆创新招聘 Ruby 工程师 (saberma 内推 15-40k) at March 02, 2018

    年底有机会获得奔驰宝马福利车,我入职的时候觉得这个离我有点远,更像是公司招聘的一个“噱头”,没想到公司真的奖了我一台宝马; 🚗 🙏

    666

  • Windows 服务器上安装 Redmine Plugins 问题 at March 01, 2018

    Plugin 版本不支持很正常,你用的 Redmine 还是老版本

    你需要检查 redmine_checklists 这个插件

    不懂 Ruby 可以尝试用 Docker 安装 Redmine,避免各种环境的问题

  • 如何在任何 model 中获取 Devise 的 current_user 信息? at February 26, 2018

    Fetch current user in models:

    https://rails-bestpractices.com/posts/2010/08/23/fetch-current-user-in-models

  • 用几个 uploader? at February 21, 2018

    马上就要用 Active Storage 了,可以先看看新的方式

    http://edgeguides.rubyonrails.org/active_storage_overview.html

  • Ruby 和 Ruby on Rails 在 2017年 还有前途吗? at February 21, 2018

    关联 https://ruby-china.org/topics/35050

  • 分析 2017 年的 RubyGems 统计数据 at February 21, 2018

    关联之前关于 Ruby、Rails 流行度的讨论,上图 Rails 今年的下载量说明了一切。

  • DHH: 2017 年 Rails 框架还值得学习吗? at February 21, 2018

    关联 https://ruby-china.org/topics/35050

  • Ruby 现在是不是很尴尬 at February 21, 2018

    https://ruby-china.org/topics/35050

  • JIT for MRI 开始开发了 at February 09, 2018

    怎么我看的对比数据,说的是目前提升还不是很明显呢

  • 城市级联选择还有什么好的 Gem 吗? at February 07, 2018

    看错了,这个是有的 https://github.com/saberma/china_city

  • 城市级联选择还有什么好的 Gem 吗? at February 07, 2018

    注意,那个 area.json 需要把台湾补上,不然会有问题,网监会找你麻烦

  • minimagick 支持写文字到图片上去么? at February 07, 2018

    mini_magick 和 rmagick 的区别是,前者依靠 fork 来外部执行 ImageMagick,后者是引入 ImageMagick 实现 C 扩展,在 Ruby 内部调用。

    前者执行效率低,后者容易内存泄露

    字体之类的搜索 ImageMagick 的相关解决方法,都是一样的

  • 有考虑使用 Sinatra + ActiveRecord 替换你的 Rails 项目吗 at February 07, 2018

    回帖加精

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