Question about javascript-php asynchronous video processing? Thank you for your guidance.

Source: Internet
Author: User
Requirement description: The Video Solution of Baidu cloud platform. the solution is to upload the video to your own server on the mobile phone, and then upload the video to your server on the Baidu server, now, when the php background is expected to complete user upload to its own server, return the user Upload success, and then upload it to Baidu server... requirement description:
Using the video solution of Baidu cloud platform, the solution is to first upload the video to your own server on the mobile phone end, and then upload the video from your own server to Baidu's server, now, we hope that the php background will return the user's upload success when the user uploads the file to its own server, and then upload the file to the Baidu server. The problem is that the PHP backend will return to the client only after all the execution is completed. It takes a long time to wait every time.

I don't know if you can give me some guidance? I am a beginner in php and have encountered many problems. thank you.

Reply content:

Requirement description:
Using the video solution of Baidu cloud platform, the solution is to first upload the video to your own server on the mobile phone end, and then upload the video from your own server to Baidu's server, now, we hope that the php background will return the user's upload success when the user uploads the file to its own server, and then upload the file to the Baidu server. The problem is that the PHP backend will return to the client only after all the execution is completed. It takes a long time to wait every time.

I don't know if you can give me some guidance? I am a beginner in php and have encountered many problems. thank you.

If your PHP service uses a PHP-FPM, you can open a dedicated process pool for processing video upload operations, the script uses fastcgi_finish_request to quickly respond to the user after completing the request, the execution of time-consuming Upload processing.


  

The PHP-FPM is not blocked during File upload because Nginx receives the uploaded content before being handed over to the PHP-FPM at a time.
The "upload from your own server to Baidu server" operation will block the occupation of a PHP-FPM working process.
In this case, you can create an upload process pool to handle this operation, so as to avoid blocking other scripts in the system.

Nginx. conf: upload. php scripts are all handled by listening to 9001 PHP-FPM process pool processing location =/upload. php {include fastcgi_params; fastcgi_pass 127.0.0.1: 9001; fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;} php-fpm: normal scripts are processed by the static www pool, the network blocking script is processed by the dynamic upload pool [www] listen = 127.0.0.1: 9000pm = staticpm. max_children = 4 [upload] listen = 127.0.0.1: 9001pm = dynamicpm. max_children = 8. start_servers = 4. min _spare_servers = 4. max_spare_servers = 4

You can use the queue. after the user passes the task, the user directly presses a task into the queue and then returns that the upload is complete. The system then executes a scheduled task to run the queue. There are several queue application forms.

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.