当前位置:网站首页>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 .
边栏推荐
- Vim中删除^M
- C language introduction practice (7): switch case calculation of days in the year (normal year / leap year calculation)
- Is there any online account opening process of Huatai Securities? Is online account opening safe
- Binary tree knowledge summary
- @ConstructorProperties注解理解以及其对应使用方式
- 【硬十宝典】——7.2【动态RAM】DDR4与DDR3区别解析
- The results of the soft test can be checked, and the entry to query the results of the soft test has been opened in the first half of 2022
- 【Web3 系列开发教程——创建你的第一个 NFT(4)】NFTs 可以给你带来什么
- JS date details, string to date
- 哈夫曼编码原理
猜你喜欢

CS5801_ HDMI to EDP advantage replaces lt6711a solution

Sorting problem: bubble sort, select sort, insert sort

【硬十宝典】——7.1【动态RAM】DDR硬件设计要点

Binary tree knowledge summary

Go 的切片与数组

MySQL基础篇(二)-- MySQL 基础

Which "digital currencies" can survive this winter? 2020-03-30

Realize the full link grayscale based on Apache APIs IX through MSE

Force deduction 5: Longest palindrome substring

深度学习——CV、CNN、RNN
随机推荐
软考可以查成绩了,2022年上半年软考成绩查询入口已开通
Regular expressions and calling related functions in C language
The "darkest hour" has not come yet. Cherish every bullet 2020-03-22
Torth file read vulnerability (cnvd-2020-27769)
dev treelist 常用用法小结
Advanced C language - archived address book (file)
UIToolkit中显示汉字
带你搞透IO多路复用原理(select、poll和epoll)
【Star项目】小帽飞机大战(三)
Force deduction 5: Longest palindrome substring
【图像隐藏】基于混合 DWT-HD-SVD 的数字图像水印方法技术附matlab代码
Vim中删除^M
Summary of common usage of dev treelist
曲线曲率展示
C#使用log4net插件,输出日志到文件
Open includeexceptiondetailinfaults on the server (from servicebehaviorattribute or from & lt; servicedebug & gt; to configure behavior) to send exception information back
Force buckle - 4. Find the median of two positive arrays
IP day 10 notes - BGP
C language introduction practice (8): switch case calculates the month, year and day of the next day (normal year / leap year calculation)
7. Reverse integer integer