PHP for Batch Task processing no timeout solution _php tips

Source: Internet
Author: User
Tags php database

This article analyzes the solution of PHP's batch task processing without timeout. Share to everyone for your reference, specific as follows:

PHP Bulk Task Processing

PHP in the batch processing tasks will time out, in fact, the solution is very simple, is to split the task, a part of the processing, task progress can be placed on the server can also be placed on the client, not very complex words on the client, with JS to deal with it.

Client JS callback Processing

Client processing needs to live in a place, is the use of AJAX processing, Ajax is asynchronous, the use of a For loop processing is only a batch request, such a large number of tasks will be directly DDoS server, so you need to wait for the callback function to return, and then make the next request.

Client Example

File: index.html

<! DOCTYPE html>  

Example server example for processing batch tasks in PHP

File: do.php

<?php Sleep
(3);
if ($_post["id"] = = 5) {
 http_response_code);
 Exit ();
}
echo Json_encode ($_post);

For more information about PHP interested readers can view the site topics: "PHP string (String) Usage summary", "PHP array Operation techniques Encyclopedia", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP basic grammar Introductory Course" , "PHP Operation Office Document Skills Summary (including word,excel,access,ppt)", "PHP date and Time usage summary", "PHP object-oriented Programming Introductory Course", "Php+mysql database operation Introductory Course" and " A summary of common PHP database operations tips

I hope this article will help you with the PHP program design.

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.