Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
JustQyx
@hz_qiuyuanxin
VIP
NO. 2099 / 2012-05-06

[email protected]
DJI
深圳
22 Topics / 614 Replies
12 Followers
46 Following
195 Favorites
教育的目的,不是培养人们适应传统的世界,不是着眼于实用性的知识和技能,而要去唤醒学生的力量,培养他们自我学习的主动性,抽象的归纳力和理解力,以便使他们在目前无法预料的种种未来局势中,自我做出有意义的选择
Reward
GitHub Public Repos
  • affirm-ruby 1

    Ruby client library for integrating with Affirm financing payments

  • elasticsearch-with-ik 1

    Just some packages, not a project

  • gfwlist 1

    The one and only one gfwlist here

  • aliyun-oss-ruby-sdk 0

    Aliyun OSS SDK for Ruby

  • pdf_handler 0

    Replace text in pdf

  • ruby_torna_sdk 0

  • RSSHub 0

    🍰 Everything is RSSible

  • justqyx.github.io 0

  • node-torna-sdk 0

  • haoel.github.io 0

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 多线程使用 Redis gem 时遇到的性能问题 at January 14, 2015

    #3 楼 @holysoros

    As of Ruby 1.9, Ruby uses native threads. Native threads means that each thread created by Ruby is directly mapped to a thread generated at the Operating System level. Every modern programming language implements native threads, so it makes more sense to use native threads. Here are some pros of native threads:

    Pros

    • Run on multiple processors
    • Scheduled by the OS
    • Blocking I/O operations don’t block other threads.

    Even though have native threads in Ruby 1.9, only one thread will be executing at any given time, even if we have multiple cores in our processor. This is because of the GIL (Global Interpreter Lock) or GVL (Global VM Lock) that MRI Ruby (JRuby and Rubinius do not have a GIL, and, as such, have “real” threads) uses. This prevents other threads from being executed if one thread is already being executed by Ruby. But Ruby is smart enough to switch control to other waiting threads if one thread is waiting for some I/O operation to complete.

    如上说的,在 Ruby 1.9 版本以后,I/O 密集型使用多线程是可以的,但是 CPU 密集型的 task,使用多线程就没有用了。 所以我认为,使用多进程来解决 CPU 密集型的任务是更好的方案,Resque 貌似使用的是多进程,而 sidekiq 采用的是多线程。至于是用队列还是直接写,还是怎么样的,根据你的应用的实际情况做相应的策略。

    而你上面指出的 redisrb 这个 gem 的源码,redis server 那边因为是单线程模型运行,所以 redis client 是有可能会被阻塞住的。对于你外面的采用多线程,MRI 本身要进行调度,所以在你这种情况下多线程并没有单线程有优势。

  • 多线程使用 Redis gem 时遇到的性能问题 at January 14, 2015

    Redis is a single-threaded server. It is not designed to benefit from multiple CPU cores. People are supposed to launch several Redis instances to scale out on several cores if needed. It is not really fair to compare one single Redis instance to a multi-threaded data store.

    如上面说的,Redis 以单线程模型运行,不需要考虑并发读写的问题。

  • 又一个文件上传组件 refile at January 06, 2015

    楼主少发了一个十分重要的信息 😄

    Refile is a modern file upload library for Ruby applications. It is simple, yet powerful. Refile is an attempt by CarrierWave's original author to fix the design mistakes and overengineering in CarrierWave.

  • 大格局, 大使命 -- 2014年 度总结 at January 03, 2015

    对于楼主的经历表示赞。

    对于“WEB 开发的走势”这部分的观点表示不赞同,因为没有场景的设定、没有数据说明而下的结论,过于片面。 而且一门工具的存在意义在于它究竟能解决什么样的问题,而判断优秀与否在于在解决同样的一个或一类问题上与其他相同的工具的效率与可维护性等等之间的比较。

  • 抛砖引玉,我的 2014 年度总结 at January 02, 2015

    能否问下楼主毕业参加工作多少年了?

  • Gmail 客户端收不到邮件 at December 29, 2014

    听是听说,但 foxmail 还是照样收得到 😄

  • 我轻断食的经历 at December 22, 2014

    #19 楼 @HungYuHei 同意 19 楼的说法

  • 为什么感觉 Ruby China 里的程序员,基本上是做 Web 的? at December 14, 2014

    我打杂的 😄

  • unicorn 和 puma 该选哪个 at December 11, 2014

    建议在生产环境里使用 unicorn(支持热部署),在开发环境下用 puma 和 thin 都可以

  • sidekiq 发邮件的诡异问题 at December 10, 2014

    这东西确定配置对了?

    ActionMailer::Base.smtp_settings = {
      :address        => "smtp.163.com",
      :port           => 25,
      :domain         => '163.com',
      :user_name      => 'your_user_name',
      :password       => 'your_password',
      :authentication => "plain"
    }
    
  • 對 query 的 data 做 sampling 動作 at December 08, 2014
    select
      date_trunc('minute', timestamp) as timestamp,
      hight,
      low,
      volum,
      count(id) as count
    from your_table
    group by date_trunc('minute', timestamp)
    order by timestamp asc
    
  • 最终还是买了 hhkb at December 01, 2014

    建议再整个大屏幕

  • 关于导入 Excel 文件进度的问题求助 at November 25, 2014

    首先,你的程序是必须去维护进度这么一个数据的。 当开始处理时,你需要知道总共有多少条数据,还要维护一个当前以处理了多少条,这样就能知道进度了。 而你发起 ajax 来获取进度,那么你就需要有个地方来放这么一个进度的信息。

    我建议你把这个信息放到 redis 里面去就好了,自己定义好 key 的规则就可以了。 或者说,你放到其他地方(文件、mysql 等等)都可以,反正就是需要有个地方能让另外一个进程拿到数据就可以了。

  • [已解决] Capistrano 用户验证问题? at November 19, 2014

    https://github.com/capistrano/capistrano/wiki/using-ssh-keys

  • 浏览帖子能不能该改成打开新的标签页啊 at November 19, 2014

    开新的标签页的话,就享受不到 turbolinks 的好处了

  • Rails 的 migration 更改 at November 19, 2014

    1、直接进数据库,用 SQL 代码改那个字段的类型; 2、直接改那个 migration 文件,然后跑一下 rake db:migrate

    这样,你已有的数据库测试的记录还不会丢

  • rubygems 网站更新了 at November 19, 2014

    原来的比较好

  • 决定入手 filco 87 二代 茶轴 at November 17, 2014

    #5 楼 @shangrenzhidao 还好,周边的同事还能习惯,哈哈

  • 决定入手 filco 87 二代 茶轴 at November 17, 2014

    如果是在宿舍自己用,我更喜欢青轴,但在公司就不敢了,买了个茶轴。

  • parallelsdesktop 双十一半价 at November 07, 2014

    已买,但未发货。。

  • 关于 Rails 如何来初始化数据库 at November 06, 2014

    可以把 APP 需要的初始数据,写在 db/seeds.rb 文件里,然后跑 rake db:seed 加载到数据库里面去。

    例如:

    country_list = [
      [ "Germany", 81831000 ],
      [ "France", 65447374 ],
      [ "Belgium", 10839905 ],
      [ "Netherlands", 16680000 ]
    ]
    
    country_list.each do |name, population|
      Country.create( name: name, population: population )
    end
    
  • 多条件查询怎么写语句 at November 04, 2014

    推荐 ransack https://github.com/activerecord-hackery/ransack

  • 求 rack,rackup 的教程资料 at November 04, 2014

    http://guides.ruby-china.org/rails_on_rack.html https://ruby-china.org/topics/15017

  • 请教一个 stale? 方法 at October 30, 2014

    #2 楼 @glz1992 http://guides.rubyonrails.org/index.html 搜索一下 cache

  • Ruby-China 为什么不用 Sunspot 做 fulltext searching 了呢 at October 30, 2014

    ActveRecord + Elasticsearch

  • 请教一个 stale? 方法 at October 30, 2014

    http://guides.rubyonrails.org/caching_with_rails.html#conditional-get-support

  • PostgreSQL 与 MySQL 的性能 at October 29, 2014

    #29 楼 @bobby_chen 建议你去弄清楚为什么慢!这点非常重要,找到了,才好对症下药。

  • PostgreSQL 与 MySQL 的性能 at October 29, 2014

    #22 楼 @bobby_chen

    之所以慢,都是因为这个操作其计算量大的原因。只需要将计算量降下来,或者提前一次性做好这件事情就可以了。

    我给你的建议是,新建一张表,然后你对每一个 game_id 每天生成一条 count(*) 记录,然后存起来就可以了。

  • [已解决] libv8 安装提示说出错,但我明明已经安装上了 at October 29, 2014

    你试试

    1. 删除 therubyracer 这个 gem
    2. 删除 libv8 这个 gem
    3. 删除系统安装的 v8 软件包

    然后

    1. 安装 v8 这个软件包
    2. 安装 libv8 这个 gem
    3. 安装 therubyracer 这个 gem
  • Prev
  • 1
  • 2
  • …
  • 7
  • 8
  • 9
  • 10
  • 11
  • …
  • 19
  • 20
  • Next
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English