Question about queue in mysql-php?

Source: Internet
Author: User
Php is a single process, right? Every script execution is independent of each other. What is the concept of multi-process? I have a question in this article www.thinkphp.cntopic14728.html: the multi-process execution queue can speed up task processing, but the problem that needs to be solved... php is a single process, right? Every script execution is independent of each other,

What is multi-process?

I have read this article at http://www.thinkphp1.cn/topic/14728.html:
He said that multi-process execution queues can speed up task processing, but the problem to be solved is that multi-process processing tasks should prevent repeated processing,:

if ($minute % 5 == 0){    for ($i=0; $i < 10; $i++) {         $cmd = "$phpcmd doQueue.php 10 $i>> doQueueMission".date('Y-m-d').".log  ";        echo  date("Y-m-d H:i:s") . "t : " .$cmd."n";        system($cmd);    }}

This scheduled task, crontab, executes system () for ten times. This is not a multi-process task, or a parallel task. It makes no sense.
Should multiple processes configure crontab? However, the real difficulty is that the "tag queue" does not allow repeated execution.

Recently, it seems like the most queue, which solves the problem of slow delivery of messages, such as placing orders, registering messages, and sending messages. The queue is very difficult. Here are the summary points:
1: Where are tasks stored?
2: Background Daemon Configuration
3: multi-process and timing of daemon
4: prevent multiple processes from repeatedly pulling queue tasks for execution (3, 4 is the most difficult point)

Are there any mature queue cases?

Reply content:

Php is a single process, right? Every script execution is independent of each other,

What is multi-process?

I have read this article at http://www.thinkphp1.cn/topic/14728.html:
He said that multi-process execution queues can speed up task processing, but the problem to be solved is that multi-process processing tasks should prevent repeated processing,:

if ($minute % 5 == 0){    for ($i=0; $i < 10; $i++) {         $cmd = "$phpcmd doQueue.php 10 $i>> doQueueMission".date('Y-m-d').".log  ";        echo  date("Y-m-d H:i:s") . "t : " .$cmd."n";        system($cmd);    }}

This scheduled task, crontab, executes system () for ten times. This is not a multi-process task, or a parallel task. It makes no sense.
Should multiple processes configure crontab? However, the real difficulty is that the "tag queue" does not allow repeated execution.

Recently, it seems like the most queue, which solves the problem of slow delivery of messages, such as placing orders, registering messages, and sending messages. The queue is very difficult. Here are the summary points:
1: Where are tasks stored?
2: Background Daemon Configuration
3: multi-process and timing of daemon
4: prevent multiple processes from repeatedly pulling queue tasks for execution (3, 4 is the most difficult point)

Are there any mature queue cases?

Https://github.com/chrisboulton/php-resque

It is said that system () will start a new process, so it makes sense to execute system () multiple times in a loop.

He said that multi-process execution queues can speed up task processing, but the problem to be solved is that multi-process processing tasks should prevent repeated processing.
The difficulty is that "tag queue" does not allow repeated execution

These are all correct.

Theoretically, any data storage method can be used as MessageQueue. For example, disk files, such as Mysql.
However, a better choice is to use specialized MQ software, such as ActiveMQ and RabbitMQ.... There are many similar software. You can understand the subject.

Php's multi-process has nothing to do with crontab, because if you do not use php's sub-process, it is serial. The pcntl_fork () function uses sub-process.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.