Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document for prewarmed container #4910

Merged
merged 1 commit into from
May 28, 2021

Conversation

ningyougang
Copy link
Contributor

@ningyougang ningyougang commented May 22, 2020

Description

In slack, some guys said, didn't know how prewarmed conainers works, so i add the document for prewarmed container

Related issue and scope

  • I opened an issue to propose and discuss this change (#????)

My changes affect the following components

  • API
  • Controller
  • Message Bus (e.g., Kafka)
  • Loadbalancer
  • Invoker
  • Intrinsic actions (e.g., sequences, conductors)
  • Data stores (e.g., CouchDB)
  • Tests
  • Deployment
  • CLI
  • General tooling
  • Documentation

Types of changes

  • Bug fix (generally a non-breaking change which closes an issue).
  • Enhancement or new feature (adds new functionality).
  • Breaking change (a bug fix or enhancement which changes existing behavior).

Checklist:

  • I signed an Apache CLA.
  • I reviewed the style guides and followed the recommendations (Travis CI will check :).
  • I added tests to cover my changes.
  • My changes require further changes to the documentation.
  • I updated the documentation where necessary.

@codecov-commenter
Copy link

codecov-commenter commented May 22, 2020

Codecov Report

Merging #4910 (4c491da) into master (aa7e6e2) will decrease coverage by 13.65%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #4910       +/-   ##
===========================================
- Coverage   81.51%   67.85%   -13.66%     
===========================================
  Files         220      226        +6     
  Lines       10731    12021     +1290     
  Branches      444      493       +49     
===========================================
- Hits         8747     8157      -590     
- Misses       1984     3864     +1880     
Impacted Files Coverage Δ
...core/database/cosmosdb/RxObservableImplicits.scala 0.00% <0.00%> (-100.00%) ⬇️
...ore/database/cosmosdb/cache/CacheInvalidator.scala 0.00% <0.00%> (-100.00%) ⬇️
...e/database/cosmosdb/cache/ChangeFeedConsumer.scala 0.00% <0.00%> (-100.00%) ⬇️
...core/database/cosmosdb/CosmosDBArtifactStore.scala 0.00% <0.00%> (-95.85%) ⬇️
...sk/core/database/cosmosdb/CosmosDBViewMapper.scala 0.00% <0.00%> (-93.90%) ⬇️
...tabase/cosmosdb/cache/CacheInvalidatorConfig.scala 0.00% <0.00%> (-92.31%) ⬇️
...enwhisk/connector/kafka/KamonMetricsReporter.scala 0.00% <0.00%> (-83.34%) ⬇️
...e/database/cosmosdb/cache/KafkaEventProducer.scala 0.00% <0.00%> (-78.58%) ⬇️
...whisk/core/database/cosmosdb/CosmosDBSupport.scala 0.00% <0.00%> (-74.08%) ⬇️
...ore/database/azblob/AzureBlobAttachmentStore.scala 11.53% <0.00%> (-60.58%) ⬇️
... and 32 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa7e6e2...4c491da. Read the comment docs.

docs/prewarm.md Outdated

* Some prewarmed containers will be deleted if they are expiration, this can save some memory resource.
* Create a certain range prewarmed conainers according to the cold start in same kind on next schedule time, e.g.
- cold start number = 2, number of prewarmed container will be created = cold start number(2)/threshold(2) * increment(1) = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't threshold 1 in the above example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the prewarm.md's content to actions.md.
Regarding Isn't threshold 1 in the above example?
I changed like below

     "stemCells": [
     {
        "initialCount": 2,
         "memory": "256 MB",
         "reactive": {
             "minCount": 1,
             "maxCount": 4,
             "ttl": "2 minutes",
             "threshold": 2,   # here, changed from 1 to 2, need to keep the same.
             "increment": 1
     }
     ]

docs/prewarm.md Outdated
#
-->

# runtimes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can skip this part as there is this part?
https://github.com/apache/openwhisk/blob/master/docs/actions.md#languages-and-runtimes

Instead of this, we may add a section to briefly describe why we need prewarm containers and the effect of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already moved to actions.md's ## Languages and Runtimes section.

docs/prewarm.md Outdated

# Prewarmed container without `reactive`

Prewarmed containers are created when invoker starts, they are created according to runtimes.json's stemCells, e.g.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Prewarmed containers are created when invoker starts, they are created according to runtimes.json's stemCells, e.g.
Prewarmed containers are created according to the stemcell configuration in the `runtime.json` file at the invoker bootup time, e.g.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your description is more accurate, already updated accordingly.

docs/prewarm.md Outdated
when user invokes actions, these relative activations are run on docker containers which base on
these runtime docker images.

# Prewarmed container without `reactive`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Prewarmed container without `reactive`
# How prewarm containers are provisioned without a reactive configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your description is more accurate, already updated accordingly.

docs/prewarm.md Outdated
the activation will be scheduled on prewarmed container firstly, then subsequent activation will be scheduled on warmed containers.
because prewarm container is already created in advance, so this can avoid `cold start`.

# Prewarmed container with `reactive`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Prewarmed container with `reactive`
# How prewarmed containers are provisioned with a reactive configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your description is more accurate, already updated accordingly.

docs/prewarm.md Outdated
}
```
`reactive` fields explanation:
* minCount: exist at least `minCount` prewarmed containers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* minCount: exist at least `minCount` prewarmed containers.
* `minCount`: the minimum number of prewarm containers. The number of prewarm containers can't be fewer than this value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your description is more accurate, already updated accordingly.

docs/prewarm.md Outdated
```
`reactive` fields explanation:
* minCount: exist at least `minCount` prewarmed containers.
* maxCount: can't create more than `maxCount`prewarmed containers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* maxCount: can't create more than `maxCount`prewarmed containers.
* `maxCount`: the maximum number of prewarm containers. The number of prewarm containers cannot exceed this value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your description is more accurate, already updated accordingly.

docs/prewarm.md Outdated
`reactive` fields explanation:
* minCount: exist at least `minCount` prewarmed containers.
* maxCount: can't create more than `maxCount`prewarmed containers.
* ttl: the prewarmed conainers will be deleted due to expiration, because they are not used in ttl time.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* ttl: the prewarmed conainers will be deleted due to expiration, because they are not used in ttl time.
* `ttl`: the amount of time that prewarm containers can exist without any activation. If no activation for the prewarm container arrives in the given time, the prewarm container will be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your description is more accurate, already updated accordingly.

docs/prewarm.md Outdated
* minCount: exist at least `minCount` prewarmed containers.
* maxCount: can't create more than `maxCount`prewarmed containers.
* ttl: the prewarmed conainers will be deleted due to expiration, because they are not used in ttl time.
* threshold and increment: these two fileds are used together to calculate the new created number of prewarmed containers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* threshold and increment: these two fileds are used together to calculate the new created number of prewarmed containers.
* `threshold` and `increment`: these two configurations control the number of new prewarm containers to be created.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your description is more accurate, already updated accordingly.

docs/prewarm.md Outdated
* ttl: the prewarmed conainers will be deleted due to expiration, because they are not used in ttl time.
* threshold and increment: these two fileds are used together to calculate the new created number of prewarmed containers.

How to support `adjust the prewarmed container resource dynamically`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
How to support `adjust the prewarmed container resource dynamically`
The number of prewarmed containers is dynamically controlled when:
* they are expired due to a TTL, some prewarmed containers are removed to save resources.
* cold starts happen, some prewarm containers are created according to the following calculus.
* `# of prewarm containers to be created` = `# of cold starts` / `threshold` * `increment`.
* ex1) `cold start number(2)` / `threshold(2)` * `increment(1)` = 1
* ex2) `cold start number(4)` / `threshold(2)` * `increment(1)` = 2
* ex3) `cold start number(8)` / `threshold(2)` * `increment(1)` = 4
* ex4) `cold start number(16)` / `threshold(2)` * `increment(1)` = 4 (cannot exceed the maximum number)
* no activation arrives for long time, the number of prewarm containers will eventually converge to `minCount`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your description is more accurate, already updated accordingly.

Copy link
Member

@rabbah rabbah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work.

@ningyougang
Copy link
Contributor Author

@style95 @rabbah I almost forgot this pr, it is ready to review again. ^^

Copy link
Member

@style95 style95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a minor nit.

docs/actions.md Outdated
@@ -82,6 +82,84 @@ You can create a new runtime in two ways:
Follow the instructions in [Updating Action Language Runtimes](actions-update.md) for updating, removing or renaming
runtime kinds or language families.

### How prewarm containers are provisioned without a reactive configuration

Prewarmed containers are created when invoker starts, they are created according to runtimes.json's stemCells, e.g.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Prewarmed containers are created when invoker starts, they are created according to runtimes.json's stemCells, e.g.
Prewarmed containers are created when an invoker starts, they are created according to runtimes.json's stemCells, e.g.

docs/actions.md Outdated

The number of prewarmed containers is dynamically controlled when:
* they are expired due to a TTL, some prewarmed containers are removed to save resources.
* cold starts happen, some prewarm containers are created according to the following calculus
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* cold starts happen, some prewarm containers are created according to the following calculus
* cold starts happen, some prewarm containers are created according to the following calculus.

@jiangpengcheng jiangpengcheng merged commit 661ddc5 into apache:master May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants