Closed nateless closed 9 years ago
It should be fine to share a connection. No need to create a channel per message published (that's a network round trip with a lock), so as long as the channel is open, just use it (one channel per thread — never share channels).
Is it safe to reuse our global connection or its better to open a new one for each client?
See above. Unless you have specific reasons, start with using just 1 connection.
We'd appreciate if questions were directed to ruby-amqp
and rabbitmq-users
Google groups in the future. Thank you.
Hello,
I think that's not the right place to ask questions, however I couldn't find answers in documentation. And they are too specific for stackoverflow.
We've been using redis's pubsub in a threaded environment. It's a very concurrent app with high load, hundreds users online connected with websocket, each user runs new threads to get realtime updates. However app started to freeze randomly, with threads leaking and deadlocks, while we investigate it and discuss in redis-rb, I've decided to switch redis to something more stable like RabbitMQ and bunny.
However I've few questions regarding thread-safety.
channel = $rabbit.create_channel
channel or it's better to create a new one for each method call? Also should we close channels and exchangers after usage? Considering its a websocket app which has a long run, user can call#stats
method hundreds of times under one connection.psubscribe
blocks the thread and it goes to deadlock by some reason we haven't figured out yet. Is it safe to reuse our global connection or its better to open a new one for each client?