1、在 Rancher 中,克隆已经存在的 Docker 容器 channel-pub-api-prev 为 channel-pub-api-prev-1、channel-pub-api-prev-2,如图1

图1

2、最终 3 个容器组成了一个集群,如图2

图2

3、在负载均衡中,添加服务规则,设置域名与目标容器的映射关系,如图3

图3

4、在 Postman 中执行了 2 次请求,第 1 次为 GET,第 2 次为 POST,最终在容器 channel-pub-api-prev 中有一条 GET 请求日志,在容器 channel-pub-api-prev-1 中有一条 POST 请求日志,在容器 channel-pub-api-prev-2 中无请求日志,负载均衡设置符合预期,如图4

图4

5、在 3 个容器中,均在基于 Supervisor 监听队列,在队列所调用的服务中,输出日志至文件中,最终在容器 channel-pub-api-prev 中有一条服务日志,表明队列作业在容器 channel-pub-api-prev 中执行的。如图5

图5

6、查看 命令行下的 Redis 锁定日志,不仅存在 判断Redis模型的锁定是否存在(已存在),而且存在 Redis模型的锁定实现时失败的 日志。时间:14:58 – 14:50 = 9 分钟。锁定次数:29 + 31 + 10 = 70 。锁定频率:70 / 9 = 8,即每分钟 8 次。如图6

图6

[root@7edbf272f55f logs]# ls -ltr
total 136
-rw-r--r-- 1 root root 16556 Mar  4 14:50 app.log
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-lock-2-1583304715.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304842.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304846.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304851.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304855.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304859.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304863.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304868.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304872.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304876.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304880.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304885.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304889.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304893.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304897.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304902.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304906.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304910.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304914.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304919.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304923.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304927.txt
-rw-r--r-- 1 root root     1 Mar  4 14:57 qq-cw-transaction-article-sync-is-lock-exist-2-1583305042.txt
-rw-r--r-- 1 root root     1 Mar  4 14:57 qq-cw-transaction-article-sync-is-lock-exist-2-1583305046.txt
-rw-r--r-- 1 root root     1 Mar  4 14:57 qq-cw-transaction-article-sync-is-lock-exist-2-1583305051.txt
-rw-r--r-- 1 root root     1 Mar  4 14:57 qq-cw-transaction-article-sync-is-lock-exist-2-1583305063.txt
-rw-r--r-- 1 root root     1 Mar  4 14:58 qq-cw-transaction-article-sync-is-lock-exist-2-1583305084.txt
-rw-r--r-- 1 root root     1 Mar  4 14:58 qq-cw-transaction-article-sync-is-lock-exist-2-1583305093.txt
-rw-r--r-- 1 root root     1 Mar  4 14:58 qq-cw-transaction-article-sync-is-lock-exist-2-1583305097.txt

[root@22f7ada2d88d logs]# ls -ltr
total 144
-rw-r--r-- 1 root root 16547 Mar  4 14:50 app.log
-rw-r--r-- 1 root root     1 Mar  4 14:50 qq-cw-transaction-article-sync-is-lock-exist-2-1583304652.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304665.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304669.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304673.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304677.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304682.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304686.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304690.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304694.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304699.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304703.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304707.txt
-rw-r--r-- 1 root root     1 Mar  4 14:51 qq-cw-transaction-article-sync-is-lock-exist-2-1583304711.txt
-rw-r--r-- 1 root root     1 Mar  4 14:52 qq-cw-transaction-article-sync-is-lock-exist-2-1583304720.txt
-rw-r--r-- 1 root root     1 Mar  4 14:53 qq-cw-transaction-article-sync-is-lock-exist-2-1583304816.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304846.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304851.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304855.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304859.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304864.txt
-rw-r--r-- 1 root root     1 Mar  4 14:54 qq-cw-transaction-article-sync-is-lock-exist-2-1583304868.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304949.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304954.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304958.txt
-rw-r--r-- 1 root root     1 Mar  4 14:56 qq-cw-transaction-article-sync-is-lock-exist-2-1583304962.txt
-rw-r--r-- 1 root root     1 Mar  4 14:56 qq-cw-transaction-article-sync-is-lock-exist-2-1583304988.txt
-rw-r--r-- 1 root root     1 Mar  4 14:56 qq-cw-transaction-article-sync-is-lock-exist-2-1583304996.txt
-rw-r--r-- 1 root root     1 Mar  4 14:57 qq-cw-transaction-article-sync-is-lock-exist-2-1583305055.txt
-rw-r--r-- 1 root root     1 Mar  4 14:57 qq-cw-transaction-article-sync-is-lock-exist-2-1583305060.txt
-rw-r--r-- 1 root root     1 Mar  4 14:57 qq-cw-transaction-article-sync-is-lock-exist-2-1583305072.txt
-rw-r--r-- 1 root root     1 Mar  4 14:58 qq-cw-transaction-article-sync-is-lock-exist-2-1583305081.txt

