google-cloud-run

How to read CPU cores available in Cloud Run environment?


We see there are environmental variables available to read to get port/service/revision of a Cloud Run service.

In order to configure a multithreaded app, like gulp threads. How do you read how many cores are available?

Snippet:

# For environments with multiple CPU cores, increase the number of workers
# to be equal to the cores available.
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app

Solution

  • I believe this information is not available from within Cloud Run.