当前位置:网站首页>Celery takes up large memory - memory leak
Celery takes up large memory - memory leak
2022-07-26 06:49:00 【51CTO】
Problem finding
Originally top Command to view the real-time memory of the server , Suddenly found that 32G Memory celery Occupy to 12%, It takes up a lot of memory 4G 了 .
-
top Under orders ,M Key on press MEM Column sorted process list , Press H Then view the thread list , because worker No child threads , So only one record is displayed ;- Press
c command , Start COMMAND List details , You can find the corresponding process initiator ;- Press
o key , Turn on the filtering function , Input COMMAND=celery Display only celery List of processes named ;
reason
By default ,celery Of worker Is the maximum number of tasks that the work process can execute before being replaced by a new task , The default is unlimited .
see Website shows
Need configuration celery Set up But the parameters written on the official website have errors in the execution process " The new setting name cannot be mixed with the old setting name "
Cannot mix new setting names with old setting names, please
rename the following settings to use the old format:
worker_max_tasks_per_child -> CELERYD_MAX_TASKS_PER_CHILD
worker_prefetch_multiplier -> CELERYD_PREFETCH_MULTIPLIER
The configuration name needs to be modified :
Restart
perform
start-up celery, adopt ps -ef | grep celery You can see two celery worker process (8226,8228)
utilize celery worker Carry out a task , When worker When the maximum task is not performed ( Destroy and rebuild ), Each time a task is executed, the memory occupied will inevitably increase , The number of tasks is 9,10 when (celery Uniform scheduling , Concurrency number * Maximum number of tasks ), There are original 8228 worker Be destroyed , Recreate 9386 worker And the original 8226 worker Be destroyed , Recreate 9564 worker, here , Run the 9 When the time , The total memory consumption has decreased , Run the 10 When the time , The total memory returns to the initial value , Carry out the same task 19、20 The situation is similar .
celery Concurrent calculation rules
celery Task concurrency is only associated with celery Configuration item CELERYD_CONCURRENCY of , And CELERYD_MAX_TASKS_PER_CHILD It doesn't matter. , namely CELERYD_CONCURRENCY=2, Only concurrent 2 individual worker, At this time, when the task processes large files , Execute twice to see two task Tasks are executed in parallel , While performing the third task , Start queuing , Until two worker completion of enforcement .
Conclusion
celery After executing the task, do not release the memory and the original worker It has not been destroyed , therefore CELERYD_MAX_TASKS_PER_CHILD Small points can be configured appropriately , The number of concurrent tasks is the same as CELERYD_CONCURRENCY Configuration item , Every time you add one worker Inevitably increase memory consumption , It also affects a worker When will it be destroyed , because celery It is to evenly schedule tasks to each worker, Therefore, the configuration should not be too large , Properly configured .
边栏推荐
- Vision Transformer 必读系列之图像分类综述
- [fault diagnosis] bearing fault diagnosis based on Bayesian optimization support vector machine with matlab code
- openssl: error while loading shared libraries: libssl.so.1.1
- UIToolkit中显示汉字
- 曲线曲率展示
- Database performance test (MySQL)
- MySQL optimized index and index invalidation
- MySQL Foundation (II) -- MySQL Foundation
- 【毕业季_进击的技术er】送别过去两年迷茫的自己。重整旗鼓,大三我来啦
- Ruby on rails Code Execution Vulnerability (cve-2020-8163) technical analysis, research, judgment and protection
猜你喜欢

Display Chinese characters in uitoolkit

28. Implement strStr()实现 strStr()

Address resolution ARP Protocol

Experimental flags: --disable_ admission_ control=false --enable_ rm=false --llama_ callback_ port=28000

Delete ^m from VIM
![Esxi 7.0 installation supports mellanox technologies mt26448 [connectx en 10gige, PCIe 2.0 5gt/s] driver, and supports the cheapest 10GB dual fiber network card](/img/51/a5282b657b1dfed2dac476c1efee2d.png)
Esxi 7.0 installation supports mellanox technologies mt26448 [connectx en 10gige, PCIe 2.0 5gt/s] driver, and supports the cheapest 10GB dual fiber network card

Valid bracket sequence of "Niuke | daily question"

曲线曲率展示

Quick sort

字符串和内存函数
随机推荐
"Final review" 16/32-bit microprocessor (8086) basic register
C language introduction practice (8): switch case calculates the month, year and day of the next day (normal year / leap year calculation)
Summary of common usage of dev treelist
源代码加密技术发展阶段
少儿编程 电子学会图形化编程等级考试Scratch一级真题解析(选择题)2022年6月
How does the national standard gb28181 protocol easygbs platform realize device video recording and set streaming IP?
[hardware ten treasures] - 7.1 [dynamic RAM] key points of DDR hardware design
[Star Project] small hat aircraft War (II)
【硬十宝典】——7.2【动态RAM】DDR4与DDR3区别解析
曲线曲率展示
服装行业如何实现数字化生产模式
Log rotation logrotate
PMP customs formula, don't hurry to recite it
JS date details, string to date
排序问题:冒泡排序,选择排序,插入排序
IP day 10 notes - BGP
供应链的多目标协同决策
堆排序(heap-sort)
『牛客|每日一题』点击消除
Press in and pop-up sequence of "Niuke | daily question" stack