[root@54d07ee806e6 logs]# ls -ltr
total 60
-rw-r--r-- 1 root root 16556 Mar  4 14:53 app.log
-rw-r--r-- 1 root root     1 Mar  4 14:53 qq-cw-transaction-article-sync-is-lock-exist-2-1583304824.txt
-rw-r--r-- 1 root root     1 Mar  4 14:53 qq-cw-transaction-article-sync-is-lock-exist-2-1583304829.txt
-rw-r--r-- 1 root root     1 Mar  4 14:53 qq-cw-transaction-article-sync-is-lock-exist-2-1583304833.txt
-rw-r--r-- 1 root root     1 Mar  4 14:53 qq-cw-transaction-article-sync-is-lock-exist-2-1583304837.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304932.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304936.txt
-rw-r--r-- 1 root root     1 Mar  4 14:55 qq-cw-transaction-article-sync-is-lock-exist-2-1583304941.txt
-rw-r--r-- 1 root root     1 Mar  4 14:57 qq-cw-transaction-article-sync-is-lock-exist-2-1583305029.txt
-rw-r--r-- 1 root root     1 Mar  4 14:57 qq-cw-transaction-article-sync-is-lock-exist-2-1583305033.txt
-rw-r--r-- 1 root root     1 Mar  4 14:57 qq-cw-transaction-article-sync-is-lock-exist-2-1583305038.txt

7、锁定频率过高的根源应该在于命令行中仅有同一条任务在执行。决定模拟出 6 条任务,锁定频率应该会有所下降。时间:15:52 – 15:47 = 6 分钟。锁定次数:47 + 34 + 45 = 126 。锁定频率:126 / 6 = 9,即每分钟 20 次。不符合预期。

[root@7edbf272f55f logs]# ls -ltr
total 188
-rw-r--r-- 1 root root 1 Mar  4 15:47 qq-cw-transaction-video-sync-is-lock-exist-4-1583308059.txt
-rw-r--r-- 1 root root 1 Mar  4 15:47 qq-cw-transaction-video-sync-lock-5-1583308059.txt
-rw-r--r-- 1 root root 1 Mar  4 15:47 qq-cw-transaction-article-sync-is-lock-exist-6-1583308069.txt
-rw-r--r-- 1 root root 1 Mar  4 15:47 qq-cw-transaction-article-sync-is-lock-exist-8-1583308069.txt
-rw-r--r-- 1 root root 1 Mar  4 15:48 qq-cw-transaction-video-sync-is-lock-exist-9-1583308096.txt
-rw-r--r-- 1 root root 1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-7-1583308161.txt
-rw-r--r-- 1 root root 2 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-11-1583308161.txt
-rw-r--r-- 1 root root 1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-6-1583308166.txt
-rw-r--r-- 1 root root 1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-8-1583308166.txt
-rw-r--r-- 1 root root 2 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-12-1583308167.txt
-rw-r--r-- 1 root root 2 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-11-1583308187.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308222.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308222.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308222.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308226.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308226.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308226.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308230.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308230.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308230.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308230.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308234.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308234.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308239.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308239.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308239.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308239.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308243.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308243.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308243.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308247.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308248.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308251.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308256.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-11-1583308260.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-11-1583308264.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-11-1583308268.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-11-1583308272.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308277.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308281.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308290.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308294.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308303.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308307.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308311.txt
-rw-r--r-- 1 root root 2 Mar  4 15:52 qq-cw-transaction-article-sync-is-lock-exist-12-1583308332.txt
-rw-r--r-- 1 root root 2 Mar  4 15:52 qq-cw-transaction-article-sync-is-lock-exist-12-1583308344.txt

[root@22f7ada2d88d logs]# ls -ltr
total 136
-rw-r--r-- 1 root root 1 Mar  4 15:47 qq-cw-transaction-video-sync-is-lock-exist-5-1583308059.txt
-rw-r--r-- 1 root root 2 Mar  4 15:48 qq-cw-transaction-video-sync-is-lock-exist-10-1583308096.txt
-rw-r--r-- 1 root root 1 Mar  4 15:48 qq-cw-transaction-article-sync-is-lock-exist-8-1583308126.txt
-rw-r--r-- 1 root root 2 Mar  4 15:48 qq-cw-transaction-article-sync-is-lock-exist-11-1583308126.txt
-rw-r--r-- 1 root root 1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-6-1583308177.txt
-rw-r--r-- 1 root root 1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-6-1583308182.txt
-rw-r--r-- 1 root root 1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-8-1583308183.txt
-rw-r--r-- 1 root root 2 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-12-1583308183.txt
-rw-r--r-- 1 root root 1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-6-1583308187.txt
-rw-r--r-- 1 root root 1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-6-1583308196.txt
-rw-r--r-- 1 root root 1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-8-1583308196.txt
-rw-r--r-- 1 root root 2 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-12-1583308196.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308206.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308222.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308222.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308226.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308226.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308226.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308230.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308230.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308230.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308235.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308235.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308235.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308239.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308239.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308239.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308243.txt
-rw-r--r-- 1 root root 1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308243.txt
-rw-r--r-- 1 root root 2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308244.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308286.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308298.txt
-rw-r--r-- 1 root root 2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308315.txt
-rw-r--r-- 1 root root 2 Mar  4 15:52 qq-cw-transaction-article-sync-is-lock-exist-12-1583308323.txt

[root@54d07ee806e6 logs]# ls -ltr
total 196
-rw-r--r-- 1 root root     1 Mar  4 15:47 qq-cw-transaction-video-sync-is-lock-exist-4-1583308059.txt
-rw-r--r-- 1 root root     1 Mar  4 15:47 qq-cw-transaction-article-sync-is-lock-exist-7-1583308069.txt
-rw-r--r-- 1 root root     1 Mar  4 15:48 qq-cw-transaction-article-sync-is-lock-exist-8-1583308087.txt
-rw-r--r-- 1 root root 17361 Mar  4 15:48 app.log
-rw-r--r-- 1 root root     2 Mar  4 15:48 qq-cw-transaction-video-sync-is-lock-exist-10-1583308096.txt
-rw-r--r-- 1 root root     1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-6-1583308160.txt
-rw-r--r-- 1 root root     1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-8-1583308161.txt
-rw-r--r-- 1 root root     2 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-12-1583308161.txt
-rw-r--r-- 1 root root     1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-7-1583308166.txt
-rw-r--r-- 1 root root     2 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-11-1583308167.txt
-rw-r--r-- 1 root root     1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-7-1583308177.txt
-rw-r--r-- 1 root root     1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-7-1583308182.txt
-rw-r--r-- 1 root root     2 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-11-1583308183.txt
-rw-r--r-- 1 root root     1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-7-1583308187.txt
-rw-r--r-- 1 root root     1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-8-1583308187.txt
-rw-r--r-- 1 root root     2 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-12-1583308187.txt
-rw-r--r-- 1 root root     1 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-7-1583308196.txt
-rw-r--r-- 1 root root     2 Mar  4 15:49 qq-cw-transaction-article-sync-is-lock-exist-11-1583308196.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308205.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308206.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308226.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-lock-8-1583308226.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-7-1583308230.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308230.txt
-rw-r--r-- 1 root root     2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308230.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308234.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308235.txt
-rw-r--r-- 1 root root     2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308235.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308239.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308239.txt
-rw-r--r-- 1 root root     2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308239.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-6-1583308243.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-lock-7-1583308243.txt
-rw-r--r-- 1 root root     2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-11-1583308243.txt
-rw-r--r-- 1 root root     2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308243.txt
-rw-r--r-- 1 root root     1 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-8-1583308248.txt
-rw-r--r-- 1 root root     2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308251.txt
-rw-r--r-- 1 root root     2 Mar  4 15:50 qq-cw-transaction-article-sync-is-lock-exist-12-1583308256.txt
-rw-r--r-- 1 root root     2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308260.txt
-rw-r--r-- 1 root root     2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308264.txt
-rw-r--r-- 1 root root     2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308269.txt
-rw-r--r-- 1 root root     2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-12-1583308273.txt
-rw-r--r-- 1 root root     2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-11-1583308277.txt
-rw-r--r-- 1 root root     2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-11-1583308281.txt
-rw-r--r-- 1 root root     2 Mar  4 15:51 qq-cw-transaction-article-sync-is-lock-exist-11-1583308285.txt

8、决定调整 bash sleep 3 为 bash sleep 60,即命令行运行一次后,间隔 60 秒后再次运行,而不是 3 秒。重复第 7 步骤,不存在 Redis 锁定日志。符合预期。

9、基于同步时间、ID顺序排列(企鹅号的事务)。某一任务开始执行时,更新企鹅号的事务的同步时间为当前时间 ,以提升执行性能,且再次降低锁定频率。

        // 查询企鹅号的应用类型,cw:内容网站应用 && 类型,1:文章 && 状态,3:处理中 && 文章发布状态:审核中的5条记录,基于同步时间、ID顺序排列(企鹅号的事务)
        $qqTransactionArticleItems = QqTransaction::find()->where(['qq_app_type' => QqArticle::QQ_APP_TYPE_CW, 'type' => QqTransaction::TYPE_ARTICLE, 'article_pub_flag' => HttpQqApiTransaction::ARTICLE_PUB_FLAG_REVIEW])->isDeletedNo()->processing()->orderBy(['synced_at' => SORT_ASC, 'id' => SORT_ASC])->limit(5)->all();

        if ($qqTransactionArticleItems) {
            foreach ($qqTransactionArticleItems as $qqTransactionArticleItem) {
                /* 判断Redis模型的锁定是否存在 */                $redisLockKeyName = 'qq_cw_transaction_article:sync:' . implode(':', ['id' => $qqTransactionArticleItem->id]);
                $redisLock = new RedisLock();
                $isLockExist = $redisLock->isLockExist($redisLockKeyName);
                // 返回 true,表示锁定存在,即已经被其他客户端锁定
                if ($isLockExist === true) {
                    continue;
                }

                /* Redis模型的锁定实现 */                $lock = $redisLock->lock($redisLockKeyName, 600);
                // 返回 false,表示已经被其他客户端锁定
                if ($lock === false) {
                    continue;
                }

                // 基于ID查找单个数据模型(企鹅号的事务)
                $qqTransactionArticleItem = QqTransaction::findOne($qqTransactionArticleItem->id);

                // 更新企鹅号的事务的同步时间
                $qqTransactionArticleItem->synced_at = time();
                $qqTransactionArticleItem->update();
                file_put_contents('/mcloud/www/channel-pub-api/console/runtime/logs/qq-cw-transaction-article-sync-' . $qqTransactionArticleItem->id . '-' . time() . '.txt', $qqTransactionArticleItem->id);
            }
        }

