Seep mysql connections on horizon:work redis

107 views Asked by At

Laravel Version 9.52.4

PHP Version 8.2.4

Database Driver & Version MySQL 8.0.31

Description On horizon start, it start multiple processes (depends on number of queues), like artisan horizon:work redis --name=name --supervisor=foo --backoff=0 --max-time=0 --max-jobs=0 --memory=128 --queue=queueName --sleep=3 --timeout=60 --tries=1 --rest=0

With every this process, it create mysql connection with command = 'sleep'. When we have for example, 2 workers and 20 queues, it will be create 40 sleep connections.

Have you encountered this problem?

Steps To Reproduce

  • new Laravel project
  • queue with horizon
  • start horizon
  • start job

I tried to manually close DB connection, with catch after/failing/exception events:

Queue::after(function (JobProcessed $event) { DB::disconnect(); });

but it only decreased ~50%.

0

There are 0 answers