From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.229.70.129 with SMTP id d1cs167130qcj; Tue, 7 Jun 2011 11:23:23 -0700 (PDT) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncCP_V2_zRBRD0u7nvBBoELlbm9A@googlegroups.com designates 10.68.57.199 as permitted sender) client-ip=10.68.57.199; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncCP_V2_zRBRD0u7nvBBoELlbm9A@googlegroups.com designates 10.68.57.199 as permitted sender) smtp.mail=rack-devel+bncCP_V2_zRBRD0u7nvBBoELlbm9A@googlegroups.com; dkim=pass header.i=rack-devel+bncCP_V2_zRBRD0u7nvBBoELlbm9A@googlegroups.com Received: from mr.google.com ([10.68.57.199]) by 10.68.57.199 with SMTP id k7mr287817pbq.25.1307471001670 (num_hops = 1); Tue, 07 Jun 2011 11:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:x-beenthere:received-spf:mime-version:subject :from:in-reply-to:date:message-id:references:to:x-mailer :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-google-group-id:list-post :list-help:list-archive:sender:list-subscribe:list-unsubscribe :content-type:content-transfer-encoding; bh=gBgCKbxVJJFB8oet0DErjeeAyADix5CNU2B7MfRspJk=; b=xXFDUc0iDoPQ8uwnDJXibwwTDTgY4hu9nuXFvLgt/BC0mjCWtq79b/o0tjL3MAo5NY ogBlxto9hNEONkp2bH5LuHbLSrZAHONq8jLk1frv7ab3WL3Q4x9/MkIlXelkXiaF6BR+ KbpSVQ96Du91IBufNScRoDvH3z0Ft07XjTxt8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:mime-version:subject:from:in-reply-to:date :message-id:references:to:x-mailer:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type :content-transfer-encoding; b=jR9Iz7zALJ2fXABEnw8FW/rR17q+O4RcWycJy0tNGqEoQnHShZLVqfR+TAvR1vGQed 2ADYZbTFvqYJBnh25RXqtZs8TLhDhn3kS32tvL7uD+RQsDoHXX+sENt81jrW29JJOG/Y KhWIBzPFHQf4hJo0SRgP4YAB1qtTk1unqIOhs= Received: by 10.68.57.199 with SMTP id k7mr74314pbq.25.1307467252212; Tue, 07 Jun 2011 10:20:52 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.68.36.67 with SMTP id o3ls1958066pbj.0.gmail; Tue, 07 Jun 2011 10:20:51 -0700 (PDT) Received: by 10.68.68.100 with SMTP id v4mr69348pbt.6.1307467251065; Tue, 07 Jun 2011 10:20:51 -0700 (PDT) Received: by 10.68.68.100 with SMTP id v4mr69347pbt.6.1307467251051; Tue, 07 Jun 2011 10:20:51 -0700 (PDT) Received: from mail-pw0-f47.google.com (mail-pw0-f47.google.com [209.85.160.47]) by gmr-mx.google.com with ESMTPS id c10si14243086pbn.1.2011.06.07.10.20.51 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Jun 2011 10:20:51 -0700 (PDT) Received-SPF: pass (google.com: domain of jftucker@gmail.com designates 209.85.160.47 as permitted sender) client-ip=209.85.160.47; Received: by pwj9 with SMTP id 9so2984959pwj.6 for ; Tue, 07 Jun 2011 10:20:51 -0700 (PDT) Received: by 10.68.41.40 with SMTP id c8mr278885pbl.406.1307467250133; Tue, 07 Jun 2011 10:20:50 -0700 (PDT) Received: from [192.168.3.56] (70-35-55-162.static.wiline.com [70.35.55.162]) by mx.google.com with ESMTPS id c5sm267279pbj.89.2011.06.07.10.20.48 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Jun 2011 10:20:48 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: Middleware and post-request processing From: James Tucker In-Reply-To: <2cac8438-1819-4887-bce9-9a99578539db@f31g2000pri.googlegroups.com> Date: Tue, 7 Jun 2011 10:20:46 -0700 Message-Id: References: <2cac8438-1819-4887-bce9-9a99578539db@f31g2000pri.googlegroups.com> To: rack-devel@googlegroups.com X-Mailer: Apple Mail (2.1084) X-Original-Sender: jftucker@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jftucker@gmail.com designates 209.85.160.47 as permitted sender) smtp.mail=jftucker@gmail.com; dkim=pass (test mode) header.i=@gmail.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable On Jun 3, 2011, at 4:23 PM, ghazel wrote: > It seems to me that Rack is in need of a new post-response stage of > processing. This stage would occur after the response is fully written > and the client is unblocked, and before the next request is processed. >=20 > Similar to what OobGC ( = http://bogomips.org/unicorn.git/tree/lib/unicorn/oob_gc.rb#n59 > ) accomplishes, it is sometimes useful to perform additional > operations after the response is written without blocking the client. > For example, the Oink middleware logs statistics about the request, > but blocks the response since it has no ability not to: ( > = https://github.com/noahd1/oink/blob/4158d71bc9150f011072b2c6eefe73c720a78d= 46/lib/oink/middleware.rb#L16 > ). This processing takes time, and needlessly delays the response. >=20 > This proposal would entail something like a single function which is > called on each middleware after the response is written to the client > and the socket is closed (depending on the server implementation). For > servers which have no ability to not block the client or delay further > requests the function should still be called, and the impact would be > similar to the behavior today. >=20 > Thoughts? The problem is, this isn't simple. Different servers have different = scheduling mechanisms, and deferred operations specifications reach into = scheduling in a horrible way. Should these run linearly? Should they be able to be pooled if = env['rack.multithreaded']. In that case should they receive the same = number of workers as the main request/response pool? Should they work = out of the same pool? And that's just some basics with threads... You can quite easily handle this on your own in middleware or servers a = number of ways today, without introducing either far reaching / = extensive specs or incomplete restrictions that parallel some we already = have (like stack based control).=