unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: 胡明 <humings@gmail.com>
Cc: unicorn-public@bogomips.org
Subject: Re: Is it possible to create a thread in Rails subscribe to Redis message channel?
Date: Tue, 24 Mar 2015 22:44:35 +0000	[thread overview]
Message-ID: <20150324224435.GA21568@dcvr.yhbt.net> (raw)
In-Reply-To: <CALFpTnNDAb-T=yuAF7eizD0Yo_kDidfHoXew+EjUVu+UOwEpCQ@mail.gmail.com>

胡明 <humings@gmail.com> 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	other threads:[~2015-03-24 22:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-24 15:28 Is it possible to create a thread in Rails subscribe to Redis message channel? 胡明
2015-03-24 22:44 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150324224435.GA21568@dcvr.yhbt.net \
    --to=e@80x24.org \
    --cc=humings@gmail.com \
    --cc=unicorn-public@bogomips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).