Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Why "gcloud beta code dev" incredibly slow ?

I have a simple Dockerfile:

FROM mcr.microsoft.com/playwright:v1.35.0-jammy

WORKDIR /app

COPY . /app

RUN npm install

CMD ["node", "index.js"]

which doesn't do so much and installs playwrights base image which contains chromium. And I have an express server which takes a screenshot of a page sent to the server (super simple express server with 1 post request). 

My question is when I run the container traditional way `docker run ...` and send an http request to my endpoint it responds super fast which is around 2-3 second (it's fast considering the job 🫣) but when I run my container with gcloud beta code dev it takes 5 minutes to respond. I am not sure why it's super slow. 

I would like to test it with increasing cpu/memory allocation to container but not sure if the gcloud beta code dev accepts in any shape of form resource modifications.

0 1 368
1 REPLY 1

Hi @suchcodemuchwow,

Welcome to the Google Cloud Community!

There are a number of reasons why Cloud Run is running slow.

  1. By default, Cloud Run containers are limited to 1 CPU only. Though you can increase this to a maximum of 8 CPU. You can increase it by running this in the command line. See CPU Limits
    gcloud run services update (name of service) --cpu (number of desired CPU)
  2. By default, Cloud Run also runs on a maximum of  512MiB of memory. You can increase by running the below code in the command line. See Configuring Memory Limits:
    gcloud run services update (name of service) --memory (desired size)
  3. See Starting Containers Quickly. Instances are scaled as needed, so the startup has an effect on the latency of your service. There is something called a Cold Start, this is when a request waits for a new instance to start. This is normal when scaling from zero
  4. You can also get in touch with Google Cloud Support if the above options don't work.

Let me know if it helped, thanks!