tumblr / colossus

I/O and Microservice library for Scala
Apache License 2.0
1.14k stars 96 forks source link

ParNew GC (Allocation Failure) frequent #510

Closed zyanho closed 7 years ago

zyanho commented 7 years ago

env: scala:2.11 colossus:0.8.2

run code

object ScenesServer {
  def main(args: Array[String]): Unit = {
    implicit val actorSystem = ActorSystem()
    implicit val io = IOSystem()

    Server.start("hello-world", 9000){ worker => new HelloInitializer(worker) }
  }
}

class HelloInitializer(worker: WorkerRef) extends Initializer(worker) {

  def onConnect = context => new HelloService(context)

}

class HelloService(context: ServerContext) extends HttpService(context) {
  def handle = {
    case request @ Get on Root / "hello" => {
      Callback.successful(request.ok("Hello World!"))
    }
  }
}

when i start this server with jvm opts

-XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Xloggc:/tmp/gc/gc.log -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintTenuringDistribution

i see Minor GC often enough

2017-05-26T11:12:59.304+0800: 2314.736: [GC (Allocation Failure) 2017-05-26T11:12:59.304+0800: 2314.736: [ParNew
Desired survivor size 104857600 bytes, new threshold 15 (max 15)
: 1655366K->18053K(1843200K), 0.0340171 secs] 1655366K->18053K(3891200K), 0.0342093 secs] [Times: user=0.24 sys=0.00, real=0.04 secs]

2017-05-26T11:15:54.036+0800: 2489.467: [GC (Allocation Failure) 2017-05-26T11:15:54.036+0800: 2489.467: [ParNew
Desired survivor size 104857600 bytes, new threshold 15 (max 15)
: 1656453K->18863K(1843200K), 0.0368496 secs] 1656453K->18863K(3891200K), 0.0370190 secs] [Times: user=0.28 sys=0.00, real=0.03 secs]

2017-05-26T11:19:14.393+0800: 2689.824: [GC (Allocation Failure) 2017-05-26T11:19:14.393+0800: 2689.824: [ParNew
Desired survivor size 104857600 bytes, new threshold 15 (max 15)
: 1657263K->17895K(1843200K), 0.0507917 secs] 1657263K->22454K(3891200K), 0.0509915 secs] [Times: user=0.24 sys=0.01, real=0.06 secs]

it look like apply 100m memory and Allocation Failure and then trigger gc maybe about akka actor?

could you give me some suggestions ?

benblack86 commented 7 years ago

With your JVM options you are not specify the heap size, so the total size will depend on the default (which could be anything). Not sure what you are trying to do? In general, you shouldn't be changing CMSInitiatingOccupancyFraction or UseCMSInitiatingOccupancyOnly.