Why am I getting a "504 Timeout" error when deploying a microservice Docker image on cloud using MATLAB Compiler SDK R2024b?

I am using the "compiler.build.productionServerArchive" and "compiler.package.microserviceDockerImage" functions to package my code into a microservice Docker image and run it on Google Cloud Run. The system is configured so that the container is suspended when not receiving requests and then resumed when requests are received, in order to save on unutilized computing cost. However, after a few weeks, I receive a "504 Timeout" error when sending a request. I am able to resolve the error by rebuilding and redeploying the microservice Docker image. 
Why is this error occurring and how can I resolve the issue without rebuilding my image?

 采纳的回答

When a microservice Docker image is suspended for a long period of time with no activity, it may remain unresponsive to new requests, causing the "504 Timeout" error. To resolve the issue while meeting your original criteria, you can implement one of the following two solutions:
  1. Scale the container to zero and have it restart from scratch when the requests come in. If you plan on running bursts of multiple requests in between idle periods, the startup time would be amortized. 
  2. You can keep the container running and query the health or metrics endpoints periodically to ensure uptime at the expense of extra running costs. This works if the clients originating the requests are sensitive to the cold start delay and the requests are infrequent enough that the container cold start would be experienced by a majority of requests (no amortization).

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Containers 的更多信息

产品

版本

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by