Skip to content

Instantly share code, notes, and snippets.

@deluvas
Last active September 13, 2020 02:25
Show Gist options
  • Save deluvas/3b5a1f0702fa41c89117 to your computer and use it in GitHub Desktop.
Save deluvas/3b5a1f0702fa41c89117 to your computer and use it in GitHub Desktop.
mod_fcgid notes

Notable parameters

  • FcgidMaxProcessesPerClass
    • Default: 100
    • Maximum amount of processes per application/website/wrapper.
  • FcgidProcessLifeTime
    • Default: 3600 seconds (0 disables check)
    • Idle processes which have existed for greater than this time will be terminated, if the number of processses for the class exceeds FcgidMinProcessesPerClass.
    • Working processes shall not be terminated.
    • This process lifetime check is performed at the frequency of the configured FcgidIdleScanInterval.
  • FcgidMaxRequestsPerProcess
    • Default: 0 (disables check).
    • FastCGI process will be terminated after handling the specified number of requests. See Accesses from server-status
  • FcgidMaxRequestLen
    • Default: 131072 bytes
    • If request body size exceeds limit - including uploads - FastCGI fails with 500 Server Error.
  • FcgidErrorScanInterval
    • Default: 3 seconds
    • Interval at which processes marked for termination are killed.
  • FcgidSpawnScoreUpLimit
    • Default: 10
    • Controls rate at which new processes spawn.

Errors

  • End of script output before headers: %s
    • CGI process ended abruptly/crashed etc.

Notes

  • PHP OPcache. The popular APC opcode cache for PHP cannot share a cache between PHP FastCGI processes unless PHP manages the child processes. Thus, the effectiveness of the cache is limited with mod_fcgid; concurrent PHP requests will use different opcode caches.

  • php_cgi.exe defaults to 500 requests per process. This can be changed via environment variable.

  • Timeouts. Processes that reach a certain timeout (IO/Busy/Idle) are marked for termination and are killed every FcgidErrorScanInterval seconds.

  • Process spawn rate. Initially, the application starts with 0 score. Each time a process is spawn, FcgidSpawnScore (default 1) is added to the score. When a process is terminated, FcgidTerminationScore (default 2) is added to the score. Every second, FcgidTimeScore (default 1) is substracted from the score. A process can be spawned if the current score is lower than FcgidSpawnScoreUpLimit.

  • Idling and FcgidMinRequestsPerClass. All application processes which have not handled a request for this period of time will be terminated, if the number of processses for the class exceeds FcgidMinProcessesPerClass.

Other relevant parameters

  • TimeOut
    • Default: 60 seconds
    • The TimeOut directive defines the length of time Apache httpd will wait for I/O in various circumstances:
      1. When reading data from the client, the length of time to wait for a TCP packet to arrive if the read buffer is empty.
      2. When writing data to the client, the length of time to wait for an acknowledgement of a packet if the send buffer is full.
      3. In (F)CGI, the length of time to wait for output from a CGI script.
      4. In mod_ext_filter, the length of time to wait for output from a filtering process.
      5. In mod_proxy, the default timeout value if ProxyTimeout is not configured.
@deluvas
Copy link
Author

deluvas commented Nov 14, 2015

FcgidMaxProcesses 500
FcgidMaxRequestsPerProcess 500
FcgidMaxProcessesPerClass 30
FcgidMinProcessesPerClass 15

FcgidSpawnScoreUpLimit 15
FcgidSpawnScore 0.5
FcgidTerminationScore 0.5

FcgidIdleScanInterval 30
FcgidBusyScanInterval 15
FcgidErrorScanInterval 1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment