Sometimes, we may calculate multiple servers based on IP. Users in the south choose the server in the south, and those in the north choose the server in the north. However, we gradually find that there are often errors in using IP statistics. I have thought about using ping on the client before. The method is to see which server has a fast connection, but at least the user needs to install a plug-in. Now think about it, it seems that using js can also solve part of the problem
Calculated based on the difference between d2 and d1 The download speed of each server and client is stored in the cookie, and then compared, the faster one is selected. And after a certain period of time, the cookie is updated to make corrections.