2

I am creating a Laravel 4.2 app with MySQL database on NGINX. I am trying to research options to reduce CPU usage at any given time using queues.

I would like any queued task to stay under a certain level of memory usage;

but what I do not understand is what actually happens if the task being run exceeds that limit set by the --memory parameter of php artisan queue:listen (or work ).

If I run

php artisan -h queue:work

in my dev terminal, it simply defines

The memory limit in megabytes (default: 128)

but it does not say what will happen if that task tries to break that limit.

2 different things I think may happen:

1) it will cause the queue to fail and end up on my failed queues table

2) it will somehow just throttle the amount of processing power from the server to accomplish the task

I am hoping it is number 2; am I correct?

Douglas.Sesar
  • 4,214
  • 3
  • 29
  • 36

1 Answers1

4

No. It can't do any magic to change your code. What it will do is safely exit the task when it has completed, and allow it to be restarted with a fresh worker.

Normally, you would run command line tasks with memory_limit = -1 (as much as it needs) - which can be useful, but you also need to be able to recover that for other processes to be able to use it.

See: \Illuminate\Queue\Listener::runProcess(Process $process, $memory);

Alister Bulman
  • 34,482
  • 9
  • 71
  • 110