PHP FPM 7.1 socket leak causes NGINX - 504 Gateway Time-out PHP FPM 7.1 socket leak causes NGINX - 504 Gateway Time-out nginx nginx

PHP FPM 7.1 socket leak causes NGINX - 504 Gateway Time-out


OK, after a LOT of debugging and testing I've noticed these few causes.

  • Primary Cause for me: The AWS RDS instance that I was using for my MySQL had 500Mb of memory. Looking back, all these issues started once the DB size surpassed 400Mb.

    • Solution: Make sure you have 2x RAM of your DB size at all times. Otherwise the entire B+Tree doesn't fit in the memory, so it has to do constant swaps. This can take your query time upwards of 15 secs.
  • Primary Cause for problems like these: Not optimized SQL queries.

    • Solution: In your localhost maintain data similar to the size of your data on the server.