Home Database Redis What is redis avalanche

What is redis avalanche

Jun 04, 2019 am 10:32 AM
redis

What is redis avalanche? The following article will give you a brief introduction, I hope it will be helpful to you.

What is redis avalanche

What is an avalanche?

Because the cache layer carries a large number of requests, it effectively protects the storage layer. However, if the cache as a whole cannot provide services for some reasons, all requests will arrive. Storage layer, the number of calls to the storage layer will increase dramatically, causing the storage layer to also hang up. The English explanation of cache avalanche is running bison, which means that after the cache layer crashes, concurrent traffic will access back-end storage in large quantities like galloping bison.

The simple understanding of cache avalanche is: due to the failure of the original cache (or the data is not loaded into the cache), during the period when the new cache has not arrived (the cache is normally obtained from Redis, as shown below) all the cache should have been accessed All requests go to query the database, which puts huge pressure on the database CPU and memory. In severe cases, it can cause database downtime and system crash.

What is redis avalanche

The cache failure is as shown below:

What is redis avalanche

One scenario where this problem exists is: when the cache server is restarted Or a large number of caches may fail in a certain period of time, so when they fail, a large amount of data will directly access the DB, which puts a lot of pressure on the DB.

The avalanche effect when the cache fails has a terrible impact on the underlying system! So what are the solutions to this problem?

Solution

1) Set up the high availability of the redis cluster and DB cluster. If redis goes down, it can be replaced by another machine immediately. This can prevent some risks.

2) Use mutex locks

After the cache expires, control the number of threads reading and writing the database through locking or queuing. For example: only one thread is allowed to query data and write cache for a certain key, while other threads wait. If it is a stand-alone machine, you can use synchronized or lock to solve it. If it is a distributed environment, you can use the redis setnx command to solve it.

3) For different keys, you can set different expiration times to make the cache invalidation time points inconsistent and try to achieve an even distribution.

4) Never expire

Setting the permanent non-expiration setting in redis ensures that there will be no hot spots, that is, it will not expire physically.

5), Resource Protection

Using Netflix's hystrix, you can isolate the thread pool of various resources to protect the main thread pool.

The above is the detailed content of What is redis avalanche. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

Hot Article

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution to 0x80242008 error when installing Windows 11 10.0.22000.100 Solution to 0x80242008 error when installing Windows 11 10.0.22000.100 May 08, 2024 pm 03:50 PM

Solution to 0x80242008 error when installing Windows 11 10.0.22000.100

How to change the password in redis How to change the password in redis Apr 20, 2024 am 03:00 AM

How to change the password in redis

Analyze PHP function bottlenecks and improve execution efficiency Analyze PHP function bottlenecks and improve execution efficiency Apr 23, 2024 pm 03:42 PM

Analyze PHP function bottlenecks and improve execution efficiency

Is redis a memory cache? Is redis a memory cache? Apr 20, 2024 am 05:26 AM

Is redis a memory cache?

Golang API caching strategy and optimization Golang API caching strategy and optimization May 07, 2024 pm 02:12 PM

Golang API caching strategy and optimization

Is redis a non-relational database? Is redis a non-relational database? Apr 20, 2024 am 05:36 AM

Is redis a non-relational database?

Caching mechanism and application practice in PHP development Caching mechanism and application practice in PHP development May 09, 2024 pm 01:30 PM

Caching mechanism and application practice in PHP development

Which one has better performance, erlang or golang? Which one has better performance, erlang or golang? Apr 21, 2024 am 03:24 AM

Which one has better performance, erlang or golang?

See all articles