marathon icon indicating copy to clipboard operation
marathon copied to clipboard

CPU usage increased dramatically 0.8.1-RC1 -> master

Open bobrik opened this issue 11 years ago • 45 comments

I built and deployed 964e43035830bc48c56e4853e39ed44553383427. Running against 0.22.1 masters:

image

Upgrade started at 16:20, last node was updated at 16:31. Revert to 0.8.1-RC1 happened at 16:41.

I mentioned performance in #1472 as well.

bobrik avatar May 09 '15 13:05 bobrik

Hi @bobrik,

thanks for reporting this. With which Mesos library version (native) are you using with Marathon? Note that we updated the Dockerfile to use the latest Mesos-Libraries just today because the corresponding base image was just recently released.

@lloesche have you seen something similar?

kolloch avatar May 11 '15 16:05 kolloch

Turns out that I was using 0.22.0 as a base image, will try with 0.22.1.

bobrik avatar May 11 '15 16:05 bobrik

Nah, it's still bad:

image

Elasticsearch has hot_threads api, do you have something similar so I can give more meaningful data?

bobrik avatar May 11 '15 16:05 bobrik

You can use poor man's profiling tool: Could you use jstack a couple of times on the Marathon process and send us the stack traces?

> jstack <MARATHON_PID> >stackX.txt
> jstack <MARATHON_PID> >stackX.txt
> jstack <MARATHON_PID> >stackX.txt
...

You might have to enter the process space with docker exec to do that.

kolloch avatar May 12 '15 08:05 kolloch

Here it is: https://gist.github.com/bobrik/87b8903cc3d502afe888

bobrik avatar May 12 '15 08:05 bobrik

@bobrik I couldn't reproduce this. I ran v0.8.2-RC2 in a docker and started 100 tasks without the Marathon process using considerably more than 10% CPU. What does your setup look like?

drexin avatar May 12 '15 10:05 drexin

Marathon is running on Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz, 8 cores.

Health checks are running once per 3-5 seconds.

image

bobrik avatar May 12 '15 10:05 bobrik

@bobrik Woud it be possible for you to change the health checks to COMMAND checks that call curl and see if the CPU usage is still that high then?

drexin avatar May 12 '15 16:05 drexin

I tried, but it didn't work:

        healthChecks:
          - protocol: COMMAND
            command:
              value: "curl -f -X GET http://$HOST:$PORT0/?n=marathon_healthcheck"
            gracePeriodSeconds: 15
            maxConsecutiveFailures: 300
            intervalSeconds: 2
            timeoutSeconds: 5
{"log":"[2015-05-12 21:26:54,159] INFO Received status update for task topface_lenny-test.67ca9fbb-f8ec-11e4-ab20-56847afe9799: TASK_RUNNING () (mesosphere.marathon.MarathonScheduler:148)\n","stream":"stdout","time":"2015-05-12T21:26:54.159345729Z"}
{"log":"[2015-05-12 21:26:54,160] INFO Received status for [topface_lenny-test.67ca9fbb-f8ec-11e4-ab20-56847afe9799] with version [2015-05-12T21:18:15.625Z] and healthy [false] (mesosphere.marathon.health.MarathonHealthCheckManager:150)\n","stream":"stdout","time":"2015-05-12T21:26:54.160155174Z"}
{"log":"[2015-05-12 21:26:54,160] INFO Forwarding health result [Unhealthy(topface_lenny-test.67ca9fbb-f8ec-11e4-ab20-56847afe9799,2015-05-12T21:18:15.625Z,,2015-05-12T21:26:54.160Z)] to health check actor [Actor[akka://marathon/user/$N#1518643597]] (mesosphere.marathon.health.MarathonHealthCheckManager:171)\n","stream":"stdout","time":"2015-05-12T21:26:54.1603141Z"}

No more info is provided to resolve the issue. Task is healthy and works with http check. Can be related to #1380.

bobrik avatar May 12 '15 21:05 bobrik

        healthChecks:
          - protocol: COMMAND
            command:
              value: "true"
            gracePeriodSeconds: 15
            maxConsecutiveFailures: 300
            intervalSeconds: 2
            timeoutSeconds: 5

120 instances, 0.8.1-RC1. Not sure if upgrading to master wouldn't kill marathon completely.

image

bobrik avatar May 12 '15 21:05 bobrik

Probably worth mentioning: each of 3 marathons receives 1 rps for /v2/apps?embed=apps.tasks for service discovery reasons, in total it's 3 rps to master.

bobrik avatar May 13 '15 06:05 bobrik

I guess these queries are more or less the only thing I see in the stack traces that sticks out:

