LAMP architecture, how to deploy and manage multiple servers for one domain name if users are distributed in various countries around the world

LAMP architecture, how to deploy and manage multiple servers for one domain name if users are distributed in various countries around the world?

1. How to resolve a domain name to a different server IP?

2, there will be multiple programs and databases on multiple servers, how to effectively manage and maintain code and database Synchronize?

3. How to let users automatically judge when they visit and call a nearby server to provide services?

Tip: hope to provide a detailed description of the operational process

Mar.23,2022

  1. DNS sub-region resolution, according to different regions and countries to resolve to different servers. I took a casual look at Tencent Cloud's analysis service. As long as the money is in place, it can be divided according to country, continent and network.
    or resolve to a sub-domain name directly, such as xxx.com -> zh.xxx.com , and then different sub-domain names correspond to different regional servers.
  2. Code Synchronize writes scripts by itself or uses tools, such as puppet . If you are afraid that there will be problems with different server codes, you can only shut down access to part of the machine first, and then update this part of the server. After the update, turn on this part of the access and close the access to the old code server, so that the code will not be different at the same time.
    Database Synchronize is rather complex, involving cross-server room Synchronize issues. If only one node allows writes and does not require strong consistency (final consistency), then there is no problem, at most, there is a little delay in the data. Group replication of MySQL claims that multiple nodes can write data at the same time, but the cost is that the operation time of a transaction is higher.
  3. you can do this by using DNS province resolution, and you can also use the dynamic acceleration network of CDN to automatically determine the best origin server.

  1. DNS parsing can support sub-network lines (such as Telecom, Unicom, Education Network), domestic or even provincial
    China Telecom's DNS hijacking, China GFW's DNS poisoning, to learn (on how Google is blocked in China)
  2. The Synchronize of
  3. code is, of course, manual operation, automated deployment tools, platforms, and Synchronize of various (Docker, TFS)
    databases. There are many schemes according to the tolerance to delay, for example, MySQL has master-slave replication, for example, various message queues, such as using scheduled tasks such as Synchronize, etc.
  4. DNS sub-region parsing is an entrance to the optimal solution
    , and then the program judges that it can jump again (for example, google.com will jump to google.com.hk and so on)

1 and 3 use load balancer. Aliyun has SLB . If you want to build it yourself, search LVS load balancer for a lot of related information.
2. It is best to use the CI/CD tool for the code. If the database is shared by all servers, then the deployment and implementation is not a small problem, and a special DBA is needed to help you do it.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3285d-2be39.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3285d-2be39.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?