From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: * X-Spam-ASN: AS14383 205.234.109.0/24 X-Spam-Status: No, score=1.0 required=3.0 tests=HK_RANDOM_FROM, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=no version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: Re: Single Threaded Async Responses Date: Mon, 5 Oct 2009 15:56:33 -0700 Message-ID: <20091005225633.GA23138@dcvr.yhbt.net> References: <0956CE27-14FE-42DF-BAD9-CED31B09D85D@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1254783406 20731 80.91.229.12 (5 Oct 2009 22:56:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Oct 2009 22:56:46 +0000 (UTC) Cc: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org To: James Tucker Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Tue Oct 06 00:56:37 2009 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Content-Disposition: inline In-Reply-To: <0956CE27-14FE-42DF-BAD9-CED31B09D85D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:3 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1MuwTs-0001FI-PP for gclrrg-rainbows-talk@m.gmane.org; Tue, 06 Oct 2009 00:56:37 +0200 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 3CA7C16782B8; Mon, 5 Oct 2009 18:56:36 -0400 (EDT) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id 7F3A916782B8 for ; Mon, 5 Oct 2009 18:56:34 -0400 (EDT) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPSA id BB6761F5F3; Mon, 5 Oct 2009 22:56:33 +0000 (UTC) James Tucker wrote: > Hi Eric and anyone else listening in, > > I completed an async API for Thin quite some time ago well suited to > some of the design goals you have here. If you're interested we could > have a chat about supporting the same API designs that allow single > threaded reactor based concurrent responses. I believe such an API would > fit well in rainbows too. Hi James, This sounds interesting. Does this mean it does synchronous request reading? That'll mean it requires nginx in front to work well. So the response is written asynchronously, meaning it can be bigger than the outgoing TCP buffers and still not block, right? I considered something like this for Unicorn, too, but then I realised that all the responses I see managed to fit into the TCP buffers without blocking already. But for weird OSes with tiny buffers or apps dealing with large responses it would probably make sense for Rainbows! (especially if you plan to help me support it into the future :) Is it merged into Thin already? Where can/should I take a look? One bit to be careful for is the body of the Rack response may not be a simple Array of String objects, so that requires extra effort/cycles to stringify into something that can be buffered for async writes. But then that could be a huge chunk to keep around in memory (since we mainly need this to support larger responses). What nginx does is it will buffer into a temporary file and then sendfile() it over as the socket becomes readable. -- Eric Wong