I'm working with backend with nodejs project, and this is my first deployment project. I notice the "it work on my computer" kind of error, when I try my API in localhost it always work, but when I dockerize and deploy to Cloud Run, I found that it worked, and all my API returned pretty fast, the longest need about 10s, so I set 180s as timeout in Cloud Run. But a few hour later my team informed me that my API is down and I checked it and found that all the last request return with 504. I even tested it and it didn't worked. But soon I ran the same code in local and it worked.
I did some research and found that this can be happen if some process still running and block all the resources. But when I saw the metrics:
Seems like CPU and memory utilization weren't high at the time of error (9PM). I know this is not a good practice, but can I restart my container every time it hit 504 error? Not like re-deploy, I mean the container just need to run npm run start
again
Cloud Run supports liveness checks, where you can have it send a request to a specific endpoint periodically and if that request fails, it'll terminate the instance and start a new instance the next time it needs one.