Minimize memory consumption: Managing excessive Jenkins logs

Edit on GitHub

The excessive accumulation of logs in a Jenkins instance, particularly the substantial volume of stdout and stderr logs generated by numerous job executions, can lead to performance degradation. Without proper log management strategies, these logs can quickly accumulate, overwhelming the Jenkins server’s memory and disk space. This can lead to performance degradation, causing Jenkins to become slow and unresponsive, especially during peak usage periods.

usage-diagram

To address this problem, take the following steps:

  1. Determine the source of log generation:
    1. Examine Jenkins logs to identify jobs and builds with significant log generation.
    2. Analyze build scripts to identify and eliminate unnecessary log generation.
  2. Mute Jenkins from receiving logs if needed:
    1. To disable child process logging, override \Spryker\Zed\Queue\Business\Process\ProcessManager::triggerQueueProcess() on the project level:
...
if (!$this->queueConfig->getQueueWorkerLogStatus()) {
    $process->disableOutput();
}
...
  1. To add forwarding for stderr, override \Spryker\Zed\Queue\Business\Worker\Worker::executeOperation() on the project level:
if ($this->queueConfig->getQueueWorkerLogStatus()) {
    $processCommand = sprintf('%s >> %s 2>&1', $processCommand, $this->queueConfig->getQueueWorkerOutputFileName());
}