Apache PHP server with time-consuming processes [closed]

1

I have an application that has some delayed requests, I would like to know if PHP how to set php to work with the best configuration possible, I would like to know if while it makes this request delayed I would be able to make a new request or it gets stuck ?

    
asked by anonymous 22.12.2016 / 10:51

2 answers

1

The Web server (Apache) does not get stuck while executing a request.

Apache has a default configuration that can serve multiple concurrent requests. It can do this by starting threads within each process and initiating new processes.

PHP, which is run by Apache, has many settings , and maybe you should explore each one to understand which ones can help you in your case. The "best" setting is difficult to know because each project has a different need.

However, like any program that runs on the server, depending on what it is doing, it can "hang" that process and a new request will be answered by another process. In Apache, because there may be multiple processes running, a time-consuming process will not prevent another from executing, but as the machine is one, depending on the type of operation you are doing, it will not be able to respond to requests in a timely manner. For example, if you have Apache and MySQL installed on the same machine and your PHP performs a complex query or does slow disk operations, the whole machine will be too loaded for Apache or any other process to run properly. >

Ideally, you should design your application not to run time-consuming processes within the Web server. In cases where time-consuming processes exist and can not be bypassed, your PHP script should pass to another application within the server that long task and the Web server would be released. That way, on the client side, you would have some page where you could monitor the progress of this long process, freeing the Web server to do the service of it, which is to meet the requests of other customers. The other way is to improve the configuration of the server machine or try to optimize your script / SQL queries that it executes to return the requests faster.

At the end there is no best-fit answer possible. It all depends on you understanding the settings and adjusting for your case. It's also worth investigating the reason for the time-consuming process.

    
22.12.2016 / 12:23
1

There is no such restriction, but it depends on your SO and hardware . Since your configuration uses PHP as a module of Apache , it is the Apache that is managing those connections, and it already manages multiple requests.

The concept of multitarefa is not related to PHP , but with the operating system and hardware . Multitasking, for example, requires a multi-core processor and SO that can use those cores for multiple concurrent executions.

The PHP runs to the configured memory limit. If your running script takes up all the reserved memory there the system creates a "run queue". Things like the ability of the connection link can also influence the result. These problems (latency, packet loss, etc.) are usually resolved with the carrier, and may be related to the contracted bandwidth limit.

In PHP , the general settings are made in php.ini , and the memory limit is changed in the memory_limit directive. Things like response time (% with%) and size limit for upload (% with%), (% with%) also influence the execution of scripts.

    
22.12.2016 / 12:15