英文:
Can cloud run restart my container every time it hit 504 error?
问题
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.
英文:
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
答案1
得分: 1
Cloud Run支持活性检查,您可以定期向特定端点发送请求,如果请求失败,它将终止实例,并在下次需要时启动新实例。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论