m3 icon indicating copy to clipboard operation
m3 copied to clipboard

m3coordinator high CPU usage

Open prateek opened this issue 8 years ago • 11 comments

Users are reporting that the coordinator sidecar adds a lot of CPU load. I'm sure there's plenty of low-hanging fruit we can fix to help matters.

prateek avatar Sep 10 '18 19:09 prateek

From Gitter:

@BertHartm 14:23 Is it weird that the m3coordinator is causing my prometheus instance cpu to jump about 3x, and then taking up about 2x on top of that for itself? my box is maxing out so I'm going to scale up and see if that ratio holds without the cpu being limited, but it feels abnormally high this is on 0.4.1 and 0.4.2, haven't tried .3 yet

robskillington avatar Sep 10 '18 19:09 robskillington

As Rob mentioned on Gitter, should we add a template which asks people to take a profile for m3coordinator issues ?

pprof -proto "http://localhost:7201/debug/pprof/profile?seconds=15" > /tmp/m3coordinator.pb.gz

nikunjgit avatar Sep 11 '18 21:09 nikunjgit

Also, I can take a look at this once we start supporting prombench. I don't want to spend time generating load.

nikunjgit avatar Sep 11 '18 21:09 nikunjgit

Here's a pprof from a cpu heavy coordinator instance m3coordinator.pb.gz

BertHartm avatar Sep 24 '18 19:09 BertHartm

0.4.6 helped dramatically with this. CPU has dropped signficantly, but I'm still having problems running full load though my cluster. I'm currently using 9 db nodes, an external write coordinator (for all Prometheus boxes), and a replication factor of 3. turning on one prometheus instances is doing ~230k / 240k commit log writes per second ( sum(rate(commitlog_writes_success))). Turning on it's HA pair, I get some shaky numbers around 350k, but nothing approaching the 460k I would expect. My p99 write latency (service_writeTaggedBatchRaw_latency) goes from ~1s to 5-10s on some nodes, and my dbindex_insert_end_to_end_latency goes from 1-2ms to several hundred ms per node.

Here are 2 profiles, one from the shared m3coordinator, and one from one of the m3dbs that was on the worse end of the write times. both were gathered as the system was recovering from having both prometheus instances turned on to just having 1, so things still seemed backlogged, but there wasn't as much data coming into the system. m3coordinator.pb.gz m3db.pb.gz

BertHartm avatar Oct 09 '18 19:10 BertHartm

here's the goroutines debug=2 file (from later, not under intense load)

m3db.goroutines.txt

BertHartm avatar Oct 09 '18 19:10 BertHartm

@BertHartm Thanks for the info! We can definitely look into the performance here but based on your setup seems like the single write coordinator will always be the bottleneck. I'm curious if you have given a though to having one write coordinator per prom instance ideally collocated with it.

nikunjgit avatar Oct 10 '18 16:10 nikunjgit

I've been wavering back and forth with sidecar setup vs. dedicated box. I'm currently using a dedicated box because of the high cpu and high network usage, which I want to keep from overloading the prometheus boxes which are also pretty high usage right now. I can probably move back once cpu is a bit lower (or I shard this prometheus instance).

Also, to summarize the discussion in gitter from yesterday: m3db was spending a lot of time calculating metrics. Lowering the sampling frequency helped me get past that issue.

BertHartm avatar Oct 10 '18 17:10 BertHartm

sounds good!

nikunjgit avatar Oct 11 '18 17:10 nikunjgit

abusing this open issue for a maybe related thing. I noticed one of my coordinators was oscilating back and forth between about 25 cores and about 12 cores every 5 minutes or so. I grabbed a profile of it high, and low. It's doing about 150k samples/s (450 after RF=3) and has downsampling set up for a 15 minute namespace.

pprof.m3coordinator.cpu_high.pb.gz pprof.m3coordinator.cpu_low.pb.gz

It seems to me like the garbage collector might be the difference on first pass, though the memory usage on the box seems fairly stable. I'm going to see if I can try to make it less frequent / aggressive

BertHartm avatar Dec 03 '18 21:12 BertHartm

@BertHartm Thanks for more details, heap profiles would be useful also. We're in the middle of an index performance sprint, but we should be done with that soon (few weeks) and will be able to look at this in more detail

richardartoul avatar Dec 04 '18 23:12 richardartoul