10、模拟出 3 条任务。事务ID为 41、42、43 的同步时间(分钟)分别为:9、9、8 。事务ID为 41、42、43 的同步次数分别为:22、20、17 。事务ID为 41、42、43 的同步频率分别为:9 * 60 / 22 = 25、9 * 60 / 20 = 27、8 * 60 / 17 = 28。得出平均值:(25 + 27 + 28) / 3 = 27。理论上的计算公式,进一法取整(事务数量 / 5) / 容器数量 * 60。符合预期。如图7

图7

[root@21325d776096 logs]# ls -ltr
total 64
-rw-r--r-- 1 root root 2 Mar  5 17:04 qq-cw-transaction-article-sync-41-1583399050.txt
-rw-r--r-- 1 root root 2 Mar  5 17:04 qq-cw-transaction-article-sync-43-1583399050.txt
-rw-r--r-- 1 root root 2 Mar  5 17:05 qq-cw-transaction-article-sync-41-1583399112.txt
-rw-r--r-- 1 root root 2 Mar  5 17:05 qq-cw-transaction-article-sync-42-1583399112.txt
-rw-r--r-- 1 root root 2 Mar  5 17:06 qq-cw-transaction-article-sync-41-1583399173.txt
-rw-r--r-- 1 root root 2 Mar  5 17:06 qq-cw-transaction-article-sync-42-1583399174.txt
-rw-r--r-- 1 root root 2 Mar  5 17:07 qq-cw-transaction-article-sync-41-1583399235.txt
-rw-r--r-- 1 root root 2 Mar  5 17:07 qq-cw-transaction-article-sync-42-1583399235.txt
-rw-r--r-- 1 root root 2 Mar  5 17:07 qq-cw-transaction-article-sync-43-1583399236.txt
-rw-r--r-- 1 root root 2 Mar  5 17:08 qq-cw-transaction-article-sync-41-1583399297.txt
-rw-r--r-- 1 root root 2 Mar  5 17:08 qq-cw-transaction-article-sync-43-1583399298.txt
-rw-r--r-- 1 root root 2 Mar  5 17:09 qq-cw-transaction-article-sync-41-1583399359.txt
-rw-r--r-- 1 root root 2 Mar  5 17:09 qq-cw-transaction-article-sync-42-1583399359.txt
-rw-r--r-- 1 root root 2 Mar  5 17:10 qq-cw-transaction-article-sync-41-1583399421.txt
-rw-r--r-- 1 root root 2 Mar  5 17:10 qq-cw-transaction-article-sync-42-1583399421.txt
-rw-r--r-- 1 root root 2 Mar  5 17:11 qq-cw-transaction-article-sync-42-1583399483.txt

[root@e9565f71310d logs]# ls -ltr
total 100
-rw-r--r-- 1 root root 2 Mar  5 17:03 qq-cw-transaction-article-sync-41-1583399012.txt
-rw-r--r-- 1 root root 2 Mar  5 17:03 qq-cw-transaction-article-sync-42-1583399013.txt
-rw-r--r-- 1 root root 2 Mar  5 17:03 qq-cw-transaction-article-sync-43-1583399013.txt
-rw-r--r-- 1 root root 2 Mar  5 17:04 qq-cw-transaction-article-sync-41-1583399074.txt
-rw-r--r-- 1 root root 2 Mar  5 17:04 qq-cw-transaction-article-sync-42-1583399075.txt
-rw-r--r-- 1 root root 2 Mar  5 17:04 qq-cw-transaction-article-sync-43-1583399076.txt
-rw-r--r-- 1 root root 2 Mar  5 17:05 qq-cw-transaction-article-sync-41-1583399137.txt
-rw-r--r-- 1 root root 2 Mar  5 17:05 qq-cw-transaction-article-sync-42-1583399138.txt
-rw-r--r-- 1 root root 2 Mar  5 17:05 qq-cw-transaction-article-sync-43-1583399139.txt
-rw-r--r-- 1 root root 2 Mar  5 17:06 qq-cw-transaction-article-sync-41-1583399200.txt
-rw-r--r-- 1 root root 2 Mar  5 17:06 qq-cw-transaction-article-sync-42-1583399201.txt
-rw-r--r-- 1 root root 2 Mar  5 17:06 qq-cw-transaction-article-sync-43-1583399201.txt
-rw-r--r-- 1 root root 2 Mar  5 17:07 qq-cw-transaction-article-sync-41-1583399263.txt
-rw-r--r-- 1 root root 2 Mar  5 17:07 qq-cw-transaction-article-sync-42-1583399264.txt
-rw-r--r-- 1 root root 2 Mar  5 17:07 qq-cw-transaction-article-sync-43-1583399264.txt
-rw-r--r-- 1 root root 2 Mar  5 17:08 qq-cw-transaction-article-sync-41-1583399325.txt
-rw-r--r-- 1 root root 2 Mar  5 17:08 qq-cw-transaction-article-sync-42-1583399326.txt
-rw-r--r-- 1 root root 2 Mar  5 17:08 qq-cw-transaction-article-sync-43-1583399326.txt
-rw-r--r-- 1 root root 2 Mar  5 17:09 qq-cw-transaction-article-sync-42-1583399388.txt
-rw-r--r-- 1 root root 2 Mar  5 17:09 qq-cw-transaction-article-sync-43-1583399388.txt
-rw-r--r-- 1 root root 2 Mar  5 17:09 qq-cw-transaction-article-sync-41-1583399388.txt
-rw-r--r-- 1 root root 2 Mar  5 17:10 qq-cw-transaction-article-sync-42-1583399450.txt
-rw-r--r-- 1 root root 2 Mar  5 17:10 qq-cw-transaction-article-sync-43-1583399451.txt
-rw-r--r-- 1 root root 2 Mar  5 17:10 qq-cw-transaction-article-sync-41-1583399451.txt
-rw-r--r-- 1 root root 2 Mar  5 17:11 qq-cw-transaction-article-sync-42-1583399512.txt

