当前位置:网站首页>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 .
边栏推荐
- Basis of multimodal semantic segmentation
- Fastdfs supports dual IP and IPv6
- Conda 虚拟环境envs目录为空
- C language file operation
- How to open an account online for Guohai Securities? Is it safe to open an account
- Vim中删除^M
- UIToolkit中显示汉字
- Multi-objective collaborative decision-making in supply chain
- On stock price prediction model (3): are you falling into the trap of machine learning
- 打开服务器上的 IncludeExceptionDetailInFaults (从 ServiceBehaviorAttribute 或从 <serviceDebug> 配置行为)以便将异常信息发送回
猜你喜欢
随机推荐
Children's programming electronic society graphical programming level examination scratch level 1 real problem analysis (multiple choice) June 2022
MySQL基础篇(二)-- MySQL 基础
力扣——4. 寻找两个正序数组的中位数
"Harmonyos" explore harmonyos applications
Deep learning - CV, CNN, RNN
CS5801_ HDMI to EDP advantage replaces lt6711a solution
抖音web端 s_v_web_id 参数生成分析与实现
Resume considerations
Fastdfs supports dual IP and IPv6
『HarmonyOS』探索HarmonyOS应用
【Star项目】小帽飞机大战(二)
PMP customs formula, don't hurry to recite it
『HarmonyOS』工程的创建与虚拟机的使用
openssl: error while loading shared libraries: libssl.so.1.1
How does the national standard gb28181 protocol easygbs platform realize device video recording and set streaming IP?
C language file operation
Heap sort
CONDA virtual environment envs directory is empty
String and memory functions
『牛客|每日一题』逆波兰表达式








