ds1379551 2017-01-13 12:27
浏览 38
已采纳

在php进程中唯一分配队列的最佳方法

I have a set of unique values, and I want to give each request one of those.

Each value may only be distributed once. The order is not important. I'm looking for a good tool to do this.

I've been thinking about using MySQL with SELECT .. LIMIT 1 FOR UPDATE. Works, is there a way to select an unlocked row instead of waiting for the first lock the release?

I have tried using rabbitmq, registering each request as a consumer consuming just one message, but this method is slow. Taking almost a second over WAN.

  • 写回答

1条回答 默认 最新

  • dongzhanlu8890 2017-01-14 05:12
    关注

    from the comments

    there seems to be quite some delay when connecting [to RMQ]

    yes, there definitely is! in some cases, i've seen the connection take 5 to 10 second or more.

    but the way we are supposed to manage RabbitMQ is to have a single open connection per application instance - open it when the app instance starts, and leave it open forever.

    when we need to do work, create a channel on which to do the work.

    channels are cheap and very fast to open and close, unlike connections.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装
  • ¥40 复杂的限制性的商函数处理