[root@7c7a4390ba3f logs]# ls -ltr
total 72
-rw-r--r-- 1 root root 2 Mar  5 17:04 qq-cw-transaction-article-sync-42-1583399050.txt
-rw-r--r-- 1 root root 2 Mar  5 17:04 qq-cw-transaction-article-sync-43-1583399050.txt
-rw-r--r-- 1 root root 2 Mar  5 17:04 qq-cw-transaction-article-sync-41-1583399050.txt
-rw-r--r-- 1 root root 2 Mar  5 17:05 qq-cw-transaction-article-sync-43-1583399112.txt
-rw-r--r-- 1 root root 2 Mar  5 17:05 qq-cw-transaction-article-sync-41-1583399112.txt
-rw-r--r-- 1 root root 2 Mar  5 17:06 qq-cw-transaction-article-sync-43-1583399174.txt
-rw-r--r-- 1 root root 2 Mar  5 17:06 qq-cw-transaction-article-sync-41-1583399174.txt
-rw-r--r-- 1 root root 2 Mar  5 17:06 qq-cw-transaction-article-sync-42-1583399174.txt
-rw-r--r-- 1 root root 2 Mar  5 17:07 qq-cw-transaction-article-sync-41-1583399236.txt
-rw-r--r-- 1 root root 2 Mar  5 17:07 qq-cw-transaction-article-sync-42-1583399236.txt
-rw-r--r-- 1 root root 2 Mar  5 17:08 qq-cw-transaction-article-sync-42-1583399298.txt
-rw-r--r-- 1 root root 2 Mar  5 17:08 qq-cw-transaction-article-sync-43-1583399298.txt
-rw-r--r-- 1 root root 2 Mar  5 17:08 qq-cw-transaction-article-sync-41-1583399298.txt
-rw-r--r-- 1 root root 2 Mar  5 17:09 qq-cw-transaction-article-sync-43-1583399360.txt
-rw-r--r-- 1 root root 2 Mar  5 17:09 qq-cw-transaction-article-sync-41-1583399360.txt
-rw-r--r-- 1 root root 2 Mar  5 17:10 qq-cw-transaction-article-sync-43-1583399421.txt
-rw-r--r-- 1 root root 2 Mar  5 17:10 qq-cw-transaction-article-sync-41-1583399422.txt
-rw-r--r-- 1 root root 2 Mar  5 17:11 qq-cw-transaction-article-sync-42-1583399483.txt

11、模拟出 5 条任务。事务ID为 47、48、49、52、53 的同步时间(分钟)分别为:4、11、4、5、5 。事务ID为 47、48、49、52、53 的同步次数分别为:10、20、10、9、10 。事务ID为 47、48、49、52、53 的同步频率分别为:4 * 60 / 10 = 24、11 * 60 / 20 = 33、4 * 60 / 10 = 24、5 * 60 / 9 = 33、5 * 60 / 10 = 30。得出平均值:(24 + 33 + 24 + 33 + 30) / 5 = 29。理论上的计算公式,进一法取整(事务数量 / 5) / 容器数量 * 60。符合预期。如图8

图8

