title: Laravel queue lead to DB connections count overflow?
body: <p>I am using t2.medium (2 cores, 4GB RAM) AWS PostgreSQL RDS as database with Laravel as backend. The queue driver is database. I have just only 2k daily users. </p>
  
  <p>Yesterday, the system was down because of full connections count to DB without prediction. After investigating, I find out that the cause is queues. They 're spawned too much as database can consume.</p>
  
  <p>Here is my supervisord config:</p>
  
  <pre><code>[program:mydata-worker]
  command=php xxxxxx/artisan queue:work database --tries=5 --timeout=300
  process_name=%(program_name)s_%(process_num)02d
  autostart=true
  autorestart=true
  user=www-data
  numprocs=15
  </code></pre>
  
  <p>This query counts in <strong>1h</strong> , 66k queues are waiting here, but just 3k are consumed:</p>
  
  <p><a href="https://i.stack.imgur.com/BK8lv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BK8lv.png" alt="connsction overflows"></a></p>
  
  <p>This is in good condition, all queue are consumed
  <a href="https://i.stack.imgur.com/s71jL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s71jL.png" alt="normal_condition"></a></p>
  
  <p>The question here are : </p>
  
  <ol>
  <li>Does my supervisord.conf correct? Should I reduce '--tries=5' or 'numprocs' ?</li>
  <li>Is it safe if I drop 'jobs' table when the connections count reach the threshhold (100 for example) ?</li>
  <li>Can you guy give me a hint to design multi-thread safe servers?</li>
  </ol>