Return-Path: X-Original-To: apmail-activemq-users-archive@www.apache.org Delivered-To: apmail-activemq-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6326D186EB for ; Mon, 8 Jun 2015 19:56:47 +0000 (UTC) Received: (qmail 82578 invoked by uid 500); 8 Jun 2015 19:56:42 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 82553 invoked by uid 500); 8 Jun 2015 19:56:42 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 82476 invoked by uid 99); 8 Jun 2015 19:56:41 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jun 2015 19:56:41 +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 51F44CC905 for ; Mon, 8 Jun 2015 19:56:41 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.251 X-Spam-Level: **** X-Spam-Status: No, score=4.251 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=3, KAM_LIVE=1, SPF_PASS=-0.001, URIBL_BLOCKED=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-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id u-wjQW7MoO5U for ; Mon, 8 Jun 2015 19:56:30 +0000 (UTC) Received: from mail-oi0-f44.google.com (mail-oi0-f44.google.com [209.85.218.44]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 9AA05209DC for ; Mon, 8 Jun 2015 19:56:29 +0000 (UTC) Received: by oiha141 with SMTP id a141so36889241oih.0 for ; Mon, 08 Jun 2015 12:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=DL6VLHELksxfxLjbx1CTuz4OC6UvvjdKFzCEQF2NuLY=; b=c+tHsqaqwafrugT1skkU4NrisOEGqse2NM7DhPb7FrgXSKl32HslE82BHzsDQXCemz LumX+uGdaWf3KM4bl3Ay+MoY0Op66me0D7FaLJkxGOkpiigfOhLJdjz5U7SReBPNYuKG R62JEoA2S3UiiaD3JaeqhdaPK7eDFmrlrYDGKRJa/NRpA4ssEKSln4c4MZJZZy0j5Nsy 1lvuMn/ARc3NuvxItzeOgC3zMUiI6ei9RHGx3+3Gl88qh67w+TR0183xUAyE1YbrWoum Shk9cSUwS1FzSipYZ1z+UnEpgWZ/yYUJ1hHwsjzk3K/DQlPDBnC2XJ/JeDqh2w/3IE4V azLw== X-Received: by 10.182.165.3 with SMTP id yu3mr15719930obb.17.1433793388519; Mon, 08 Jun 2015 12:56:28 -0700 (PDT) MIME-Version: 1.0 Sender: burtonator2011@gmail.com Received: by 10.183.6.233 with HTTP; Mon, 8 Jun 2015 12:56:08 -0700 (PDT) In-Reply-To: References: From: Kevin Burton Date: Mon, 8 Jun 2015 12:56:08 -0700 X-Google-Sender-Auth: GpxewgOQ4gi2XnQT2grg77EFPps Message-ID: Subject: Re: consumer prefetch considered harmful ..evict from the prefetch buffer? To: users@activemq.apache.org Content-Type: multipart/alternative; boundary=001a11c2fcba9aa5e50518070900 --001a11c2fcba9aa5e50518070900 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Looks like bumping up the number of used connections/thread DEFINITELY has improved performance. We=E2=80=99re now doing about 2x more throughput. We went from about 20% of our threads used at any point in time to about 45% (higher is better). Our task throughput is now 3x (higher is definitely better) and CPU usage is from 20% to 60% (since it=E2=80=99s doing more work). so I think this was definitely a choke point. Maybe recommend users on higher end systems to use multiple connections so that they get more threads. I think we=E2=80=99re an edge case though ;) We always seem to be! On Mon, Jun 8, 2015 at 8:58 AM, Kevin Burton wrote: > > >> I can see two potential problems that your description didn't draw a lin= e >> between: >> >> 1. With a large prefetch buffer, it's possible to have one thread hav= e >> a >> large number of prefetched tasks and another have none, even if all >> tasks >> take an average amount of time to complete. No thread is slow per se= , >> but >> because the messages were prefetched lopsidedly, one thread sits idle >> while >> the other churns through what's on its plate. >> > > > Yes. Totally. I think I mentioned that but maybe didn=E2=80=99t spell i= t out > perfectly. > > This is one major edge case that needs to be addressed. > > >> 2. With *any* prefetch buffer size, it's possible to have one message >> that takes forever to complete. Any messages caught behind that one >> slow >> message are stuck until it finishes. >> >> > No.. that won=E2=80=99t happen because I have one consumer per thread so = others > are dispatched on the other consumers. Even if prefetch is one. > > At least I have a test for this, and believe this to be the case and > verified that my test works properly. > > But this you *may* be right if we=E2=80=99re just explaining it different= ly. I > use one thread per consumer, so as long as there=E2=80=99s a message in p= refetch, > then I=E2=80=99m good. > > the problem is, I think, that my high CPU is stalling out ActiveMQ and so > I can=E2=80=99t stay prefetched. > > >> Which scenario are you worried about here? >> >> If the latter, the AbortSlowAckConsumerStrategy ( >> >> http://timbish.blogspot.com/2013/07/coming-in-activemq-59-new-way-to-abo= rt.html >> ; >> sadly the wiki doesn't detail this strategy and Tim's personal blog post >> is >> the best documentation available) is intended to address exactly this: >> > > Oh yes.. I think I remember reading this. > > yes.. the duplicate processing is far from ideal. > > >> If the former, you're basically looking to enable work-stealing between >> consumers, and I'm not aware of any existing capability to do that. If >> you >> wanted to implement it, you'd probably want to implement it as a sibling >> class to AbortSlowAckConsumerStrategy where SlowAck is the trigger but >> StealWork is the action rather than Abort. > > > > Yes.. but I think you detailed the reason why it=E2=80=99s not ideal - it= requires > a lot of work! > > > I'm a little skeptical that your worker threads could so thoroughly smoth= er >> the CPU that the thread doing the prefetching gets starved out >> > > you underestimate the power of the dark side=E2=80=A6 :) > > We=E2=80=99re very high CPU load=E2=80=A6 with something like 250-500 thr= eads per daemon. > > We=E2=80=99re CPU oriented so if there=E2=80=99s work to be done, and we= =E2=80=99re not at 100% > CPU, then we=E2=80=99re wasting compute resources. > > >> (particularly since I'd expect it to be primarily I/O-bound, so it's CPU >> usage should be minimal), though I guess if you had as many worker threa= ds >> as cores you might be able to burn through all the prefetched messages >> before the ActiveMQ thread gets rescheduled. But I assume that your >> workers are doing non-trivial amounts of work and are probably getting >> context switched repeatedly during their processing, which I'd think wou= ld >> give the ActiveMQ thread plenty of time to do what it needs to. Unless = 1) >> you've set thread priorities to prioritize your workers over ActiveMQ, i= n >> which case don't do that, > > > > Yes. My thread should be minimum priority. I would verify that but > there=E2=80=99s a Linux bug that causes jstack to show the wrong value. > > Does anyone know what priority the ActiveMQ transport thread runs under? > The above bug prevents me from (easily) figuring that out. > > >> 2) your worker threads are somehow holding onto a >> lock that the ActiveMQ thread needs, which is possible but seems unlikel= y, >> or 3) you've set up so many consumers (far more than you have cores) tha= t >> the 1/(N+1)th that the ActiveMQ thread gets is too little or too >> infrequent >> to maintain responsiveness, in which case you need to scale back your >> worker thread pool size (which I think means using fewer consumers per >> process, based on what you've described). >> > > Yes. This is the case. What I=E2=80=99m thinking to do is the reverse. = To use > more connections and put then in a connection pull .. > > To right now if I have 1 connection, and 500 workers, then I have a 1:500 > ratio.. But if I bump that up to just 10=E2=80=A6 I=E2=80=99ll have 1:50= . > > It think this is more realistic and would mean more CPU time to keep the > prefetch buffer warm. If I sized it as 1:1 (which would be wasteful of > resources I think) then I think the problem would effectively be solved > (but waste memory to solve it). > > But maybe around 1:10 or 1:20 it would be resolved. > > I need to verify that ActiveMQ allocates more thread per connection but > I=E2=80=99m pretty sure it does. > > > -- > > Founder/CEO Spinn3r.com > Location: *San Francisco, CA* > blog: http://burtonator.wordpress.com > =E2=80=A6 or check out my Google+ profile > > > --=20 Founder/CEO Spinn3r.com Location: *San Francisco, CA* blog: http://burtonator.wordpress.com =E2=80=A6 or check out my Google+ profile --001a11c2fcba9aa5e50518070900--