Code Monkey home page Code Monkey logo

Comments (7)

hhrensheng avatar hhrensheng commented on September 27, 2024

image

from webman-rqueue.

hhrensheng avatar hhrensheng commented on September 27, 2024

应该是这个原因,我把$timerInterval消费间隔改成1秒占用就下来了

from webman-rqueue.

chaz6chez avatar chaz6chez commented on September 27, 2024
  1. 队列的消费利用的是event-loop的timer
  2. 延迟队列是利用消息的delay的判断+消息的republish来模拟的

所以延迟队列在消费间隔较小的时候会频繁对延迟队列的消息进行滚动,反复read+republish,直到delay条件达到;在这个情况下,CPU会占用较高,一方面是redis本身压力会增加,一方面是队列在接近空转的情况下处理;

所以:

  1. 延迟队列尽可能消费间隔大一些
  2. 不同的延迟任务尽可能分散在不同消费间隔的延迟队列【可选项建议】

from webman-rqueue.

chaz6chez avatar chaz6chez commented on September 27, 2024

通过对以下三个参数的调整可以在消费能力、消费时效性、CPU占用率上达到平衡

  1. QOS,单个进程单次读取的最大消息树
  2. timerInterval, 单个进程消费间隔时间
  3. count,消费组最大消费者数量

from webman-rqueue.

chaz6chez avatar chaz6chez commented on September 27, 2024

计划在下一个版本增加自适应定时间隔:

  1. 增加闲置间隔idle_limit配置参数,接受一个int,单位ms
  2. 增加退避指数avoid_index配置,接受一个float
  3. 增加最大退避间隔avoid_interval配置,接受一个float,单位ms
  4. 优化当前定时消费为自适应定时消费

当idle_limit时间内没有读取到任何消息时,当前消费进程的定时器会根据退避指数avoid_index倍数增加自己的定时器间隔,每增加一次间隔后的下一次如果依然没有读取到消息,则定时器间隔呈avoid_index指数倍数上升;
定时器间隔不会超过最大退避间隔;
当任意一次消息被读取后,定时器间隔恢复初始化。

from webman-rqueue.

hhrensheng avatar hhrensheng commented on September 27, 2024

感谢作者的答疑。自适应的这种效果确实不错,现在默认的1ms间隔确实太短了,如果不修改的话,一般云服务器大部分都是低主频确实容易高占用。

from webman-rqueue.

chaz6chez avatar chaz6chez commented on September 27, 2024

2.1.10版本开始增加了自适应队列,是一个实验性质的功能特性,待成熟后,会在2.2中正式加入

from webman-rqueue.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.