Part six: Building a highly available system

Single point: The system is deployed on a single machine. If the machine is faulty (hardware damage or network failure), the system becomes unavailable.

Methods to avoid a single point: Load balancing, hot backup, and using multiple equipment rooms

Hot spare can also be understood as keepalived + LVS (Linux VIRTUAL machine)+ Ngnix

Problems in using multiple equipment rooms 1. State synchronization across equipment rooms (to ensure the consistency of multi-master data)

2. Two-phase commit (2PC) ensures consistency

3. Three-phase commit (3PC) for consistency

4. Maintain consistency based on Paxos (as long as most master feedback is successful, not all)

Part seven: Building scalable systems

Vertical scaling refers to the method of upgrading or increasing the hardware of a single machine to support the growth of traffic and data volume. Horizontal scaling refers to increasing the number of machines to support traffic and data growth.

Vertical scaling

Add cpus and memory

Horizontal scaling

Horizontal scaling of cache status 1. Broadcast synchronization: Achieves the consistency of memory information of nodes in the cluster with a certain delay. 2. Distributed cache: memcached and Redis are commonly used for encryption-free login

Horizontal scaling of files 1. Directly connected storage (poor performance and high cost) 2. Network storage (slow read/write speed) 3. Distributed file system (HDFS, Fastdfs)

1. Cache: page static, page fragment cache, data cache 2. Asynchronous database access: Netty can improve database access performance (non-blocking or asynchronous I/O can provide faster feedback results) 4. 5. Distributed database, replication slave database to achieve read/write separation (Mysql replication or Oracle Standby,Mysql supports symmetric and asymmetric replication (production of specific sub-tables))