tengine 흔 한 오류 코드 정리 및 원인 분석

4996 단어 NGINX
403 Forbidden
You don’t have permission to access the URL on this server. Sorry for the inconvenience. Please report this message and include the following information to us.
해결: 권한 파일 권한 보기
500
이 웹 페이지 는 www. test. com 을 제대로 작 동 하지 못 해 현재 이 요청 을 처리 할 수 없습니다.HTTP ERROR 500
원인:
  • php 문법 오류, lua 문법 오류 등 웹 스 크 립 트 오류.
  • 방 문 량 이 많 을 때 시스템 자원 제한 으로 인해 너무 많은 파일 핸들 을 열 수 없습니다
  • 스 크 립 트 실행 시간 은 (max execution time, request terminate timeout] 사이 에 있 습 니 다. (request terminate timeout) 을 초과 한 경우 소개 합 니 다
  • 장면 재현:
    php. ini 설정:
    max_execution_time = 5    ; Maximum execution time of each script, in seconds
    
    

    php - fpm 설정:
    request_terminate_timeout = 30
    

    php_code:
    $start = time();
    while(true) {
       if (time()-$start > 5) {
     		die("game over");
     	}
    }
    

    해결 방법:
  • 코드 의 정확성 확보
  • max execution time 과 request terminate timeout
  • 을 정확하게 설정 합 니 다.
  • 오래 걸 리 는 스 크 립 트 를 실행 해 야 하고 php. ini 를 수정 하고 싶 지 않 으 면 set time limit (0) 을 추가 할 수 있 습 니 다.
  • 504 Gateway Time-out
    The gateway did not receive a timely response from the upstream server or application. Sorry for the inconvenience. Please report this message and include the following information to us. Thank you very much!
    장면 재현:
    PHP 코드:
    
    

    tengine 설정:
    // fastcgi      ,  60 
    fastcgi_connect_timeout 10;
    
    // tengine     fastcgi              
    fastcgi_send_timeout 10;
    
    //fastcgi     tengine              
    fastcgi_read_timeout 10;
    
    

    원인 중 하나: 게 이 트 웨 이 시간 초과 원인 프로그램 실행 시간 이 tengine 설정 시간 초과 로 게 이 트 웨 이 시간 초과
    해결 방법:
  • 최적화 코드 (이것 이 관건)
  • tengine 시간 초과 조정 (프 록 시 connect timeout, proxy send timeout, proxy read timeout)
  • 502 Bad Gateway
    The proxy server received an invalid response from an upstream server. Sorry for the inconvenience. Please report this message and include the following information to us. Thank you very much!
    장면 재현:
    php. ini 설정:
    max_execution_time = 30     ; Maximum execution time of each script, in seconds
    

    php - fpm 설정:
    request_terminate_timeout = 10
    

    php 코드:
    
    

    실행 후 tengine 로그
    2018/09/21 15:01:50 [error] 32753#0: *8 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 10.33.65.83, server: www.test.com, request: "GET /a.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:8721", host: "www.test.com"
    

    php - fpm 로그:
    [21-Sep-2018 16:57:43] WARNING: [pool test] child 824, script '/home/test/www/htdocs/a.php' (request: "GET /a.php") executing too slow (3.963645 sec), logging
    [21-Sep-2018 16:57:43] NOTICE: child 824 stopped for tracing
    [21-Sep-2018 16:57:43] NOTICE: about to trace 824
    [21-Sep-2018 16:57:43] NOTICE: finished trace of 824
    [21-Sep-2018 16:57:44] WARNING: [pool test] child 824, script '/home/test/www/htdocs/a.php' (request: "GET /a.php") execution timed out (4.964827 sec), terminating
    [21-Sep-2018 16:57:44] WARNING: [pool test] child 824 exited on signal 15 (SIGTERM) after 683.779281 seconds from start
    [21-Sep-2018 16:57:44] NOTICE: [pool test] child 838 started
    
    

    php - fpm 로그 에서 824 프로 세 스에 요청 한 것 을 볼 수 있 습 니 다. 그러나 스 크 립 트 가 실 행 된 시간 이 request terminate timeout 시간 을 초과 하여 824 가 종료 신 호 를 받 았 고 824 가 종료 한 후에 838 프로 세 스 를 새로 시 작 했 습 니 다.
    php - fpm 의 worker 프로 세 스 가 시간 초과 (request terminate timeout 초과) 를 실행 하면 스 크 립 트 실행 을 중지 할 뿐만 아니 라 worker 프로 세 스 도 종 료 됩 니 다. 다음 에 새로운 프로 세 스 를 시작 합 니 다. 이번 502 의 원인 은 tengine 의 오류 연결 이 리 셋 된 것 은 php 의 worker 프로 세 스 가 종료 되 었 기 때 문 일 수 있 습 니 다.
    원인:
  • 스 크 립 트 가 request terminate timeout 시간 을 초과 하여 502
  • 가 발생 합 니 다.
  • 백 스테이지 워 커 의 수량 부하 가 크 거나 너무 적어 서 새로운 요청 이 워 커 처리 되 지 않 아 502
  • 대량의 warning 으로 인해 발생 (https://mp.weixin.qq.com/s/-3XBN1_ru2jF3P-rakOjKg)
  • php. ini 의 memory limit 이 너무 작 습 니 다 [고증 대기]
  • phop - fpm. conf 에서 max children, max requests 설정 이 합 리 적 이지 않 습 니 다.
    해결 방법:
  • request terminate timeout 을 합 리 적 으로 수정
  • pm. max children, pm. start server, pm. min spare server, pm. max spare server, pm. max requests
  • 를 합 리 적 으로 설정 합 니 다.
    499
    주로 클 라 이언 트 요청 시간 이 초과 되 었 습 니 다 (클 라 이언 트 설정 시간 초과, 예 를 들 어 CURL 이 서버 api 를 호출 할 때).
  • 서버 에서 느 린 조회 로 인해 클 라 이언 트 요청 시간 초과
  • 클 라 이언 트 의 시간 초과 시간 을 합 리 적 으로 조정
  • (번 외) PHP 가 데이터 베 이 스 를 읽 는 최대 실행 시간:
    php. ini 설정
    mysqlnd.net_read_timeout = 5 
    

    PHP 가 데이터 베 이 스 를 읽 는 최대 실행 시간 을 초과 하면 Mysql server has gone away 에 보고 합 니 다.
    참고 자료:https://blog.tanteng.me/2016/03/nginx-buffer-params/ https://www.cnblogs.com/leezhxing/p/6220879.html
    추천 자료:https://blog.csdn.net/Mijar2016/article/details/53709777

    좋은 웹페이지 즐겨찾기