Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8271A2009F3 for ; Sat, 4 Jun 2016 15:14:59 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 75FD6160A26; Sat, 4 Jun 2016 13:14:59 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B8B57160A1E for ; Sat, 4 Jun 2016 15:14:58 +0200 (CEST) Received: (qmail 11599 invoked by uid 500); 4 Jun 2016 13:14:57 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 11587 invoked by uid 99); 4 Jun 2016 13:14:57 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Jun 2016 13:14:57 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 1F53BC1690 for ; Sat, 4 Jun 2016 13:14:57 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.802 X-Spam-Level: X-Spam-Status: No, score=-0.802 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id qfG_0CBu6Ygr for ; Sat, 4 Jun 2016 13:14:56 +0000 (UTC) Received: from mail-io0-f176.google.com (mail-io0-f176.google.com [209.85.223.176]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 041535F477 for ; Sat, 4 Jun 2016 13:14:55 +0000 (UTC) Received: by mail-io0-f176.google.com with SMTP id o189so94739517ioe.2 for ; Sat, 04 Jun 2016 06:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=Bx9Z9BTxSQ4/jCy4kSelV2eLrcPedqa/GLfnZ6jt9kc=; b=K+30kLu41jIqk3Fme8gKloNHYJz7vMttebqMO3CfdW4i1mUO/y2khqcaITc5c1hbVi xb3JM4yzCeDnk7DPXcw1Vjafnge1DDFRNH2GESVLsiYrhPpyBRA2ZmTxBSJ1T9H9OHNq ZPfwotVO464MFNgMJnRo/+hCEgg8Fh+dCIYEAkx+pwD8FIuNj3GrlfrPn81omYu8HQBV G4ocwOSR1TD7lasG7xisu7yWNCg1siCvR4UnJL57m9yHDnG7FoHnWXYcvqIVCOYh3dUb +9SCYCjcP6KMahE/xbc9yR8zs4pnZQnJqaMlVbYZ30S0wSOQzBjKl60snU5BvR2byQGR pGcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=Bx9Z9BTxSQ4/jCy4kSelV2eLrcPedqa/GLfnZ6jt9kc=; b=kj2dt77p1GWwdmZw6jA1tSsZXjKUicPWLjannWRGeHd8jTtU18QAawJxkkDz+2fIQF zRuje81vfmC3eky5iTOP2HHQXsnQ+kc7FZDBdYtjP0k7WO/irfYof2TjU4eVT3lZBnUp T11VYTV8MUg8loD4mDoy3JvQ4aZTbEbX4VU6YGdOW1FNKJdEjCBJh7qZVTedmNt7D3N2 7BdVO+P54ZEw4hmJy89y8R2Tm2XentZR7uBAsLEbS68Dl+ySa7dyUXQXErLpZw42k68O Nj5GTjnSo4Dfn6KnxVv/Hsu72r6xB4LuaUT3pOycWPNYP2Sdb/e8H71Aj8B9jUookLac WD4A== X-Gm-Message-State: ALyK8tKVhjc35qbFTUWVruBmUMCikDDdUNJ0BAgn5C+2CliOaG1vzicyyjcK3gKH+327GmxJoiS4pLFBCE6Srw== X-Received: by 10.107.28.14 with SMTP id c14mr10910536ioc.86.1465046075969; Sat, 04 Jun 2016 06:14:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.148.79 with HTTP; Sat, 4 Jun 2016 06:14:35 -0700 (PDT) In-Reply-To: <1464979514.4082.7.camel@apache.org> References: <1464721441.20289.5.camel@apache.org> <1b08bbb964a64010bb0a5779b0611c69@c3piexchange1.corp.premierinc.com> <1464979514.4082.7.camel@apache.org> From: sebb Date: Sat, 4 Jun 2016 14:14:35 +0100 Message-ID: Subject: Re: BasicAsyncResponseConsumer needs OOM protection? To: HttpComponents Project Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable archived-at: Sat, 04 Jun 2016 13:14:59 -0000 On 3 June 2016 at 19:45, Oleg Kalnichevski wrote: > On Thu, 2016-06-02 at 19:35 +0000, Idzerda, Edan wrote: >> > -----Original Message----- >> > From: Oleg Kalnichevski [mailto:olegk@apache.org] >> > Sent: Tuesday, May 31, 2016 3:04 PM >> > To: HttpComponents Project >> > Subject: Re: BasicAsyncResponseConsumer needs OOM protection? >> > >> > On Tue, 2016-05-31 at 16:03 +0000, Idzerda, Edan wrote: >> > > Using this patch, I can request HTTP responses that exceed available >> > memory without resulting in a hang. Does this seem like the appropria= te >> > place to patch this error? Or should I create a JIRA against this iss= ue and >> > suggest this patch as a solution? I've attached a diff to this email >> > > >> > > Thanks for your assistance and for working on such a great set of Ja= va >> > libraries. >> > >> > Edan >> > >> > Basic request / response consumers are not supposed to be used for >> > anything other than the most basic use cases. One is generally advised >> > to build custom response consumers specifically tailed to their >> > particular application. >> >> I understand that, and thanks for the other examples. For what it's wort= h, I have load tested the reverse proxy using the BasicAsyncResponseConsume= r and it performs extremely well with small messages. >> >> However, if a developer uses the HttpAsyncClient without specifying a sp= ecific response consumer, they are using this Basic one by default. If the= y happen to experience an OOM condition because their heap cannot handle a = response size, the NIO Connection Pool cannot make any new requests. I foun= d this difficult to debug because I assumed the connection pool would recov= er from this unexpected condition. >> >> Isn't the AbstractMultiworkerIOReactor expecting that any error like thi= s would be captured by the response consumer? If that's true, shouldn't t= he BasicAsyncResponseConsumer suppress a hard error like OOM to prevent thi= s problem? Or should the IOReactor layer recover better? >> > > Not if it is a subclass of java.lang.Error. Errors represent abnormal, > fatal, non-recoverable conditions and usually should cause JRE to > terminate. > > If in the context of your application OOM errors can be considered > recoverable and can re-thrown as I/O exceptions it is your decision to > make but this may not necessarily be the case for most users. Also in general it is quite difficult to recover from OOM, as more memory may be needed (at least temporarily). > Oleg > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org > For additional commands, e-mail: dev-help@hc.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org