I am connecting to an external service (ex. Algolia) from my PHP backend. Say, the external service takes a while to respond (ex. >1 sec). During that duration, the Apache process keeps waiting on it and is unable to complete the request.
Further incoming traffic on the website causes Apache to start forking more processes because the previously forked processes are still waiting for the request to be completed.
In the worst case, if I get too many simultaneous requests to the same URL which was invoking that external service, a lot of Apache processes go into waiting state ultimately causing the server CPU load to sky-rocket and the Ubuntu server to completely stop responding.
Is there a workaround for this problem?