[root@21325d776096 logs]# ls -ltr
total 88
-rw-r--r-- 1 root root 2 Mar  6 09:55 qq-cw-transaction-article-sync-47-1583459743.txt
-rw-r--r-- 1 root root 2 Mar  6 09:55 qq-cw-transaction-article-sync-48-1583459744.txt
-rw-r--r-- 1 root root 2 Mar  6 09:55 qq-cw-transaction-article-sync-49-1583459744.txt
-rw-r--r-- 1 root root 2 Mar  6 09:56 qq-cw-transaction-article-sync-52-1583459806.txt
-rw-r--r-- 1 root root 2 Mar  6 09:56 qq-cw-transaction-article-sync-47-1583459807.txt
-rw-r--r-- 1 root root 2 Mar  6 09:56 qq-cw-transaction-article-sync-48-1583459807.txt
-rw-r--r-- 1 root root 2 Mar  6 09:56 qq-cw-transaction-article-sync-49-1583459807.txt
-rw-r--r-- 1 root root 2 Mar  6 09:56 qq-cw-transaction-article-sync-53-1583459807.txt
-rw-r--r-- 1 root root 2 Mar  6 09:57 qq-cw-transaction-article-sync-47-1583459869.txt
-rw-r--r-- 1 root root 2 Mar  6 09:57 qq-cw-transaction-article-sync-48-1583459869.txt
-rw-r--r-- 1 root root 2 Mar  6 09:57 qq-cw-transaction-article-sync-52-1583459870.txt
-rw-r--r-- 1 root root 2 Mar  6 09:57 qq-cw-transaction-article-sync-49-1583459870.txt
-rw-r--r-- 1 root root 2 Mar  6 09:57 qq-cw-transaction-article-sync-53-1583459870.txt
-rw-r--r-- 1 root root 2 Mar  6 09:58 qq-cw-transaction-article-sync-48-1583459932.txt
-rw-r--r-- 1 root root 2 Mar  6 09:58 qq-cw-transaction-article-sync-52-1583459932.txt
-rw-r--r-- 1 root root 2 Mar  6 09:58 qq-cw-transaction-article-sync-53-1583459932.txt
-rw-r--r-- 1 root root 2 Mar  6 09:59 qq-cw-transaction-article-sync-48-1583459994.txt
-rw-r--r-- 1 root root 2 Mar  6 10:00 qq-cw-transaction-article-sync-48-1583460055.txt
-rw-r--r-- 1 root root 2 Mar  6 10:01 qq-cw-transaction-article-sync-48-1583460117.txt
-rw-r--r-- 1 root root 2 Mar  6 10:02 qq-cw-transaction-article-sync-48-1583460179.txt
-rw-r--r-- 1 root root 2 Mar  6 10:04 qq-cw-transaction-article-sync-48-1583460240.txt
-rw-r--r-- 1 root root 2 Mar  6 10:05 qq-cw-transaction-article-sync-48-1583460302.txt

[root@e9565f71310d logs]# ls -ltr
total 96
-rw-r--r-- 1 root root 2 Mar  6 09:55 qq-cw-transaction-article-sync-52-1583459751.txt
-rw-r--r-- 1 root root 2 Mar  6 09:55 qq-cw-transaction-article-sync-53-1583459752.txt
-rw-r--r-- 1 root root 2 Mar  6 09:55 qq-cw-transaction-article-sync-47-1583459752.txt
-rw-r--r-- 1 root root 2 Mar  6 09:55 qq-cw-transaction-article-sync-48-1583459752.txt
-rw-r--r-- 1 root root 2 Mar  6 09:55 qq-cw-transaction-article-sync-49-1583459752.txt
-rw-r--r-- 1 root root 2 Mar  6 09:56 qq-cw-transaction-article-sync-52-1583459813.txt
-rw-r--r-- 1 root root 2 Mar  6 09:56 qq-cw-transaction-article-sync-47-1583459813.txt
-rw-r--r-- 1 root root 2 Mar  6 09:56 qq-cw-transaction-article-sync-48-1583459814.txt
-rw-r--r-- 1 root root 2 Mar  6 09:56 qq-cw-transaction-article-sync-49-1583459814.txt
-rw-r--r-- 1 root root 2 Mar  6 09:56 qq-cw-transaction-article-sync-53-1583459814.txt
-rw-r--r-- 1 root root 2 Mar  6 09:57 qq-cw-transaction-article-sync-47-1583459876.txt
-rw-r--r-- 1 root root 2 Mar  6 09:57 qq-cw-transaction-article-sync-48-1583459877.txt
-rw-r--r-- 1 root root 2 Mar  6 09:57 qq-cw-transaction-article-sync-49-1583459877.txt
-rw-r--r-- 1 root root 2 Mar  6 09:57 qq-cw-transaction-article-sync-52-1583459878.txt
-rw-r--r-- 1 root root 2 Mar  6 09:57 qq-cw-transaction-article-sync-53-1583459878.txt
-rw-r--r-- 1 root root 2 Mar  6 09:59 qq-cw-transaction-article-sync-48-1583459940.txt
-rw-r--r-- 1 root root 2 Mar  6 09:59 qq-cw-transaction-article-sync-52-1583459940.txt
-rw-r--r-- 1 root root 2 Mar  6 09:59 qq-cw-transaction-article-sync-53-1583459941.txt
-rw-r--r-- 1 root root 2 Mar  6 10:00 qq-cw-transaction-article-sync-48-1583460002.txt
-rw-r--r-- 1 root root 2 Mar  6 10:01 qq-cw-transaction-article-sync-48-1583460063.txt
-rw-r--r-- 1 root root 2 Mar  6 10:02 qq-cw-transaction-article-sync-48-1583460125.txt
-rw-r--r-- 1 root root 2 Mar  6 10:03 qq-cw-transaction-article-sync-48-1583460187.txt
-rw-r--r-- 1 root root 2 Mar  6 10:04 qq-cw-transaction-article-sync-48-1583460248.txt
-rw-r--r-- 1 root root 2 Mar  6 10:05 qq-cw-transaction-article-sync-48-1583460310.txt

