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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.