Php calls python at a low speed

Source: Internet
Author: User
Tags what php
When using php to call a python program to process data, it is found that the speed is too slow. It takes about 1 m40s to run. However, it takes about five seconds to run the python program directly on the server. The results of the two are the same. It is really unclear why php takes such a long time to process data... It is found that the speed is too slow when the python program is called through php. It takes about 1 m40s to run. However, it takes about five seconds to run the python program directly on the server.

The results of the two are the same. It is really unclear why php is used for such a long time. Try to call python asynchronously, that is, the PHP file contains the following code:


   result.json &');?>

The same result is true, but it is still slow. Does anyone know how to do this, or how to find out what php is doing?

To answer this question, it still does not solve the problem of slow python calling.

But the key to finding the problem is that a file of 80 + mb is read in the python program. The solution is to split the file into small files and access only the desired file each time, so that you do not need to read all the information.

This operation speed is acceptable. Does anyone know why it is slow to open large files using php to call python?

Reply content:

When using php to call a python program to process data, it is found that the speed is too slow. It takes about 1 m40s to run. However, it takes about five seconds to run the python program directly on the server.

The results of the two are the same. It is really unclear why php is used for such a long time. Try to call python asynchronously, that is, the PHP file contains the following code:


   result.json &');?>

The same result is true, but it is still slow. Does anyone know how to do this, or how to find out what php is doing?

To answer this question, it still does not solve the problem of slow python calling.

But the key to finding the problem is that a file of 80 + mb is read in the python program. The solution is to split the file into small files and access only the desired file each time, so that you do not need to read all the information.

This operation speed is acceptable. Does anyone know why it is slow to open large files using php to call python?

Is it asynchronous? How do I rememberPHPAll are synchronized...

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.