Does Google Cloud Run memory limit apply to the container size?

和自甴很熟 提交于 2020-07-09 05:59:31

问题


For cloud run's memory usage from the docs (https://cloud.google.com/run/docs/configuring/memory-limits)

Cloud Run applications that exceed their allowed memory limit are terminated.

When you configure memory limit settings, the memory allocation you are specifying is used for:

  • Operating your service
  • Writing files to disk
  • Running binaries or other processes in your container, such as the nginx web server.

Does the size of the container count towards "operating your service" and counts towards the memory limit?

We're intending to use images that could already approach the memory limit, so we would like to know if the service itself will only have access to what is left after subtracting container size from the limit


回答1:


Size of the container image you deploy to Cloud Run does not count towards the memory limit. For example, if your container image is 3 GiB, you can still run on a 256 MiB memory environment.

Writing new files to local filesystem, or (obviously) allocating more memory within your app will count towards the memory usage of your container. (Perhaps also obvious, but worth mentioning) the operating system will "load" your container's entrypoint executable to memory (well, to execute it). That will count towards the available memory as well.




回答2:


Cloud Run PM here.

Only what you load in memory counts toward your memory usage. So for example, if you have a 2GB container but only execute a very small binary inside it, then only this one will count as used memory.

This means that if your image contains a lot of OS packages that will never be loaded (because for example you inherited from a.big base image), this is fine.



来源:https://stackoverflow.com/questions/56567944/does-google-cloud-run-memory-limit-apply-to-the-container-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!