How to Fix mod_fcgid: can’t apply process slot PHP Error

How to Fix mod_fcgid: can’t apply process slot PHP Error

Last Updated February 14, 2022 · Web Development

Recently, one of our clients with a slightly legacy application began having a lot of memory issues. Over time, this application has grown in size and scope and it seemed like we were hitting some memory limits. Several times a day the PHP error log was filling up with “mod_fcgid: can’t apply process slot” messages. A quick server restart would get things back to normal but, hours later, the errors would return and the application would begin to lock up.

The application runs on a virtual private server (VPS) from a very popular hosting company. We were therefore limited by what we could and couldn’t do to solve this issue. Initially, it was recommended that we split some of the application’s processes up between multiple users. This wasn’t the final solution but, in the end, we did take that advice to improve performance elsewhere. In the end, the problem was identified as an issue caused by our use of FastCGI.

What is CGI and FastCGI?

In short, CGI (Common Gateway Interface) is a means for a web server to use an external application. In this case, that external software is PHP which is the language used for the application in question. FastCGI is a newer version of CGI built with performance in mind. FastCGI is a complicated piece of technology but the idea is that FastCGI starts a process that lives longer than one created with CGI. The intention is to reduce server load.

Figuring Out Our FastCGI Problem

The hosting company recommends all applications and websites use FastCGI. Until we began having issues, that is what we chose to do. This ended up being our problem. FastCGI has a number of settings that you can customize to increase performance. Unfortunately, our hosting provider wasn’t capable of changing those for us. In particular, we were looking to adjust the following settings:

Our research indicated what common, default settings for these fields were. Unfortunately, the hosting provider had these values very low. They were unable to adjust them for us at all. One of the risks of using a third-party server provider is you are at their mercy on occasion. This was one of those times.

In general, we prefer to use third-party hosts for our applications. Rarely do we spin up our own servers. Managed hosting, while it has drawbacks like this situation, is often more cost-effective for our clients.

Fixing mod_fcgid: can’t apply process slot Errors

In the end, the simplest solution is often the best. We switched the application back to using normal CGI and the errors and memory issues went away. In addition, some of our other performance-related problems solve themselves as well.

With more server control, we could have solved this issue on our own. Bumping up the values of FcgidMaxProcesses and FcgidMaxProcessesPerClass would have probably sorted this issue out. If you are in a similar situation, running FastCGI with “mod_fcgid: can’t apply process slot” errors then we recommend switching to regular CGI.

Do you have some questions about this FastCGI issue? Let us know and we might be able to lend a hand. Link Software has been web-based applications from scratch and supported legacy applications.

  • This field is for validation purposes and should be left unchanged.