[root@7c7a4390ba3f logs]# ls -ltr
total 120
-rw-r--r-- 1 root root 17367 Mar  6 09:55 app.log
-rw-r--r-- 1 root root     2 Mar  6 09:55 qq-cw-transaction-article-sync-47-1583459731.txt
-rw-r--r-- 1 root root     2 Mar  6 09:55 qq-cw-transaction-article-sync-48-1583459732.txt
-rw-r--r-- 1 root root     2 Mar  6 09:55 qq-cw-transaction-article-sync-49-1583459732.txt
-rw-r--r-- 1 root root     2 Mar  6 09:56 qq-cw-transaction-article-sync-52-1583459793.txt
-rw-r--r-- 1 root root     2 Mar  6 09:56 qq-cw-transaction-article-sync-47-1583459794.txt
-rw-r--r-- 1 root root     2 Mar  6 09:56 qq-cw-transaction-article-sync-48-1583459794.txt
-rw-r--r-- 1 root root     2 Mar  6 09:56 qq-cw-transaction-article-sync-49-1583459794.txt
-rw-r--r-- 1 root root     2 Mar  6 09:56 qq-cw-transaction-article-sync-53-1583459795.txt
-rw-r--r-- 1 root root     2 Mar  6 09:57 qq-cw-transaction-article-sync-47-1583459856.txt
-rw-r--r-- 1 root root     2 Mar  6 09:57 qq-cw-transaction-article-sync-52-1583459857.txt
-rw-r--r-- 1 root root     2 Mar  6 09:57 qq-cw-transaction-article-sync-48-1583459857.txt
-rw-r--r-- 1 root root     2 Mar  6 09:57 qq-cw-transaction-article-sync-49-1583459858.txt
-rw-r--r-- 1 root root     2 Mar  6 09:57 qq-cw-transaction-article-sync-53-1583459859.txt
-rw-r--r-- 1 root root     2 Mar  6 09:58 qq-cw-transaction-article-sync-47-1583459920.txt
-rw-r--r-- 1 root root     2 Mar  6 09:58 qq-cw-transaction-article-sync-48-1583459921.txt
-rw-r--r-- 1 root root     2 Mar  6 09:58 qq-cw-transaction-article-sync-49-1583459922.txt
-rw-r--r-- 1 root root     2 Mar  6 09:58 qq-cw-transaction-article-sync-52-1583459922.txt
-rw-r--r-- 1 root root     2 Mar  6 09:58 qq-cw-transaction-article-sync-53-1583459922.txt
-rw-r--r-- 1 root root     2 Mar  6 09:59 qq-cw-transaction-article-sync-48-1583459984.txt
-rw-r--r-- 1 root root     2 Mar  6 10:00 qq-cw-transaction-article-sync-48-1583460045.txt
-rw-r--r-- 1 root root     2 Mar  6 10:01 qq-cw-transaction-article-sync-48-1583460107.txt
-rw-r--r-- 1 root root     2 Mar  6 10:02 qq-cw-transaction-article-sync-48-1583460169.txt
-rw-r--r-- 1 root root     2 Mar  6 10:03 qq-cw-transaction-article-sync-48-1583460231.txt
-rw-r--r-- 1 root root     2 Mar  6 10:04 qq-cw-transaction-article-sync-48-1583460293.txt
-rw-r--r-- 1 root root     2 Mar  6 10:05 qq-cw-transaction-article-sync-48-1583460355.txt

12、模拟出 8 条任务。事务ID为 57、58、59、63、64、65、68、69 的同步时间(分钟)分别为:11、12、13、12、11、12、11、12 。事务ID为 57、58、59、63、64、65、68、69 的同步次数分别为:21、22、22、19、17、5、17、17 。事务ID为 57、58、59、63、64、65、68、69 的同步频率分别为:11 * 60 / 21 = 31、12 * 60 / 22 = 33、13 * 60 / 22 = 35、12 * 60 / 19 = 38、11 * 60 / 17 = 39、12 * 60 / 5 = 144、11 * 60 / 17 = 39、12 * 60 / 17 = 42。得出平均值:(31 + 33 + 35 + 38 + 39 + 144 + 39 + 42) / 8 = 50。理论上的计算公式,进一法取整(事务数量 / 5) / 容器数量 * 60。符合预期。如图9

图9

[root@21325d776096 logs]# ls -ltr
total 220
-rw-r--r-- 1 root root     2 Mar  6 10:30 qq-cw-transaction-article-sync-57-1583461834.txt
-rw-r--r-- 1 root root     2 Mar  6 10:30 qq-cw-transaction-article-sync-58-1583461834.txt
-rw-r--r-- 1 root root     2 Mar  6 10:30 qq-cw-transaction-article-sync-59-1583461834.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-68-1583461896.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-69-1583461896.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-57-1583461897.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-58-1583461897.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-63-1583461959.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-64-1583461959.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-68-1583461959.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-69-1583461959.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-58-1583462021.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-59-1583462022.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-63-1583462022.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-57-1583462022.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-68-1583462084.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-58-1583462084.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-69-1583462085.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-59-1583462085.txt
-rw-r--r-- 1 root root 34566 Mar  6 10:35 app.log
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-63-1583462146.txt
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-64-1583462147.txt
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-68-1583462147.txt
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-57-1583462147.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-59-1583462209.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-63-1583462209.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-69-1583462210.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-57-1583462210.txt
-rw-r--r-- 1 root root     2 Mar  6 10:37 qq-cw-transaction-article-sync-64-1583462271.txt
-rw-r--r-- 1 root root     2 Mar  6 10:37 qq-cw-transaction-article-sync-68-1583462272.txt
-rw-r--r-- 1 root root     2 Mar  6 10:37 qq-cw-transaction-article-sync-59-1583462272.txt
-rw-r--r-- 1 root root     2 Mar  6 10:37 qq-cw-transaction-article-sync-57-1583462272.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-63-1583462334.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-64-1583462334.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-69-1583462335.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-57-1583462335.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-59-1583462396.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-63-1583462397.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-68-1583462397.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-57-1583462397.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-59-1583462459.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-64-1583462459.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-69-1583462460.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-65-1583462460.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-58-1583462460.txt
-rw-r--r-- 1 root root     2 Mar  6 10:42 qq-cw-transaction-article-sync-69-1583462522.txt
-rw-r--r-- 1 root root     2 Mar  6 10:42 qq-cw-transaction-article-sync-59-1583462523.txt