"qtp265226115-746" prio=10 tid=0x00007f0964023000 nid=0xd88 waiting on condition [0x00007f091bbf8000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000007dafdd118> (a scala.concurrent.impl.Promise$CompletionLatch)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1033)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1326)
    at scala.concurrent.impl.Promise$DefaultPromise.tryAwait(Promise.scala:208)
    at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:218)
    at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223)
    at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:190)
    at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53)
    at scala.concurrent.Await$.result(package.scala:190)
    at mesosphere.marathon.api.RestResource$class.result(RestResource.scala:44)
    at mesosphere.marathon.api.v2.AppsResource.result(AppsResource.scala:29)
    at mesosphere.marathon.api.v2.AppsResource.mesosphere$marathon$api$v2$AppsResource$$enrichedTasks(AppsResource.scala:294)
    at mesosphere.marathon.api.v2.AppsResource$$anonfun$5.apply(AppsResource.scala:57)
    at mesosphere.marathon.api.v2.AppsResource$$anonfun$5.apply(AppsResource.scala:55)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:418)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:418)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1222)
    - locked <0x00000007dafdbf40> (a scala.collection.immutable.Stream$Cons)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1212)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:418)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:418)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1222)
    - locked <0x00000007dafdbf90> (a scala.collection.immutable.Stream$Cons)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1212)
    at scala.collection.immutable.Stream.foreach(Stream.scala:595)
    at play.api.libs.json.JsValueSerializer.serialize(JsValue.scala:311)
    at play.api.libs.json.JsValueSerializer$$anonfun$serialize$2.apply(JsValue.scala:320)
    at play.api.libs.json.JsValueSerializer$$anonfun$serialize$2.apply(JsValue.scala:318)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
    at play.api.libs.json.JsValueSerializer.serialize(JsValue.scala:318)
    at play.api.libs.json.JsValueSerializer.serialize(JsValue.scala:302)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114)
    at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:1887)
    at play.api.libs.json.JacksonJson$.generateFromJsValue(JsValue.scala:495)
    at play.api.libs.json.Json$.stringify(Json.scala:51)
    at play.api.libs.json.JsValue$class.toString(JsValue.scala:80)
    at play.api.libs.json.JsObject.toString(JsValue.scala:166)
    at mesosphere.marathon.api.v2.AppsResource.index(AppsResource.scala:87)
    at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.codahale.metrics.jersey.InstrumentedResourceMethodDispatchProvider$TimedRequestDispatcher.dispatch(InstrumentedResourceMethodDispatchProvider.java:30)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263)
    at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178)
    at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
    at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:62)
    at mesosphere.marathon.api.CacheDisablingFilter.doFilter(CacheDisablingFilter.scala:18)
    at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
    at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
    at mesosphere.marathon.api.CORSFilter.doFilter(CORSFilter.scala:46)
    at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
    at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
    at mesosphere.marathon.api.LeaderProxyFilter.doFilter(LeaderProxyFilter.scala:56)
    at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
    at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
    at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
    at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1467)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at com.codahale.metrics.jetty8.InstrumentedHandler.handle(InstrumentedHandler.java:192)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:370)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
    at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:745)

I don't know yet why this would have changed recently.

kolloch avatar May 13 '15 08:05 kolloch

I've shut down service discovery updater for a few minutes on 0.8.1-RC1 and look at that:

image

The second decrease in cpu usage on the graph happened when I closed browser tab with marathon.

bobrik avatar May 13 '15 13:05 bobrik

Flamegraphs: https://gist.github.com/bobrik/969d322bb28c6a649cf7

https://github.com/jrudolph/perf-map-agent

0.8.1-RC1:

flamegraph-0.8.1-rc1

0.8.2-SNAPSHOT:

flamegraph-0.8.2-snapshot

Blue line, higher is 0.8.2:

image

bobrik avatar May 14 '15 09:05 bobrik

@drexin, were you using OpenJDK when you tried reproducing this? I wonder if that had something to do with it. https://gist.github.com/bobrik/87b8903cc3d502afe888 suggests that these numbers are all using that.

dgromov avatar May 17 '15 15:05 dgromov

I'm using Sun Java 1.7 not openjdk if that makes a difference

apuckey avatar May 18 '15 04:05 apuckey

Hi @bobrik, BTW I hope that it is clear that we really appreciate your detailed reporting. Unfortunately, we can't reproduce it so far.

I could imagine that it has something to do with the Mesos Library changes. Did you try 0.8.1-RC1 with the 0.22.1 mesos libraries by any chance? I am not sure if that is a supported configuration but if that exhibits the same CPU pattern, the reason could lie in the new Mesos Library version.

I think it might make sense to implement #1539 soon and check if your problems persist.

What do you think?

kolloch avatar May 18 '15 17:05 kolloch

Should I just try 0.8.1-RC1 tag on top of mesosphere/mesos:0.22.1 docker image?

Removing native code sounds like a good idea, too much is happening there.

bobrik avatar May 18 '15 19:05 bobrik

Hi @bobrik, if it's not a big hassle (at least in comparison to the things you have already done), trying 0.8.1-RC1 on top of mesosphere/mesos:0.22.1 would be grand. :+1:

kolloch avatar May 19 '15 08:05 kolloch

Looks like marathon itself is to blame and 0.22.1 is even better with 0.8.2-SNAPSHOT. Snapshot is from today's master, btw.

~ 12:10 marathon 0.8.1-RC1, mesos 0.22.1 ~ 12:25 marathon 0.8.1-RC1, mesos 0.22.0 ~ 12:38 marathon 0.8.2-SNAPSHOT, mesos 0.22.1 ~ 12:47 marathon 0.8.2-SNAPSHOT, mesos 0.22.0

image

bobrik avatar May 19 '15 10:05 bobrik