当前位置:网站首页>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 .
边栏推荐
- Summarize and learn STM32 to create project template
- [fault diagnosis] bearing fault diagnosis based on Bayesian optimization support vector machine with matlab code
- Go 的通道channel
- 原生高性能抓包工具Proxyman,送给爱学习的你
- 供应链的多目标协同决策
- 字符串和内存函数
- Merge_sort
- TCP protocol -- message format, connection establishment, reliable transmission, congestion control
- Press in and pop-up sequence of "Niuke | daily question" stack
- 09 eth smart contract
猜你喜欢

MySQL Foundation (II) -- MySQL Foundation

Huffman coding principle

深度学习——CV、CNN、RNN

快速排序(quick-sort)

Force buckle - 3. Longest substring without repeated characters

Delete ^m from VIM

String and memory functions

@ConstructorProperties注解理解以及其对应使用方式

The real epidemic situation in the United States, do not easily "bottom" 2020-03-23

C# 可以利用反射给只读属性赋值吗?
随机推荐
Download, installation and development environment construction of "harmonyos" deveco
shell编程
JS date details, string to date
C # use log4net plug-in to output logs to files
快速排序(quick-sort)
『HarmonyOS』探索HarmonyOS应用
Overview of image classification of vision transformer must read series
Force deduction 5: Longest palindrome substring
[graduation season _ advanced technology Er] farewell to yourself who has been confused for the past two years. Regroup, junior I'm coming
Valid bracket sequence of "Niuke | daily question"
Tiktok web s_ v_ web_ Analysis and implementation of ID parameter generation
深度学习——CV、CNN、RNN
Curve curvature display
Summary of common usage of dev treelist
An album has been released, from introductory practical demonstration to advanced live Q & A, playing with container service so easy~
Basis of multimodal semantic segmentation
C language introduction practice (8): switch case calculates the month, year and day of the next day (normal year / leap year calculation)
MySQL Foundation (II) -- MySQL Foundation
Map dictionary and constraints of go
dev treelist 常用用法小结