spring-bootgoogle-cloud-runhttp-status-code-429

Configure timing of opening ports in Spring-Boot application


Question: Is there an option within spring or its embedded servlet container to open ports when spring is ready to handle traffic?

Situation: In the current setup i use a spring boot application running in google cloud run.

Circumstances:

Problem: Traffic to an unready application will result in a lot of http 429 status codes.

This affects:

My desire:

  1. Configure spring/servlet container to delay opening ports when application is actually ready Delaying opening ports to the time the application is ready would ease much pain without interfering too much with the existing code base.

  2. Any alternatives not causing too much pain?

  3. Things i found and considered not viable

    • Using native-image is not an option as it is considered experimental and consumes more RAM at compile time than our deployment pipeline agents allow to allocate (max 8GB vs needed 13GB)

    • another answer i found: readiness check for google cloud run - how? which i don't see how it could satisfy my needs, since spring-boot startup time is still slow. That's why my initial idea was to delay opening ports


I did not have time to test the following, but one thing i stumbled upon is


Solution

  • As you are well aware of the fact that “Cloud Run currently does not have a readiness/liveness check to avoid sending requests to unready applications” I would say there is not much that can be done on Cloud Run’s side except :

    This question seems more directed at Spring Boot specifically and I found an article with a similar requirement. However, if you absolutely need the app ready to serve when requests come in, we have another alternative to Cloud Run, Google Kubernetes Engine (GKE) which makes use of readiness/liveness probes.