The essence of the problem is that if the server with the application falls, the requests will go to another, and the same problem with the servers mysql and redis.

  1. Server: To guarantee server fault tolerance, is it enough to buy 2 servers and register them for one domain?
  2. DB (Mysql): Make 2 masters to link to each other, and if one falls, will all requests go to another? And how to make the application itself know on which mysql / redis server to send requests, the same trick to do with the server?

Tell me how you can solve this problem?

Scheme:

enter image description here

    2 answers 2

    In your case, you need to implement a load balancer based on NGINX (module ngx_http_upstream_module). It will accept requests for the specified domain and redirect them to a free or less loaded backend (application server). For databases, you need to configure the Master and Slave server and make replication between them.

      To ensure fault tolerance, you can also create a pacemaker-based linux cluster from two or more nodes (servers), create a service IP with a name that will rise on one of the cluster nodes. Applications connect to the database for this service name. All nodes should ideally be located in different data centers, otherwise failover will not occur.