A long limit lets slow processes finish; a short one shows the error sooner. AWS recommends setting the application's idle timeout higher than the load balancer's: if the application closes the connection first, the load balancer can return a 502.
For SEO, the 504 follows the general 5xx rule: Google's documentation on status codes (4 February 2026) describes the 500, 502 and 503 separately, but not the 504. Its crawlers slow down, ignore the content and keep indexed URLs, "but eventually dropped", with no deadline. What happens when a server error lasts for days is covered in the entry on the 503 error.
A server that does not answer Googlebot at all is a different case. Google treats "network timeouts, connection reset, and DNS errors similarly to 5xx server errors", but without a response there is no status code. According to its page on network errors, crawling slows down immediately, and indexed URLs that cannot be reached are removed from the index "within days".