胡明 <[email protected]> wrote:
> I am trying to create a thread in Rails to subscribe a message channel of
> Redis. Is there a way to do this? I am using unicorn.

Theoretically, yes, similar things are done with other services.

<snip>

> But it will make the unicorn server unable to handle any web request. I
> thought that if I am using a different thread to subscribe to Redis, it
> won't block the main thread; am I missing something here?

I'm not familiar with Redis, but I know it's a server based on stream
sockets similar to anything else HTTP/IMAP/MySQL/Postgres/memcached-based.

But based on your observation, your client library is probably blocking
the entire Ruby VM by not releasing the GVL when it the thread waits on
Redis.

Which Redis client library are you using?

If the client library is written in C, it should have rb_thread_* calls
when it needs to wait on the server for anything (e.g.
rb_thread_call_without_gvl, rb_thread_fd_select, rb_thread_fd_select,
etc...).  If you don't see those in the source code, get it fixed :)

Reply via email to