I want to resolve a 504 gateway timeout error in Amazon OpenSearch Service.
Resolution
Each OpenSearch Service domain's load balancer distributes incoming traffic to the data nodes. If OpenSearch Service requests don't complete and return a confirmation within the idle timeout period, then the load balancer closes the TCP connection. As a result, you receive an HTTP 504 gateway timeout error.
Gateway timeout errors typically occur when you send too many requests at the same time or when you send complex requests.
To resolve an HTTP 504 gateway timeout error, take one or more of the following actions:
- Turn on slow logs for your OpenSearch Service index, and then specify logging thresholds. Slow logs can help you identify queries that take a long time to complete. Tune the queries to resolve the 504 error. For more information, see Monitoring OpenSearch logs with Amazon CloudWatch Logs.
- Reduce the amount of data that OpenSearch Service must query for the requests so that requests take less time to complete.
- Switch to a larger instance type.
- Configure exponential backoff and retry mechanisms in your application so that requests that time out are sent again.
- Use bulk requests instead of individual requests to reduce the overhead for each request for the cluster.
Related information
How do I resolve an HTTP 503 Service Unavailable error in OpenSearch Service?
Creating and managing Amazon OpenSearch Service domains