[root@e9565f71310d logs]# ls -ltr
total 212
-rw-r--r-- 1 root root     2 Mar  6 10:30 qq-cw-transaction-article-sync-63-1583461842.txt
-rw-r--r-- 1 root root     2 Mar  6 10:30 qq-cw-transaction-article-sync-64-1583461842.txt
-rw-r--r-- 1 root root     2 Mar  6 10:30 qq-cw-transaction-article-sync-65-1583461843.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-59-1583461905.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-63-1583461905.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-64-1583461906.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-68-1583461906.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-57-1583461968.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-58-1583461968.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-59-1583461969.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-63-1583461969.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-64-1583462030.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-68-1583462031.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-69-1583462032.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-58-1583462032.txt
-rw-r--r-- 1 root root 33937 Mar  6 10:34 app.log
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-57-1583462093.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-63-1583462094.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-64-1583462094.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-68-1583462094.txt
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-58-1583462155.txt
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-59-1583462156.txt
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-69-1583462156.txt
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-63-1583462156.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-58-1583462218.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-64-1583462218.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-68-1583462218.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-59-1583462219.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-58-1583462280.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-63-1583462281.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-69-1583462281.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-64-1583462281.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-58-1583462343.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-59-1583462344.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-68-1583462344.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-63-1583462344.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-58-1583462406.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-64-1583462406.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-69-1583462406.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-59-1583462406.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-63-1583462468.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-68-1583462468.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-59-1583462469.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-58-1583462469.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-65-1583462470.txt

[root@7c7a4390ba3f logs]# ls -ltr
total 220
-rw-r--r-- 1 root root     2 Mar  6 10:30 qq-cw-transaction-article-sync-57-1583461824.txt
-rw-r--r-- 1 root root     2 Mar  6 10:30 qq-cw-transaction-article-sync-58-1583461825.txt
-rw-r--r-- 1 root root     2 Mar  6 10:30 qq-cw-transaction-article-sync-59-1583461825.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-57-1583461886.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-58-1583461886.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-59-1583461886.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-63-1583461887.txt
-rw-r--r-- 1 root root     2 Mar  6 10:31 qq-cw-transaction-article-sync-64-1583461887.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-69-1583461948.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-57-1583461949.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-58-1583461949.txt
-rw-r--r-- 1 root root     2 Mar  6 10:32 qq-cw-transaction-article-sync-59-1583461949.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-64-1583462011.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-68-1583462011.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-69-1583462011.txt
-rw-r--r-- 1 root root     2 Mar  6 10:33 qq-cw-transaction-article-sync-57-1583462011.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-59-1583462073.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-57-1583462074.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-63-1583462074.txt
-rw-r--r-- 1 root root     2 Mar  6 10:34 qq-cw-transaction-article-sync-64-1583462074.txt
-rw-r--r-- 1 root root 17200 Mar  6 10:35 app.log
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-58-1583462136.txt
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-59-1583462136.txt
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-69-1583462136.txt
-rw-r--r-- 1 root root     2 Mar  6 10:35 qq-cw-transaction-article-sync-57-1583462136.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-57-1583462198.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-64-1583462199.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-68-1583462199.txt
-rw-r--r-- 1 root root     2 Mar  6 10:36 qq-cw-transaction-article-sync-58-1583462199.txt
-rw-r--r-- 1 root root     2 Mar  6 10:37 qq-cw-transaction-article-sync-63-1583462261.txt
-rw-r--r-- 1 root root     2 Mar  6 10:37 qq-cw-transaction-article-sync-57-1583462261.txt
-rw-r--r-- 1 root root     2 Mar  6 10:37 qq-cw-transaction-article-sync-69-1583462261.txt
-rw-r--r-- 1 root root     2 Mar  6 10:37 qq-cw-transaction-article-sync-58-1583462261.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-57-1583462323.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-59-1583462324.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-68-1583462324.txt
-rw-r--r-- 1 root root     2 Mar  6 10:38 qq-cw-transaction-article-sync-58-1583462324.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-64-1583462386.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-57-1583462386.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-69-1583462386.txt
-rw-r--r-- 1 root root     2 Mar  6 10:39 qq-cw-transaction-article-sync-58-1583462386.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-65-1583462448.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-57-1583462448.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-63-1583462449.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-68-1583462449.txt
-rw-r--r-- 1 root root     2 Mar  6 10:40 qq-cw-transaction-article-sync-58-1583462449.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-69-1583462511.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-63-1583462511.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-68-1583462512.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-59-1583462512.txt
-rw-r--r-- 1 root root     2 Mar  6 10:41 qq-cw-transaction-article-sync-65-1583462512.txt

 

永夜