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 03B88200BF4 for ; Fri, 6 Jan 2017 22:53:54 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 02934160B39; Fri, 6 Jan 2017 21:53:54 +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 23A50160B37 for ; Fri, 6 Jan 2017 22:53:52 +0100 (CET) Received: (qmail 66196 invoked by uid 500); 6 Jan 2017 21:53:52 -0000 Mailing-List: contact dev-help@mesos.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mesos.apache.org Delivered-To: mailing list dev@mesos.apache.org Received: (qmail 66181 invoked by uid 99); 6 Jan 2017 21:53:52 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jan 2017 21:53:52 +0000 Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com [209.85.215.42]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 687CF1A0329 for ; Fri, 6 Jan 2017 21:53:51 +0000 (UTC) Received: by mail-lf0-f42.google.com with SMTP id v186so7532565lfa.1 for ; Fri, 06 Jan 2017 13:53:51 -0800 (PST) X-Gm-Message-State: AIkVDXIWyAlWnofQrg43JbFpNVWHhg1EB8T7ek7v4yhb6yzGySNyt/rQLkRT+X5pKO2YlpV0c2PVh9q962vlKTU1 X-Received: by 10.25.75.80 with SMTP id y77mr26752237lfa.173.1483739629733; Fri, 06 Jan 2017 13:53:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.114.83.138 with HTTP; Fri, 6 Jan 2017 13:53:29 -0800 (PST) In-Reply-To: References: From: Benjamin Mahler Date: Fri, 6 Jan 2017 13:53:29 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Metrics collection affected when libprocess queue builds up To: dev Content-Type: multipart/alternative; boundary=94eb2c1a0b9c91ef760545740dc0 archived-at: Fri, 06 Jan 2017 21:53:54 -0000 --94eb2c1a0b9c91ef760545740dc0 Content-Type: text/plain; charset=UTF-8 Yep, thanks! For https://issues.apache.org/jira/browse/MESOS-6872 it sounds like you're referring to the help information? We already list the timeout but perhaps we need an example section in our help pages. http://mesos.apache.org/documentation/latest/endpoints/metrics/snapshot/ Or are you referring to the http://mesos.apache.org/documentation/latest/monitoring/ page? That likely warrants a NOTE as well as you mentioned earlier. For https://issues.apache.org/jira/browse/MESOS-6873 I'd suggest we just instead introduce the Gauge overload that takes a 'function>' (rather than a 'Deferred>') (approach (3)) so that we can just write the version that calls queue.size() outside of the actor's context. That won't impose an overhead, unlike the counter approach where counting each incoming and outgoing event may impose some non-trivial overhead on the event processing hot path. On Fri, Jan 6, 2017 at 7:09 AM, Zhitao Li wrote: > Hi Benjamin, > > I've filed MESOS-6872 > and MESOS-6873 for doc > and gauge change, and will fix them. Can you shepherd these? > > I'll do another pass of other gauge usage in allocator to see whether there > is easy low hanging fruits. > > Thanks. > > On Wed, Jan 4, 2017 at 6:28 PM, Benjamin Mahler > wrote: > > > A patch to update the documentation with a NOTE about this would be > great. > > It excludes all metrics that were not available within the timeout, there > > is no indication within a particular result whether any timed out and > were > > excluded. > > > > My feeling is that taking the difference between enqueued and dequeued is > > > not as obvious as a `Gauge`. If we take this path, we should document > it > > > clearly how to use the metric. > > > > > > We could also explore avoiding the dispatch per (3) for this case, since > > getting the size is a read only operation and should be thread-safe > without > > acquiring the lock. > > > > I'm also interested in how other `Gauge` type systems are implemented in > > > other well know OSS projects. Maybe we can do some more research on > their > > > approach? > > > > > > We did research when the metrics library was originally added. Coda > Hale's > > library (now called "dropwizard metrics" FWICT) was one of the libraries > we > > looked at, and its Gauge is equivalent to suggestion (3), as it was > > designed for Java-style programs with locking as opposed to actors: > > > > http://metrics.dropwizard.io/3.1.0/getting-started/#gauges > > > > On Fri, Dec 30, 2016 at 10:34 AM, Zhitao Li > wrote: > > > > > Hi Benjamin, > > > > > > Thanks for the response. First time heard of the `timeout` parameter. > > I'll > > > fix our monitoring scripts to always specify this. > > > > > > One question on timeout: does it simply drop any metric callback which > is > > > not collected within the timeout? Does caller know which metrics are > > > dropped due to timeout? > > > > > > Also, it is not documented in > > > http://mesos.apache.org/documentation/latest/monitoring/. Should we > > send a > > > patch to update it? > > > > > > On Tue, Dec 27, 2016 at 6:12 PM, Benjamin Mahler > > > wrote: > > > > > > > The /metrics endpoint exposes a timeout parameter if you want to > > receive > > > a > > > > response with all of the metrics that were available within the > > timeout, > > > > e.g. /metrics/snapshot.json?timeout=10secs > > > > > > > > I'd recommend using this when collecting metrics so that you can > > maintain > > > > visibility when a particular component is backlogged. > > > > > > > > Should we explore a more reliable way to track metrics independently > > from > > > > > libprocess's queue? > > > > > > > > > > > > Note that this problem applies only to our defer-based "Gauge" > metrics > > > that > > > > execute on the actor. Counters and Timers are immune to this. I would > > say > > > > there are a couple of improvements we can make in increasing order of > > > > difficulty: > > > > > > > > (1) There are instances of Gauges that might be better represented as > > > > Counters. For example, we expose the actor queue sizes using a gauge > > > (known > > > > to be unfortunate!), when instead we could expose two counters for > > > > "enqueued" and "dequeued" messages and infer size from these. We can > > also > > > > add the ability for callers to manually increment and decrement their > > > > Gauges rather than go through a dispatch. > > > > > > > > > My feeling is that taking the difference between enqueued and dequeued > is > > > not as obvious as a `Gauge`. If we take this path, we should document > it > > > clearly how to use the metric. > > > > > > > > > > > > > > (2) Allow Gauge dispatches to be sent to the front of the actor's > > queue, > > > > rather than the back. I would hope that we don't wind up with a > notion > > of > > > > integer priority for messages. Note that this doesn't solve the > problem > > > for > > > > when the "backlog" is occurring inside a single expensive function. > It > > > also > > > > has the issue of preventing "progress" if metrics are hit frequently > > > enough > > > > and are expensive enough. > > > > > > > > > > (3) There are instances of Gauges that might be better represented as > > > > thread-safe logic. For example, if we need an actor's std::map > member's > > > > .size(), we could call .size() safely so long as the map is not > > > destructed. > > > > In other cases, explicit locking may be needed and is more > complicated. > > > > > > > > (4) There are instances of Gauges that might be better represented > as a > > > > "wrapping" around a data-structure. For example, the std::map could > be > > > > wrapped as a 'map_wrapper' that injects metric updates into each > > > non-const > > > > operation that affects the size of the map. > > > > > > > > So far I've felt that the timeout and (1) will be sufficient for the > > > > foreseeable future, while (3) and (4) seem to require a significant > > > impact > > > > to non-metrics related code complexity, let me know what you think. > > > > > > > > > > I agree that we should not adopt (2) only to address this problem: it > > seems > > > like something larger and also affects how libprocess was generally > > > designed, so we should think more carefully about that. > > > > > > I like the idea of (3) since it can be implemented gradually, and it > can > > > completely avoid paying the cost of enque/deque message (which is > another > > > interesting question: how expensive it could be?) > > > > > > (4) seems like a bigger > > > > > > I'm also interested in how other `Gauge` type systems are implemented > in > > > other well know OSS projects. Maybe we can do some more research on > their > > > approach? > > > > > > > > > > Ben > > > > > > > > On Mon, Dec 19, 2016 at 6:32 PM, Zameer Manji > > wrote: > > > > > > > > > I believe Zhitao is referring to `/metrics/snapshot` returning a > > result > > > > > after 10-30 seconds. > > > > > > > > > > I think in a typical environment, this will cause most metrics > > > collection > > > > > tooling to timeout. This causes the operator to not have any > > visibility > > > > > into the system, making debugging/fighting the problem very hard. > > > > > > > > > > On Mon, Dec 19, 2016 at 9:23 PM, haosdent > > wrote: > > > > > > > > > > > Hi, @zhitao > > > > > > > > > > > > > the `/metrics/snapshot` could take 10-30 seconds to respond. > > > > > > > > > > > > Do you mean it `/metrics/snapshot` return result after 10~30 > > seconds? > > > > > > Or `/metrics/snapshot` takes 10~30 seconds to reflect the change > > of ` > > > > > > allocator/mesos/event_queue_dispatches gauge`? > > > > > > > > > > > > On Mon, Dec 19, 2016 at 1:11 PM, Zhitao Li < > zhitaoli.cs@gmail.com> > > > > > wrote: > > > > > > > > > > > > > Hi all, > > > > > > > > > > > > > > While I was debugging an allocator message queue build up issue > > on > > > > > master > > > > > > > (which I plan to share another thread), I noticed that > > > > > > `/metrics/snapshot` > > > > > > > is also badly affected. > > > > > > > > > > > > > > For example, when the allocator queue has ~3k dispatches in it > > > > > (revealed > > > > > > by > > > > > > > the allocator/mesos/event_queue_dispatches gauge), the > > > > > > `/metrics/snapshot` > > > > > > > could take 10-30 seconds to respond. > > > > > > > > > > > > > > During an active debugging or outage fighting, this is pretty > > > > > undesired. > > > > > > > > > > > > > > My guess is that many stats collection code relies on > *deferring* > > > to > > > > > > > another libprocess and collect the result. > > > > > > > > > > > > > > Should we explore a more reliable way to track metrics > > > independently > > > > > from > > > > > > > libprocess's queue? > > > > > > > > > > > > > > -- > > > > > > > Cheers, > > > > > > > > > > > > > > Zhitao Li > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > Best Regards, > > > > > > Haosdent Huang > > > > > > > > > > > > -- > > > > > > Zameer Manji > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Cheers, > > > > > > Zhitao Li > > > > > > > > > -- > Cheers, > > Zhitao Li > --94eb2c1a0b9c91ef760545740dc0--