Search code examples
google-cloud-rungcp-secret-manager

The frequency of loading Secret Manager in Cloud Run


I am considering migrating my current web services to Cloud Run. In Cloud Run's "Variables and Secrets", if we use Secret Manager to mount environment variables and credential files, how often will Secret Manager be read by which of the following?

  1. Whenever a web service is accessed.
  2. Every time an instance is created
  3. Whenever a revision is deployed
  4. other (I would appreciate it if you could tell me)

Currently, the web service is accessed by about 300 people per minute, and I expect that if 1 or 2 is selected, the number of accesses to the Secret Manager will increase and the billing amount will increase. If you have any best practices, I would appreciate it if you could share them with me.

Thank you in advance for your help.


Solution

  • The answer depends on the code in your container. Typically each container would access Secret Manager on container start and hold those variables in the global namespace.

    Using global variables

    How many containers depend on how many simultaneous requests can be handled by each container.

    How often a container is started and stopped depends on how frequently requests arrive. When a container is not processing requests it is eligible to be stopped. For your use case (300 requests per minute), consider the Always On option so that a minimum number of containers are always running.