background

In a company project, there is basically a common service: data dictionary service; Typically, applications use the interface provided by the data dictionary service to obtain the latest data dictionary. This implementation has the following problems:

  • In general, networks need to be considered unreliable, and this implementation fails to meet the high availability (99.99%) criteria
  • Retrieving the latest data dictionary through the interface will result in high concurrency of the interface, which will require more servers to support and waste resources
  • Through the interface access, there will be network transport consumption

Based on this, we can consider to do a redis cache the data dictionary, but even use the redis cache, also there is a certain degree of network transmission on consumption, in practical applications, the data dictionary is the data change frequency is very low, can be cached in application, reduce access to redis, improve the response speed.

1. Overall design

1.1 Basic Model

The basic model is shown above:

  1. Users can add or modify dictionaries on the data dictionary management platform
  2. The data dictionary management platform notifies the data dictionary client of dictionary updates
  3. Data Dictionary pulls the latest dictionary from the data dictionary management platform and updates the local configuration

Second, server design

2.1 Design of real-time push after publishing dictionary

In the dictionary service management platform, an important function is to push the dictionary modification to the client in real time. Let’s take a quick look at how this is implemented.

2.1.1 Implementation of sending messages

We use Redis Messaging (Pub/Sub), of course you can also use MQ, ZK, etc.

Iii. Client design

Why Caffeine

Caffeine is a high-performance cache library based on JAVA 1.8 Version. Caffeine’s memory cache uses the Google Guava API. Caffeine is based on Google’s experience in designing The Guava Cache. Caffeine is significantly more efficient than other caches

Reference documentation

VX: AAAMAXIAOXIN