<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>happyming9527 (志明)</title>
    <link>https://ruby-china.org/happyming9527</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>Passenger 切换成 Puma 之后，流量图出现了一些奇怪的变化</title>
      <description>&lt;p&gt;我用的一直是亚马逊的 ec2，昨天，我把我正式站 rails 应用，由 passenger 改成了 puma。在日活没有多少变化的情况下，负载均衡网卡的流量图发生了显著的变化。我不明白为啥 incoming 流量会比昨天高很多，也比 outgoing 的流量高很多。请问这跟我切换成 puma 有什么关系？&lt;/p&gt;

&lt;p&gt;2018-05-05 的流量
&lt;img src="https://l.ruby-china.com/photo/2018/41cf855d-8188-4d45-a250-76833b1f089b.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;2018-05-06 的流量
&lt;img src="https://l.ruby-china.com/photo/2018/62ba1d77-3aa9-4f15-9f16-7ec4021f42cb.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;我是在 15:20 切换成 puma 的。可以说流量图立竿见影发生了变化。求教社区各位大神，这变化是好的么？
客户端对网络请求有超时重试的机制。难道是用 puma 之后，很多请求被放到队列里面。没有及时返回，造成客户端重发请求么？&lt;/p&gt;</description>
      <author>happyming9527</author>
      <pubDate>Mon, 07 May 2018 10:13:24 +0800</pubDate>
      <link>https://ruby-china.org/topics/36709</link>
      <guid>https://ruby-china.org/topics/36709</guid>
    </item>
    <item>
      <title>MySQL 提交 commit sql 执行特别慢，求助</title>
      <description>&lt;p&gt;rails 4.2.6 开发的项目。以前没有发现，很多 sql 语句，提交极其的慢。但单条执行的语句是非常快，仅仅是 commit 提交的慢。这个会是什么原因，请各位大佬指教一下。&lt;/p&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2017/dcf46014-f5aa-466f-ae9e-2dc8b6cb5752.png!large" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>happyming9527</author>
      <pubDate>Fri, 10 Nov 2017 10:42:42 +0800</pubDate>
      <link>https://ruby-china.org/topics/34548</link>
      <guid>https://ruby-china.org/topics/34548</guid>
    </item>
    <item>
      <title>请问 CDN 来的图片，是通过哪个 header 来缓存的？</title>
      <description>&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2017/272b4ee7-357e-4dea-95ad-5baab8b04c21.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;如上图，图片的地址是 cdn 的地址，response 中没有 expires，cache-control 这样的控制缓存的字段。
请问浏览器为啥会从 disk cache 中读取缓存？&lt;/p&gt;</description>
      <author>happyming9527</author>
      <pubDate>Sat, 21 Oct 2017 11:06:09 +0800</pubDate>
      <link>https://ruby-china.org/topics/34414</link>
      <guid>https://ruby-china.org/topics/34414</guid>
    </item>
    <item>
      <title>rails 的 cookie store session 只能靠浏览器控制是否过期么？</title>
      <description>&lt;p&gt;当 rails 设置了用 cookie store 存储 session。也设置了 expire_after。这样在浏览器上可以看到 cookie 有一个过期时间。可是如果黑客能拿到这个 cookie，那是不是不管这个时间是否已经过了，服务器都没法判断，这个 session 是否是过期的呢？难道 rails 的 cookie store session 只是靠浏览器的 cookie 的 expires 时间来控制的？&lt;/p&gt;</description>
      <author>happyming9527</author>
      <pubDate>Wed, 07 Dec 2016 22:08:04 +0800</pubDate>
      <link>https://ruby-china.org/topics/31838</link>
      <guid>https://ruby-china.org/topics/31838</guid>
    </item>
    <item>
      <title>请问 Ruby 语言里面有弱引用的结构么？</title>
      <description>&lt;p&gt;es6 的里面，增加了 weakmap，weakset 这些弱引用的类型，可以直接被垃圾回收。请问 ruby 语言有这样的实现么？&lt;/p&gt;</description>
      <author>happyming9527</author>
      <pubDate>Wed, 07 Dec 2016 10:57:57 +0800</pubDate>
      <link>https://ruby-china.org/topics/31821</link>
      <guid>https://ruby-china.org/topics/31821</guid>
    </item>
    <item>
      <title>SSL 证书，二级域名，三级域名都想用，需要购买哪种证书？</title>
      <description>&lt;p&gt;做了个网站，买了个 rapidSsl 的 wildcard 的证书。但是发现二级域名可以通用同一个证书，但是三级域名不能通用。但是我的需求是二级域名和三级域名都需要 ssl 证书。各位大神，我需要购买什么类型的证书，是 multi-domain 的证书么？但是看到说域名个数只能有四五个，我是多台服务器。证书可能存放到不同服务器。而且对 multi-domain 的证书的生成过程不太了解。是否需要提前确定需要设置哪些域名，才能生成 multi-domain 的证书？如果我中间，又想加入别的域名，是不是这个证书就不能用了？&lt;/p&gt;</description>
      <author>happyming9527</author>
      <pubDate>Mon, 05 Dec 2016 12:45:50 +0800</pubDate>
      <link>https://ruby-china.org/topics/31801</link>
      <guid>https://ruby-china.org/topics/31801</guid>
    </item>
    <item>
      <title>Rails 多线程的坑，请问怎么破?</title>
      <description>&lt;p&gt;写了段多线程的同步数据的 rake 任务。但是启动的时候，不定时的会报错，之前写单线程的时候是没啥问题的，改成多线程就出问题了。&lt;/p&gt;

