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=-0.5 required=5.0 tests=AWL,MSGID_FROM_MTA_HEADER, RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.unicorn.general Subject: Re: Forking off the unicorn master process to create a background worker Date: Tue, 15 Jun 2010 15:14:26 -0700 Message-ID: <20100615221426.GA24854@dcvr.yhbt.net> References: <20100526210542.GC24211@dcvr.yhbt.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1276640080 10236 80.91.229.12 (15 Jun 2010 22:14:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 15 Jun 2010 22:14:40 +0000 (UTC) Cc: unicorn list To: Russell Branca Original-X-From: mongrel-unicorn-bounces@rubyforge.org Wed Jun 16 00:14:38 2010 Return-path: Envelope-to: gclrug-mongrel-unicorn@m.gmane.org X-Original-To: mongrel-unicorn@rubyforge.org Delivered-To: mongrel-unicorn@rubyforge.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-BeenThere: mongrel-unicorn@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: mongrel-unicorn-bounces@rubyforge.org Errors-To: mongrel-unicorn-bounces@rubyforge.org Xref: news.gmane.org gmane.comp.lang.ruby.unicorn.general:579 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OOeOy-0006RV-Aa for gclrug-mongrel-unicorn@m.gmane.org; Wed, 16 Jun 2010 00:14:36 +0200 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id BEF04185839E; Tue, 15 Jun 2010 18:14:34 -0400 (EDT) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id DC98418583A0 for ; Tue, 15 Jun 2010 18:14:26 -0400 (EDT) Received: from localhost (unknown [127.0.2.5]) by dcvr.yhbt.net (Postfix) with ESMTP id 2BBB31F516; Tue, 15 Jun 2010 22:14:26 +0000 (UTC) Russell Branca wrote: > Hello Eric, > > Sorry for the delayed response, with the combination of being sick and > heading out of town for a while, this project got put on the > backburner. I really appreciate your response and think its a clean > solution for what I'm trying to do. I've started back in getting the > job queue working this week, and will hopefully have a working > solution in the next day or two. A little more information about what > I'm doing, I'm trying to create a centralized resque job queue server > that each of the different applications can queue work into, so I'll > be using redis behind resque for storing jobs and what not, which > brings me an area I'm not sure of the best approach on. So when we hit > the job queue endpoint in the rack app, it spawns the new worker, and > then immediately returns the 200 ok started background job message, > which cuts off communication back to the job queue. My plan is to save > a status message of the result of the background task into redis, and > have resque check that to verify the task was successful. Is there a > better approach for returning the resulting status code with unicorn, > or is this a reasonable approach? Thanks again for your help. Hi Russell, please don't top post, thanks. If you already have a queue server (and presumably a standalone app processing the queue), I would probably forgo the background Unicorn worker entirely. Based on my ancient (mid-2000s) knowledge of user-facing web applications: the application should queue the job, return 200, and have HTML meta refresh to constantly reload the page every few seconds. Hitting the reload endpoint would check the database (Redis in this case) for completion, and return a new HTML page to stop the meta refresh loop. This means you're no longer keeping a single Unicorn worker idle and wasting it. Nowadays you could do it with long-polling on Rainbows!/Thin/Zbatery, too, but long-polling is less reliable for people switching between WiFi access points. The meta refresh method can be a waste of power/bandwidth on the client side if the background job takes a long time, though. I'm familiar at all with Resque or Redis, but I suspect other folks on this mailing list should be able to help you flesh out the details. -- Eric Wong _______________________________________________ Unicorn mailing list - mongrel-unicorn@rubyforge.org http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying