Skip to content

App Runner 503 HTTP errors during deployments

0

Hi all,

Every time we deploy to our production App Runner, our clients (React apps) experience 503 errors coming from the App Runner server when making requests to it.

The 503 errors start as soon as the deployment is marked as “finished” in App Runner and come from the instances that are being shut down. It seems like App Runner continues to route traffic to the old instances for a few seconds after the deployment has completed, which results in 503 errors.

The errors appear to be coming from the load balancer component, which is abstracted away. We have observed 503 responses with the message: “upstream connect error or disconnect/reset before headers. Reset reason: connection failure."

Any have any ideas on how to prevent this from happening, or has experience this issue ? any help is greatly appreciated.

Additional info about our App Runner set up:

Deployment Deployment method: Automation Source: Docker ECR image, NodeJS express app

Auto scaling Concurrency: 200 Minimum size: 8 Maximum size: 25

Health check

Protocol: HTTP Path: /health-check Timeout: 10 seconds Interval: 11 seconds Unhealthy threshold: 5 requests Health threshold: 5 requests

asked 2 years ago592 views

1 Answer
1

The 503 errors you're experiencing during deployments are likely due to the way App Runner handles traffic routing during the transition between old and new instances. This is a common challenge in blue-green deployments, which App Runner uses internally.

To mitigate this issue, you can try the following approaches:

  1. Implement a graceful shutdown in your application. When your Node.js Express app receives a SIGTERM signal (which App Runner sends before terminating an instance), it should stop accepting new requests but continue processing existing ones. This can help reduce the number of in-flight requests that get cut off.

  2. Increase your health check interval and threshold. By increasing the health check interval to something like 30 seconds and the healthy threshold to 10 requests, you give your new instances more time to warm up and become ready before they start receiving traffic.

  3. Implement connection draining in your application. This involves keeping the old instances alive for a short period after new instances are ready, allowing in-flight requests to complete.

  4. Consider implementing retry logic in your client applications. This can help handle temporary 503 errors during deployments.

  5. If possible, stagger your deployments or perform them during low-traffic periods to minimize the impact on users.

  6. Ensure your application starts quickly and is ready to handle requests as soon as possible after launch. Slow startup times can exacerbate issues during deployment.

  7. You already implemented increased auto scaling with a minimum size greater than 1. This means that even if one instance is being replaced during a deployment, others are still available to handle incoming requests

Remember, some level of errors during deployments is often unavoidable, especially in high-traffic scenarios. The goal is to minimize their occurrence and impact on your users.

Sources
App runner auto deployment problem with ECR image tag | AWS re:Post
App Mesh connectivity troubleshooting - AWS App Mesh App Runner Startup Time

answered 2 years ago

AWS
SUPPORT ENGINEER

revised 2 years ago

  • I implemented a graceful server shutdown by listening for SIGTERM, but 503 errors continue to occur during deployment. I’ve noticed that the 503 errors stop once SIGTERM is fired on the instances being scaled down. However, several minutes before SIGTERM is fired, the old instances are no longer handling any requests, and this is when the 503 errors occur. I’m wondering if SIGTERM needs to be triggered much earlier so the load balancer stops trying to route requests to them ?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.