PHP Exec () and Python script features

I have a php application that executes Python scripts via exec () and cgi.

I have several pages that do this, and although I know that WSGI is the best way to go for the long term, I wonder if this is acceptable for small / medium traffic volumes.

I ask because several posts mentioned that Apache should spawn a new process for each instance of the Python interpreter that increases overhead, but I don’t know how significant this is for a smaller project.

Thanks.

+4
source share
1 answer

In the case of CGI, the server starts a copy of the PHP interpreter every time it receives a request. PHP in turn starts the Python process, which gets killed after exec (). There is a huge overhead for starting two processes and performing all import operations for each request.

In the case of FastCGI or WSGI, the server saves progressive processes (the minimum and maximum number of running processes are configured), so for the price of some memory you get rid of starting a new process every time. However, you still have to start / stop the Python process every time you call exec (). If you can use a Python application without exec (), for example, part of PHP for PHP in Python, this will greatly improve performance.

But, as you mentioned, this is a small project, so the only important criterion is that your current server can support the current load.

0
source

All Articles