Received: by 10.204.5.194 with SMTP id 2mr172584bkw.7.1349978917657; Thu, 11 Oct 2012 11:08:37 -0700 (PDT) X-BeenThere: erlang-programming@googlegroups.com Received: by 10.204.151.24 with SMTP id a24ls2406527bkw.1.gmail; Thu, 11 Oct 2012 11:08:37 -0700 (PDT) Received: by 10.204.145.140 with SMTP id d12mr173047bkv.6.1349978917381; Thu, 11 Oct 2012 11:08:37 -0700 (PDT) Received: by 10.204.145.140 with SMTP id d12mr173046bkv.6.1349978917361; Thu, 11 Oct 2012 11:08:37 -0700 (PDT) Return-Path: Received: from hades.cslab.ericsson.net (hades.cslab.ericsson.net. [192.121.151.104]) by gmr-mx.google.com with ESMTP id k7si629113bks.2.2012.10.11.11.08.37; Thu, 11 Oct 2012 11:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) client-ip=192.121.151.104; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) smtp.mail=erlang-questions-boun...@erlang.org; dkim=neutral (body hash did not verify) header...@gmail.com Received: from hades.cslab.ericsson.net (hades [192.121.151.104]) by hades.cslab.ericsson.net (Postfix) with ESMTP id 05DD95C034; Thu, 11 Oct 2012 20:08:30 +0200 (CEST) X-Original-To: erlang-questi...@erlang.org Delivered-To: erlang-questi...@erlang.org Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com [209.85.160.53]) by hades.cslab.ericsson.net (Postfix) with ESMTP id BBE195C005 for ; Thu, 11 Oct 2012 20:08:27 +0200 (CEST) Received: by mail-pb0-f53.google.com with SMTP id wz12so2374450pbc.40 for ; Thu, 11 Oct 2012 11:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=rNt1ZnQ4eCxHYBk1FATKDqavzxWGxMBqm6DKN6BFYyU=; b=u8PPHPOGeamM0iOlhBGGFc8Ld/2mncrxDyfpsqshWkn1NHD9NNIp7t6yTN/0Fjr3nn foD/ijX5ZqvhjoBXIrqO6RrEBkcSDICUN05yqzhx/5UNZIQ0sm2P96bNrImOe/mP1Ssd bhkreZ3jxOF0D19tbjufWcn0mWMyYyYTobqPwJLV4Un1TF3hiMVnLunWkKkbBTFIgQmF dfm0AOlB4w/+8Pygq95k66EuaqPff34nZxV52TYhj5jyzwuvh+123onE/vmKKYhxO5TR cOajYnoCOh/vpRNOnRK6oMaZxNxdr0RAAr08VEx7xf1UUNKeZW0KOGGICUCT7wxxfIpA EdFw== MIME-Version: 1.0 Received: by 10.66.81.103 with SMTP id z7mr4221793pax.57.1349978906531; Thu, 11 Oct 2012 11:08:26 -0700 (PDT) Received: by 10.68.48.228 with HTTP; Thu, 11 Oct 2012 11:08:26 -0700 (PDT) In-Reply-To: <022F4CD3-4A8F-4B38-8A5B-41A484B00...@gmail.com> References: <022F4CD3-4A8F-4B38-8A5B-41A484B00...@gmail.com> Date: Thu, 11 Oct 2012 20:08:26 +0200 Message-ID: From: Joe Armstrong To: Eric Newhuis Cc: erlang-questi...@erlang.org Subject: Re: [erlang-questions] Bounded Buffer Problems/Solutions X-BeenThere: erlang-questi...@erlang.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Erlang/OTP discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: erlang-questions-boun...@erlang.org Sender: erlang-questions-boun...@erlang.org On Wed, Oct 10, 2012 at 9:37 PM, Eric Newhuis wrote: > What are the generally accepted solutions for when producers need to be throttled? gen_server as consumer or otherwise? > > Are there any good solutions or philosophy for the bounded buffer problem in Erlang? ..flow control? Freaky out-of-band communication at a distance to limit messages sent? Use the idea of rope: Message in reverse to a producer shim that he is allowed to send N more messages before he needs to ask for the right to send more? Other? Actually no - we noticed years ago (round 1990) that if producers ran faster than consumers you got a problem. So it this case we made everything synchronous. Send a message, wait for a reply ad nauseam. This is used in gen_servers and virtually everywhere. It doesn't seem to matter I guess if the CPU is always busy we're happy bunnies. Ok so you wait a bit longer, bit something else gets done while you're waiting. Now you could (say) require an ack after every ten messages - and send up to ten messages without requiring an ack or something but things actually go surprisingly well without this ... > > Are there common Erlang idioms for monitoring execution time at the gen_server level so that an API can respond upward with a policy of "the system is currently busier than a one legged man in a kicking contest?" No - easy to implement though. My approach has always been take the simplest solution that works - then measure and only fix things if they are broken. So we've built massive systems with synchronous client server RPCs all over the place then we tune them - most often it's the time to parse inputs or the database that's the problem. Getting data in and out of the system and computation seem to be the problem areas the interprocess message passing is very fast compared to this - so complex buffering seems not to be necessary. I'm not saying you never need it - just that I've never seen it myself. Cheers /Joe > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@erlang.org > http://erlang.org/mailman/listinfo/erlang-questions _______________________________________________ erlang-questions mailing list erlang-questi...@erlang.org http://erlang.org/mailman/listinfo/erlang-questions