random 502 gateway errors with nginx php-fpm and ubuntu

前端 未结 4 1158
长情又很酷
长情又很酷 2021-02-01 23:54

I was having an issue with random 502 gateway errors using nginx and php-fpm. In my case I discovered a scenario where various php.ini error_log settings and error_reporting lev

4条回答
  •  花落未央
    2021-02-02 00:45

    502 gateway errors in Nginx are caused by php-fpm not having enough process and/or timeouts. Logging only tells you what the issues are and are not the cause of 502 errors.

    I use stunnel+haproxy+nginx+php-fpm on 25 servers. The defaults in pfp-fpm are very low, even for a moderately busy server. Configure the fpm child processes much the same way you would with apache mod_php.

    I use the following:

    pm.max_children = 250
    pm.start_servers = 20
    pm.min_spare_servers =10
    pm.max_spare_servers = 20
    pm.max_requests = 1500
    

    This is a server with 2GB ram. It serves 20-30GB traffic per day with no 502's

提交回复
热议问题