Java Architect-Distributed (1): Distributed cache middleware [Master-slave replication "highly available" Redis cluster]

1. Overview of distributed architecture

Insert picture description here


Microservice architecture is a type of distributed architecture.

1. The difference between single unit, cluster and distributed

Insert picture description here


Insert picture description here
Insert picture description here

2. Advantages of distributed architecture

Insert picture description here

3. Disadvantages of distributed architecture

Insert picture description here

4. Principles of Distributed Architecture Design

Insert picture description here


The power of the distributed system architecture is not only "demolition", but also because it can integrate various "middleware", fault tolerance and high availability.

  • Asynchronous decoupling
  • Not only module code decoupling, but also communication between modules should be decoupled as much as possible. [Message queue realizes communication decoupling]
  • Idempotent consistency
  • The user's request may go through multiple subsystems. It is necessary to ensure that there is only one copy of the final database operation, that is, to ensure the consistency of the database data (mainly for the "increase" and "reform" of the database).
  • Split principle
  • It can be split according to various standards, such as: portal subsystem, user center subsystem, search subsystem, file processing subsystem...
  • Converged distributed middleware
  • For example: Redis cache middleware, Zookeeper middleware, message queue
  • Fault tolerance and high availability

5. Drawbacks of Keepalived + LVS + Nginx "Highly Available" cluster architecture

Insert picture description here


When the number of system visits increases, the pressure on the database will be very heavy . Use distributed cache Redis database to provide system concurrency.

Insert picture description here

6. NoSql

Insert picture description here
Insert picture description here

7. Distributed cache

Insert picture description here

8. What is Redis

Insert picture description here

9. Comparison of caching schemes

9.1 Ehcache (suitable for single application)

Insert picture description here

9.2 Memcache (Nosql, distributed, non-persistent, string only)

Insert picture description here

9.3 Redis (Nosql, distributed, persistent, rich data structure)

Insert picture description here