&lt;p&gt;代码如下：&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="ss"&gt;:move_user&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:environment&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="no"&gt;TempSettings&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;MOVE_KIND&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'batch'&lt;/span&gt;

  &lt;span class="n"&gt;tread_num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
  &lt;span class="n"&gt;last_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;with_phone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;last&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;
  &lt;span class="n"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;last_id&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;tread_num&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="n"&gt;tread_num&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="no"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"开始thread &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; 同步用户------------------"&lt;/span&gt;
      &lt;span class="n"&gt;relation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;with_phone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'id &amp;gt; ? and id &amp;lt;= ?'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
      &lt;span class="n"&gt;relation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_in_batches&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;group&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
        &lt;span class="n"&gt;group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
          &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;async_self&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="ss"&gt;:join&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="n"&gt;tread_num&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="no"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"开始thread &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; 同步用户其他信息------------------"&lt;/span&gt;
      &lt;span class="n"&gt;relation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;with_phone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'id &amp;gt; ? and id &amp;lt;= ?'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
      &lt;span class="n"&gt;relation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_in_batches&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;group&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
        &lt;span class="n"&gt;group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
          &lt;span class="k"&gt;next&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dm_user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_success?&lt;/span&gt;
          &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;async_other&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;

      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="ss"&gt;:join&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;报错如下：&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="no"&gt;Circular&lt;/span&gt; &lt;span class="n"&gt;dependency&lt;/span&gt; &lt;span class="n"&gt;detected&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;autoloading&lt;/span&gt; &lt;span class="n"&gt;constant&lt;/span&gt; &lt;span class="no"&gt;UserKid&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;RAILS_ENV=production 这样的参数也设置过，甚至还加过  config.allow_concurrency = false
这样的设置，但是还是时好时坏，请问怎么破？&lt;/p&gt;</description>
      <author>happyming9527</author>
      <pubDate>Thu, 25 Aug 2016 17:40:25 +0800</pubDate>
      <link>https://ruby-china.org/topics/30906</link>
      <guid>https://ruby-china.org/topics/30906</guid>
    </item>
    <item>
      <title>Rails 怎么做数据库分库的?</title>
      <description>&lt;p&gt;最近接了个活，后端得做高负载的处理，我想要分库处理。论坛里有朋友后端数据库是多个的么？你们是如何做夸库的事务处理的呢？貌似 rails 是不支持两阶段提交的。请问大家有什么好方案呢？&lt;/p&gt;</description>
      <author>happyming9527</author>
      <pubDate>Wed, 17 Aug 2016 10:47:05 +0800</pubDate>
      <link>https://ruby-china.org/topics/30833</link>
      <guid>https://ruby-china.org/topics/30833</guid>
    </item>
    <item>
      <title>用云服务器存储视频，如何获得视频截图？</title>
      <description>&lt;p&gt;以前做过的好几个项目都涉及到用户上传的视频。但是给用户展现视频前，需要一张视频的缩略图。以前都是在服务器上用 ffmpeg 截图。但是挺占用服务器资源的。后来用了阿里云的 oss，图片倒是可以自动剪裁。但是视频这类服务没有发现截图的服务，各位兄弟姐妹关于这块视频的功能都是怎么处理的？&lt;/p&gt;</description>
      <author>happyming9527</author>
      <pubDate>Sat, 13 Feb 2016 10:18:31 +0800</pubDate>
      <link>https://ruby-china.org/topics/28975</link>
      <guid>https://ruby-china.org/topics/28975</guid>
    </item>
    <item>
      <title>有人用过阿里云的键值存储 KVStore 么？</title>
      <description>&lt;p&gt;我看到阿里云的介绍上说阿里云的键值存储 KVStore 支持 redis 协议，但是也没有 ruby 的实例代码。请问社区里有人用过这个服务么？如果用过，速度怎么样？拿来做 rails 的缓存服务器如何啊？&lt;/p&gt;</description>
      <author>happyming9527</author>
      <pubDate>Sat, 07 Nov 2015 23:00:34 +0800</pubDate>
      <link>https://ruby-china.org/topics/27987</link>
      <guid>https://ruby-china.org/topics/27987</guid>
    </item>
  </channel>
</rss>
