Managing high timeout request using the Slow pool
Within the config tab you can find the Slow pool.
Slow or long requests
The default timeout on the gateway is 30 seconds per HTTP request. When you have requests that take longer than 30 seconds, you will encounter a 504 Gateway Time-out error.
The correct way to deal with timeouts
Slow or long running requests should ideally be dealt with at the application level:
-
Optimize your code.
-
Make sure the downtime of third party services does not affect your application: implement reasonable timeouts in your code! A third party service becoming unavailable should not stop your application from functioning properly. If your application core relies on this service, it should return a clean error and never cause timeouts.
-
Push long running actions, such as PDF generation or parsing jobs, on a queueing system and let them run in the background. If you’re dealing with legacy code, this will not always be easy to accomplish though.
Enter the slow pool
The slow pool will allow you to define a list of paths for your application that require a higher timeout on the gateway. All of these paths will get a timeout of 3600 seconds. The paths that are NOT in this list will not be affected and will still receive a timeout after 30 seconds.
Again: this is not the ideal solution but will help you to easily migrate legacy services or handle sudden issues as they pop up while a proper fix is being implemented.
Remarks
Saving the slow pool settings will also apply any port configurations that are saved.
The slow pool will only affect gateway timeouts! There are various other timeouts, such as PHP execution time for example. You will need to make sure your applications timeouts are set long enough to not cause a timeout at this level as well.