You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2020/04/02 10:15:56 UTC

[GitHub] [openwhisk] style95 commented on a change in pull request #4871: Adjust prewarm container dynamically

style95 commented on a change in pull request #4871: Adjust prewarm container dynamically
URL: https://github.com/apache/openwhisk/pull/4871#discussion_r402203935
 
 

 ##########
 File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
 ##########
 @@ -82,6 +85,27 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
 
   backfillPrewarms(true)
 
+  // check periodically every 1 minute, delete prewarmed container if unused for sometime
+  context.system.scheduler.schedule(10.seconds, 1.minute) {
+    prewarmConfig.foreach { config =>
+      val kind = config.exec.kind
+      val memory = config.memoryLimit
+      val ttlMinutes = config.ttlMinutes
+      val containers = prewarmedPool.filter { warmInfo =>
+        warmInfo match {
+          case (_, PreWarmedData(_, `kind`, `memory`, _)) => true
+          case _                                          => false
+        }
+      }
+      for ((container, data) <- containers) {
+        if (Duration.between(data.lastUsed, Instant.now).compareTo(Duration.ofMinutes(ttlMinutes)) > 0) {
 
 Review comment:
   If there is no activation for prewarm kind for the given TTL time, it will always cause a cold start next time.
   Also, even if we can add more prewarm containers when cold starts happen I think it may not fit well for some workloads. If loads spike for some runtime kind, it will cause a lot of cold starts. Also, it will try to create more prewarm containers at the same time. As we know, docker operation is quite expensive and it will end up with a huge number of container creation along with long wait-time.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services