Graceful restart update (GR mechanism)

Graceful restart update (GR mechanism)

What is smooth start mechanism
  • It is a mechanism to ensure that the forwarding service is not interrupted when the protocol is restarted.
When to use graceful restart
  • Graceful restart is generally used in the process of business update or version release, which can avoid the impact of temporary service unavailability caused by restarting the service due to code release.
ngnix graceful restart and smooth update
  • The Nginx process is divided into the master master process and the work worker process. The master process mainly manages the reception and distribution of event signals. All request processing is processed by the worker process and returns the result. The smooth restart of Nginx or the upgrade of the reload configuration file, etc., the first is Send a restart or reload configuration file signal to the master, then the master tells all the worker processes to no longer accept new requests, then the master starts a new worker process, and finally tells the old worker process to exit gracefully.
  • Smooth update: During the upgrade process, 3 signals (USR2, WINCH and QUIT) are also involved.
    First, the USR2 signal is sent to the original master. The original master process will additionally start a master process and several worker processes. The old and new worker processes provide external services at the same time.
    The second step is to send the WINCH signal, and the original worker process stops the service and exits.
    Finally, send the QUIT signal to the original master to quit, leaving only the new master and worker.
php-fpm graceful restart
  • The reload smooth restart of php-fpm means: Assuming that 50 of the 128 php-cgi processes are processing PHP programs, and the remaining 78 processes are in an idle state, php-fpm will kill it after receiving the smooth restart signal. 78 idle processes, then 128 processes are newly started, and new requests are handed over to the newly started process to handle, and those 50 processes will only be killed after they have finished processing the PHP program they are currently executing.
  • The php-fpm master process understands the following signals:
    • INT, TERM terminate immediately
    • QUIT graceful termination
    • USR1 reopens the log file
    • USR2 gracefully reloads all worker processes and reloads configuration and binary modules
  • Close php-fpm:
    • kill -INTcat /usr/local/php/var/run/php-fpm.pid
  • Gracefully restart php-fpm:
    • kill -USR2cat /usr/local/php/var/run/php-fpm.pid
  • Note that the php-fpm.pid file needs to be opened in the php-fpm.conf configuration file:

    [global]
    ; Pid file
    ; Note: the default prefix is /usr/local/php/var
    ; Default Value: none
    pid = run/php-fpm.pid
    //即,将pid(;pid = run/php-fpm.pid)前的;去掉。

    Reference: https://www.cnblogs.com/justdoyou/p/7152334.html
    http://ask.apelearn.com/question/11387

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324621970&siteId=291194637