How to configure the task configuration of swoole

the current server is the server of the 2-core 4GB
swoole construction. There are 600clients (will continue to increase)
the client sends a heartbeat to the server every minute, so it theoretically receives 600heartbeats at a time and throws them to task for logical processing.
the time taken by one of my processes is probably 200ms

document:

SWOOLE_CPU_NUMSWOOLE_CPU_NUM * 1000
1100ms1000QPS100

40M1004G
taskonTasktaskworkerworker

the biggest thing I can set is task_worker_num= > 4000?
1. Under what circumstances does the delivery capacity exceed the processing capacity? does it mean that the first 600 heartbeats have not been processed before the second heartbeat?
what does it mean that 2.task_max_request and max_request set the maximum number of tasks for a process? Will a new process continue to run after it automatically exits after exceeding the value? Whether all previous connections will be disconnected.

Jun.13,2022

in theory, you can set task_worker_num=2000 at the maximum, but this is impractical because memory and CUP energy resources are not unlimited. For a 2-core 4GB host, assuming that the available memory is 3G and each process occupies 30 MB of memory, then the number of processes that can be opened theoretically is 3000 4GB .

1 when the delivery capacity exceeds the processing capacity, does it mean that the first 600 heartbeats have not been processed before the second heartbeat?

Yes

when the task delivery speed exceeds the processing speed. According to your assumption, the time consumed by a process is about 200ms, then a process can handle 60000 code heartbeats per minute, that is, if there is only one process, the task delivery speed exceeds 300 / min even if the processing capacity is exceeded, both processes are the same

.

2 what does it mean that task_max_request and max_request set the maximum number of tasks for a process?

  • task_max_request A task process automatically exits after processing tasks that exceed this value, and then starts a new task process to continue processing
  • max_request the maximum number of tasks for the worker process. Default is 0. A worker process will automatically exit after processing tasks beyond this value

the above parameters differ in the task process and the worker process. After the value is exceeded, it will not exit until it has been processed.

in this case, you can start 4-6 task processes, then monitor the processing of task processes, and then adjust them up and down according to the situation.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b33503-2be9e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b33503-2be9e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?