Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BB6577152 for ; Mon, 1 Aug 2011 12:46:13 +0000 (UTC) Received: (qmail 36355 invoked by uid 500); 1 Aug 2011 12:46:12 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 36193 invoked by uid 500); 1 Aug 2011 12:46:11 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 36184 invoked by uid 99); 1 Aug 2011 12:46:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Aug 2011 12:46:11 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [90.183.38.155] (HELO gmmr3.centrum.cz) (90.183.38.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Aug 2011 12:46:02 +0000 Received: from mail1011.cent (lb1-gmcz-self.centrum.cz [90.183.38.132]) by gmmr3.centrum.cz (Postfix) with ESMTP id DC4541401219C for ; Mon, 1 Aug 2011 14:45:41 +0200 (CEST) Received: by mail1011.cent (Postfix, from userid 33) id A7AAB5A4E2; Mon, 1 Aug 2011 14:45:41 +0200 (CEST) To: Subject: Taking 100% CPU when network is throttled Received: from 95.103.213.92 (X-Forwarded-For: 95.103.213.92) by mail1011.centrum.cz (centrum.cz multimail) with HTTP Date: Mon, 01 Aug 2011 14:45:41 +0200 From: "azurIt" X-Mailer: Centrum Email 5.3 X-Priority: 3 MIME-Version: 1.0 Message-Id: <20110801144541.3E073A5A@pobox.sk> X-Maser: brud Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Hi, i came accross a serious problem with Apache server when it is NOT able to read/write from/to network immediatelly. We are using network throttling patches in our linux kernel wihch are able to emulate low network throughput (we are using this to throttle users). When a process reaches it's limit, read/write will result in EAGAIN which is completely ok cos it's standard behavior. Problem is that Apache is not able to correctly process this and is trying to read/write in a loop WITHOUT any delay - this is, of course, resulting in 100% CPU consumption. This bug can lead to DoS of the whole server. Here is the strace output when Apache's child is throttled: writev(6409, [{"n1n1n1n1n1n1n1n1n1n1n1n1n1n1n1n1n"..., 2900}], 1) = -1 EAGAIN (Resource temporarily unavailable) poll([{fd=6409, events=POLLOUT}], 1, 100000) = 1 ([{fd=6409, revents=POLLOUT}]) writev(6409, [{"n1n1n1n1n1n1n1n1n1n1n1n1n1n1n1n1n"..., 2900}], 1) = -1 EAGAIN (Resource temporarily unavailable) poll([{fd=6409, events=POLLOUT}], 1, 100000) = 1 ([{fd=6409, revents=POLLOUT}]) writev(6409, [{"n1n1n1n1n1n1n1n1n1n1n1n1n1n1n1n1n"..., 2900}], 1) = -1 EAGAIN (Resource temporarily unavailable) poll([{fd=6409, events=POLLOUT}], 1, 100000) = 1 ([{fd=6409, revents=POLLOUT}]) writev(6409, [{"n1n1n1n1n1n1n1n1n1n1n1n1n1n1n1n1n"..., 2900}], 1) = -1 EAGAIN (Resource temporarily unavailable) poll([{fd=6409, events=POLLOUT}], 1, 100000) = 1 ([{fd=6409, revents=POLLOUT}]) writev(6409, [{"n1n1n1n1n1n1n1n1n1n1n1n1n1n1n1n1n"..., 2900}], 1) = -1 EAGAIN (Resource temporarily unavailable) poll([{fd=6409, events=POLLOUT}], 1, 100000) = 1 ([{fd=6409, revents=POLLOUT}]) ..and so on until it is able to send data again. I suggest to insert a little delay everytime an EAGAIN is returned. azur