Queue problems for mass SMS and group email

Source: Internet
Author: User
Tags rabbitmq
Recently to do mass SMS and Group E-mail program, because some restrictions, are many times to request a response to the interface, to reach the effect of mass.

Then there is the problem: I need to send 100 customers email, interface response time averaged at 2s, then my php needs to do 100 post operation, up to 200s, and then the page timed out ...

How do I fix this problem without changing the PHP settings?

I can think of two scenarios myself:

    1. Each post one, and then the page jumps, like some of the domestic open source programs to generate static pages, each time only make a small request, such as 10s can complete five times post, and then jump to the new page, incoming start=10 start=15 such parameters, constantly jump jump refresh refresh, Finish the task at last. The disadvantage is that this requires the client to always keep the browser ...
    2. The task of sending a message exists in the database, do a send.php, such as a file, each time to take one or several messages to send, and then use Crond or scheduled tasks per second line send.php Check if there is a new task, some words to perform the task.

I want to know if there is any other simple way, such as I have heard of rabbitmq or something, but did not understand ...

Reply content:

Recently to do mass SMS and Group E-mail program, because some restrictions, are many times to request a response to the interface, to reach the effect of mass.

Then there is the problem: I need to send 100 customers email, interface response time averaged at 2s, then my php needs to do 100 post operation, up to 200s, and then the page timed out ...

How do I fix this problem without changing the PHP settings?

I can think of two scenarios myself:

    1. Each post one, and then the page jumps, like some of the domestic open source programs to generate static pages, each time only make a small request, such as 10s can complete five times post, and then jump to the new page, incoming start=10 start=15 such parameters, constantly jump jump refresh refresh, Finish the task at last. The disadvantage is that this requires the client to always keep the browser ...
    2. The task of sending a message exists in the database, do a send.php, such as a file, each time to take one or several messages to send, and then use Crond or scheduled tasks per second line send.php Check if there is a new task, some words to perform the task.

I want to know if there is any other simple way, such as I have heard of rabbitmq or something, but did not understand ...

In the background task execution is a good way, should also be the best method, do not need RABBITMQ, this will only complicate the problem. But there is actually a way to make your PHP does not time out, even if the user's browser connection is broken, it will continue to execute, it is in your PHP file at the beginning of the first add the following two lines

Ignore_user_abort (True); Set_time_limit (0);

RABBITMQ is similar to the second scenario that you provide, the only difference is that your solution needs to scan the task table continuously, the load will be high, the efficiency is low when the data volume is large.
The use of RABBITMQ words is to have the task you deal with, is often said message-driven. Message-driven technology is common in programs that require asynchronous processing. belong to an efficient solution. You can separate out a task system, specifically to handle the need for asynchronous processing of relatively time-consuming business, such as the sending of mail, documents, video conversion, image processing and so on. The solution is very clear and simple.
Hope to bring you a reference.

That's what I'm doing now. In other languages, such as:. NET writes a mail queue service. Then PHP uses the socket to post but does not wait. The rest of the matter is given. NET to do it over there.

The factors to consider are:
1. Is the timeliness of the requirements high?
2. What happens when a mass EMAIL is triggered?

Scenario One: The request is collected first, each page request processing a request, distributed processing , suitable for general Web applications, not clear about your situation, if each page request will need to trigger the action of mass EMAIL ...;

Scenario Two: If the timeliness of the request is not high, you can system tools such as Cron, the first to collect the request for storage, write a processing request script, in the early hours of the server load is not high when the use of cron to execute this script.

In 2 of the scheme, if the volume is not a problem,
If the volume is large, still need to consider based on Message Queuing (Mq,redis), in the background of multiple consumption program consumption (send)
We system millions of text messages every day to send the basic is to do so!

  • 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.