Cookies ahead

Our support chat tool "Intercom" would like to collect some more data on you. See the related link for more details.

Docs

Out of memory

Published

Reviewedbyfl

💥

Out of memory, out of process.

When the processes of an environment need more memory than the plan provides, the system kills one of them to free memory. That is an OOM kill, short for out of memory. It shows up in the dashboard metrics for PHP and for jobs.

About OOM kills

Each PHP or jobs plan comes with a fixed amount of memory, shared by all its processes. A single process can stay within the PHP memory_limit and still push the total over the plan. Then a process gets killed. The healthy number of OOM kills is zero.

The metrics show both sides: memory use against the plan sizes, and the kills that follow.

PHP

A killed PHP process ends the request it was handling, and the visitor gets an error page. Kills often line up with 503 errors.

  • Single kills usually come from one heavy request, such as an export or an image upload.
  • Repeated kills at busy times mean too many processes for the memory of the plan.
  • Memory that is high while PHP requests are low points to code that loads too much at once: large result sets, images processed in memory.

Find the peak in the PHP memory metric, then read the logs for the requests at that time. PHP processes explains how processes share memory.

Jobs

A killed worker or cron stops mid-job. Depending on the queue, the job is retried, lost, or left half done.

  • Kills at fixed times point to a cron.
  • Memory that climbs steadily and only drops on a restart points to a leak in a worker: each processed job leaves something behind.

Restart workers after a number of jobs or at a memory limit. Most queue libraries have an option for it. Process large data sets in batches. See tune jobs.

Fix or scale

Fix the code first: a request or job that loads less needs less memory on any plan. Scale the PHP or Jobs component when the memory use is legitimate.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