Note: This only describes the situation of a single server. Docker Container is mapped to different ports. Docker Container provides external services through tomcat.
1. As shown in the figure, if the reverse proxy server sends a request, After the request reaches Nginx, assuming it matches the Upstream of Service A, it will be assigned to port 10100 or 10101 according to the corresponding distribution algorithm in nginx.conf.
2. Assume that the tomcat in the docker container corresponding to 10100 hangs ( Usually it is because the available memory held by the container is insufficient, causing the tomcat in the container to be killed.)
3. At this time, the request is assigned to port 10100, which will result in 404.
4. If At this time, we make a copy of the traffic and add a timeout. Then when the request is sent to 10100, after timeout or 404, the copied traffic is sent to port 10101.
The above has introduced how to solve the problem of unresponsiveness of a certain service node through traffic replication, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.