Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Redis Subscriber blocks thread/process?

$
0
0

I'm building a new API endpoint that uses Redis PUB/SUB to do a long polling; around 30seconds, however, I just realized that Redis.subscribe_with_timeout is blocking my thread.

Initially I only create one instance of Redis (Singleton) for my entire application and encountered the problem when I called Redis.publish in another endpoint (while the Subscriber is listening). According to Publish to redis is blocking my process, an alternative is to create a ConnectionPool but it seems that it would get a new connection for every Redis.subscribe_with_timeout commands.

I believe this would not work if there are multiple requests, say I initialized the connection pool to 10 and there are 10 requests as well at the same time which means I would not be able to do Redis.publish since all connections are already taken.

Any thoughts on other alternatives?

EDIT:

I don't think it actually blocks the thread, just that when I do Redis.subscriber it blocks any redis connections.


Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>