dsyua2828 2014-12-13 05:35
浏览 46

管理每个用户的Beanstalkd队列

Let's say for arguments sake, I have a single SMTP server where I can send 60 emails per minute (1 per second).

If I have 60 users wanting to send emails through this SMTP server and they all send me 60 emails.

If I maintain 1 queue in Laravel, all 60 emails from user #1 will get sent first, then all 60 emails from user #2 will get sent next and so on. User #60 will have to wait for 3,540 emails to send before his starts.

I would like use Beanstalkd on a round-robin basis, and the only way I can think of doing this, is maintaining 60 tubes, one for each user but this would require me to run:

php artisan queue:listen --queue=user1,user2,user3,etc,user60

The problem I am facing here is that if user #61 signs up, his tube will not be picked up by the listener until I create a new command like so:

php artisan queue:listen --queue=user1,user2,user3,etc,user60,user61

If I grow to 1 million users, is it advisable to have 1 million tubes?

Is there any easy way to ask Beanstalkd to fetch 1 job per tube because these tubes can be created on the fly, I will never know how many tubes I have?

The problem I am facing is that I have a bottleneck on the SMTP server so I need to send these emails in a round robin fashion. I can achieve this easily using MySQL and Cron Jobs but this has led to duplicate emails in the past when using MySQL as a queueing system.

  • 写回答

1条回答 默认 最新

  • dpi10335 2014-12-13 21:36
    关注

    Short answer, you can try adding more workers, but if you have a funnel on the SMTP server, you only need to remember that you are replacing one problem with another.

    Client 1 has 60 emails
    Client 2 has 60 emails and so on ... until client 60
    

    Client 1 will only send the second email one minute later, thus it will take one hour to send 60 emails from client 1.

    You would be better served using a service such as Mandrill or Sendgrid, where you would have multiple servers sending the messages.

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算