The application server is the server that handles the website application, the business code of the website is deployed here, is the website development most complex, change most at the same time is the most important, the most basic place. You can say there is no web site without an application server.
Before we introduce the distributed cache, because many of the visitors and the original I, for what is the application server, the concept of what is distributed cache is not clear, so we step-by-step, from the basic concept.
1. Caching Fundamentals
The so-called cache refers to the storage of data in relatively high-speed media, for the system processing. On the one hand cache access speed, can reduce the data access time, on the other hand, if the cached data is calculated, then the cached data can be used without duplication, so the cache will also play a role in reducing the computational time.
The essence of the cache is a memory hash table, in the website application, the data cache is stored in the form of a key-value pair (key,value) in the hash table (do not know the hash table of the self-brain complement).
When it is necessary to read the data in the hash table, we first need to provide the key value of the value pair, the hash function calculates the key value of the hashcode corresponding hash table index, through which the data in the hash table can be accessed quickly.
Cache is mainly used to store the read and write more frequently, rarely changing data, such as hot words, items such as commodities. When the application reads the data, it reads from the cache, accesses the database if it is not read in the cache, or fails the data, and writes the data to the cache.
2. Reasonable use of cache
There are many advantages to using caching to improve system performance, but the use of the cache is unreasonable, but it can not improve the systems, but will cause the system to be cumbersome.
If the data used in the cache is frequently modified, it will cause the data to be written to the cache, the application has not been time to read the data, the data has been invalidated, the burden of the system is increased. In general, the read/write ratio of the data should be more than 2:1 (write a cache, read at least two times before the data is updated), and the cache is meaningful.
The cache uses memory as the storage medium, but in the system, the memory resource is very valuable, it is not possible to cache all the data, only the recently accessed data can be cached, and the historical data will be squeezed out of the cache. If the cached data does not have a hotspot and does not follow the 28 laws of the cache, then the cache is meaningless.
Typically, the cached data is set to expire, and once the expiration time is exceeded, the data is reloaded from the database. So the application needs to tolerate inconsistent data over time. In Internet applications, this delay is generally acceptable, but specific applications also need to be treated with caution (depending on what data can be cached and what not).
Distributed Cache-Cache Fundamentals for Application Server performance optimization