CN107256235A - A kind of caching system hot spot data access method - Google Patents
A kind of caching system hot spot data access method Download PDFInfo
- Publication number
- CN107256235A CN107256235A CN201710357388.4A CN201710357388A CN107256235A CN 107256235 A CN107256235 A CN 107256235A CN 201710357388 A CN201710357388 A CN 201710357388A CN 107256235 A CN107256235 A CN 107256235A
- Authority
- CN
- China
- Prior art keywords
- focus
- key
- server
- hotkey
- data access
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0806—Multiuser, multiprocessor or multiprocessing cache systems
- G06F12/0842—Multiuser, multiprocessor or multiprocessing cache systems for multiprocessing or multitasking
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0844—Multiple simultaneous or quasi-simultaneous cache accessing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/12—Replacement control
- G06F12/121—Replacement control using replacement algorithms
- G06F12/123—Replacement control using replacement algorithms with age lists, e.g. queue, most recently used [MRU] list or least recently used [LRU] list
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
- G06F16/24552—Database cache management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/526—Mutual exclusion algorithms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/10—Providing a specific technical effect
- G06F2212/1012—Design facilitation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/16—General purpose computing application
- G06F2212/163—Server or database system
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Databases & Information Systems (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
The invention discloses a kind of caching system hot spot data access method, comprise the following steps:S1:Increase HotKey modules on redis DS, acquiescence DS opens HotKey modules after starting, controlled at any time with interface after start and stop focus statistics function, focus statistics function on, do related initialization;S2:By the HotKey logic adds of server identification focus in worker threads, each read request for reaching server competes one and try is locked first, after acquisition is locked successfully, and experienced three stages, statistics successfully passes through the request of three phases;S3:When server end feedback has focus generation, the key in the feedback bags is write local cache by client first, while opening hot running patterns.The present invention makes an amendment on the basis of original cluster, does not change clustered deploy(ment), transparent to application, and method is simple, easy to use.
Description
Technical field
The present invention relates to data access technology field, more particularly to a kind of caching system hot spot data access method.
Background technology
Redis is the widely used distributed K-V caching systems of current enterprise, when being written and read on this system, can root
Calculate a fixed server to access the K-V according to key hash;Therefore in actual applications, some peak periods, meeting
Same Key (some commodity sales promotion, hot news, focus comment of application etc. may be corresponded to) is largely asked, according to key's
Hash, all read requests will be all fallen on same server, and the load of the machine will seriously aggravate, and now whole system increases
Plus server is also without any use, because according to hash algorithm, same key request still can fall on same new engine
On, the machine turns into system bottleneck;This problem is referred to as " focus key " problems;
Solving hot issue has many methods, if can not split focus from the angle of business, then can only take many
The form of number evidence is shared (C/S shares, and shares between service end cross-thread, machinery compartment, cluster);If such as user knows in advance
Some key are likely to become focus, then client can split focus key in advance;A standby cluster can also be built, is write
When it is double write, it is then random double to read;These schemes have respective shortcoming;Therefore, we have proposed a kind of caching system focus
Data access method is used to solve the above problems.
The content of the invention
The technical problem existed based on background technology, the present invention proposes a kind of caching system hot spot data access method.
A kind of caching system hot spot data access method proposed by the present invention, comprises the following steps:
S1:On redis DS increase HotKey modules, acquiescence DS start after open HotKey modules, with interface with
When control start and stop focus statistics function, after focus statistics function on, do related initialization;
S2:The HotKey logic adds that server is recognized into focus are in worker threads, and the reading for each reaching server please
Ask competition one first that try is locked, after acquisition is locked successfully, experienced three stages, statistics successfully passes through the request of three phases;
S3:When server end feedback has focus generation, client first writes the key in the feedback bags
Local-cache, while open hot-running patterns, under the pattern can only write service end feedback marked with focus
Non-hot key will progressively be eliminated in key, local-cache.
Preferably, in the S1, DS is dataserver.
Preferably, in the S1, correlation initialization includes the opcode sequences of operation to be paid close attention to during setting statistics focus key
List, setting sampling number, setting focus QPS threshold values, setting server end focus key maximum sizes and each focus key exist
The life cycle of server.
Preferably, in the S2, three phases include sample phase, positioning stage and inquiry phase.
In the present invention, a kind of caching system hot spot data access method is made an amendment on the basis of original cluster, no
Change clustered deploy(ment), it is transparent to application;It is broadly divided into two module service end focus statistics and client Localcache logics;
Focus statistics logic is operated above in data-server, to the read request of each arrival, key is extracted and is counted, and count
The focus key in current request is calculated, while as the exactly hot key of client access, then returning a focus to client anti-
Present feedback bags;Client is received after feedback bags, and the hot-key of carrying just is write into client local-cache,
Refuse non-thermal key write-ins local-cache simultaneously, method is simple, easy to use.
Embodiment
The present invention is made with reference to specific embodiment further to explain.
Embodiment
The present embodiment proposes a kind of caching system hot spot data access method, comprises the following steps:
S1:On redis DS increase HotKey modules, acquiescence DS start after open HotKey modules, with interface with
When control start and stop focus statistics function, after focus statistics function on, do related initialization;
S2:The HotKey logic adds that server is recognized into focus are in worker threads, and the reading for each reaching server please
Ask competition one first that try is locked, after acquisition is locked successfully, experienced three stages, statistics successfully passes through the request of three phases;
S3:When server end feedback has focus generation, client first writes the key in the feedback bags
Local-cache, while open hot-running patterns, under the pattern can only write service end feedback marked with focus
Non-hot key will progressively be eliminated in key, local-cache.
In the present embodiment, in S1, during DS is dataserver, S1, correlation initialization includes wanting during setting statistics focus key
The opcode sequences of operation list of concern, setting sampling number, setting focus QPS threshold values, setting server end focus key capacity
The upper limit and each focus key are in the life cycle of server, and in S2, three phases include sample phase, positioning stage and inquiry
A kind of stage, caching system hot spot data access method is made an amendment on the basis of original cluster, does not change clustered deploy(ment), correspondence
With transparent;It is broadly divided into two module service end focus statistics and client Localcache logics;I.e. on data-server
Focus statistics logic is run in face, to the read request of each arrival, is extracted key and is counted, and calculate in current request
Focus key, while as the exactly hot key of client access, then returning a focus to client and feeding back feedback bags;Client
End is received after feedback bags, and the hot-key of carrying just is write into client local-cache, write while refusing non-thermal key
Enter local-cache, method is simple, easy to use.
In the present embodiment, sample phase comprises the following steps:
S1, judge the opcode of this request whether inside the opcode lists of configuration;
S2,1024 buckets of maintenance, are hashing onto bucket by the pick-key in each request, record the hits of each bucket, remember
Record present sample number of times (the key forms during redis is each asked have pkey-skey, multi-key, single-key etc.,
How the live part in them is counted, behind describe in detail, effective key is referred to as here for pick-key);
S3, when sampling number reaches sample_max (server configuration), calculate the standard deviation and average of these barrels, together
When write down maximum barrel number;
If the standard deviation of S4, these barrels is more than N times (setting coefficient) of average, then it is assumed that there is focus, when maximum
The QPS of barrel number is more than threshold value, then maximum barrel number is exactly current hot bucket, into positioning stage, while into next sampling
Cycle.
That is hot spot phenomenon judgment formula is:
The standard deviation that all barrels of count is counted>The average * N (coefficient) that the count of these barrels is counted.
Positioning stage comprises the following steps:
S1, the request for having hit hot bucket for reap_max times next can be counted again, calculate each pick- in hot bucket
Key access times, count reap_max stopping;
S2, X pick-key for selecting counting maximum, if some of X pick-key QPS is more than threshold value,
These key are identified as hot key;
S3, the pick-key addition server focus LRU chained lists that hot will be determined as, while into next locating periodically,
Discharge this try locks.
Inquiry phase comprises the following steps:
S1, each read request to reaching server, can all take out pick-key, then inquire about server LRU chained lists;
If S2, hit, focus is labeled as to the pick-key;
After S3, the request terminate, a feedback bag can be additionally sent, focus key is carried, client is notified;
S4, so far, server hot-key logics terminate.
The present embodiment depends on the Local-cache of redis clients, and it is the caching function that redis clients are carried,
The key-value of write service device can be buffered in local reading, its capacity is very limited;It should be noted using local-cache
Following detailed problem:
1st, it is how synchronous between Localcache and redis-server
After client opens cache functions, each local cache of write operation Force Deletion key, during read operation, more
The value of new back-end server is to local cache.
2nd, Localcache data are eliminated
Because client machine configures limited, Localcache can only cache part K-V;Therefore client Localcache
There are two kinds of eliminative mechanisms excessive to prevent memory consumption, expired eliminate is evicted from capacity.
It is expired to eliminate, i.e., after reading server is operated successfully, when updating Localcache, each key can be set one
The rational expired time (acquiescence 30ms) in Localcache;It is that multithreading is visited mostly during using using redis clients
Ask;Just think when multiple threads find that some key survival exceedes expired time, what processing can be doneHave a large amount of requests
Puncture Localcache, access rear end redis.
In order to solve the problems, such as such mighty torrent, the operation for having added an expired time to renew here;When multiple threads are concurrent
When reading some key, first competition can judge key expired time to the thread of lock, if expired, return
Null, and renew to the key and (extend expired time), that due to return is null, the thread can puncture Localcache after
Continue and initiate to ask to server, and update local Localcache;During other thread accesses key, it has been after renewing, these
It during the access of the thread key, would not find expired, that read is old value, when first thread is completed
After server ends key-value to Localcache renewal terminates, all threads will all read new value;Such benefit
It is pressure will not to be caused to server in some key expired time once to Localcache, and substantial amounts of access server is punctured
Power.
3rd, Clone mechanism
The problem of Clone will be solved be:When client needs the corresponding value of key being written to Localcache, very
Many scenes need depth clone, to prevent same object from being changed outside Localcache, so as to cause in Localcache
Value and rear end server value it is inconsistent.
But clone operations expend CPU very much in itself, if being required for clone's toward writing value in Localcache every time
Words, influence performance very much;And majority of case, user accesses key chance once, such as one for iteration
Circulation, is accessed different (key+i), it is necessary to which the corresponding value of each key, clone are once write Local- again every time
In cache;Two problems are so done:One is very time-consuming;Two are:And the K-V write in Localcache is without second
The chance of hit, this is unnecessary clone.
Therefore our clone mechanism is that when writing Localcache for the first time, only null is write as value;When
When the key of this in Localcache also has second of chance accessed, client, which takes null, will go server reading newest again
Data, value that then we read with regard to real service end of clone is simultaneously write in Localcache;It is considered that should
Key, which has to read for the second time, just to be had chance more times and is read.
The foregoing is only a preferred embodiment of the present invention, but protection scope of the present invention be not limited thereto,
Any one skilled in the art the invention discloses technical scope in, technique according to the invention scheme and its
Inventive concept is subject to equivalent substitution or change, should all be included within the scope of the present invention.
Claims (4)
1. a kind of caching system hot spot data access method, it is characterised in that comprise the following steps:
S1:Increase HotKey modules on redis DS, acquiescence DS opens HotKey modules after starting, with interface with time control
After start and stop focus statistics function processed, focus statistics function on, related initialization is done;
S2:The HotKey logic adds that server is recognized into focus are in worker threads, and the read request for each reaching server is first
First try is locked in competition one, after acquisition is locked successfully, and experienced three stages, statistics successfully passes through the request of three phases;
S3:When server end feedback has focus generation, the key in the feedback bags is write local- by client first
Cache, while opening hot-running patterns.
2. a kind of caching system hot spot data access method according to claim 1, it is characterised in that in the S1, DS
For data server.
3. a kind of caching system hot spot data access method according to claim 1, it is characterised in that in the S1, phase
Closing initialization includes setting the opcode sequences of operation list to be paid close attention to during statistics focus key, setting sampling number, setting focus
The life cycle of QPS threshold values, setting server end focus key maximum sizes and each focus key in server.
4. a kind of caching system hot spot data access method according to claim 1, it is characterised in that in the S2, three
The individual stage includes sample phase, positioning stage and inquiry phase.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710357388.4A CN107256235A (en) | 2017-05-19 | 2017-05-19 | A kind of caching system hot spot data access method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710357388.4A CN107256235A (en) | 2017-05-19 | 2017-05-19 | A kind of caching system hot spot data access method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107256235A true CN107256235A (en) | 2017-10-17 |
Family
ID=60027519
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710357388.4A Pending CN107256235A (en) | 2017-05-19 | 2017-05-19 | A kind of caching system hot spot data access method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107256235A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107908695A (en) * | 2017-10-31 | 2018-04-13 | 平安普惠企业管理有限公司 | Operation system operation method, device, system and readable storage medium storing program for executing |
CN108234481A (en) * | 2017-12-29 | 2018-06-29 | 上海品顺信息科技有限公司 | A kind of method and distributed system that multiple machine distributing is controlled to access external system |
CN108737898A (en) * | 2018-05-23 | 2018-11-02 | 武汉斗鱼网络科技有限公司 | A kind of hot spot live streaming method for pushing, server and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103095686A (en) * | 2012-12-19 | 2013-05-08 | 华为技术有限公司 | Hot metadata access control method and server |
CN103177005A (en) * | 2011-12-21 | 2013-06-26 | 深圳市腾讯计算机系统有限公司 | Processing method and system of data access |
CN104794064A (en) * | 2015-04-21 | 2015-07-22 | 华中科技大学 | Cache management method based on region heat degree |
CN106294197A (en) * | 2016-08-05 | 2017-01-04 | 华中科技大学 | A kind of page frame replacement method towards nand flash memory |
-
2017
- 2017-05-19 CN CN201710357388.4A patent/CN107256235A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103177005A (en) * | 2011-12-21 | 2013-06-26 | 深圳市腾讯计算机系统有限公司 | Processing method and system of data access |
CN103095686A (en) * | 2012-12-19 | 2013-05-08 | 华为技术有限公司 | Hot metadata access control method and server |
CN104794064A (en) * | 2015-04-21 | 2015-07-22 | 华中科技大学 | Cache management method based on region heat degree |
CN106294197A (en) * | 2016-08-05 | 2017-01-04 | 华中科技大学 | A kind of page frame replacement method towards nand flash memory |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107908695A (en) * | 2017-10-31 | 2018-04-13 | 平安普惠企业管理有限公司 | Operation system operation method, device, system and readable storage medium storing program for executing |
CN108234481A (en) * | 2017-12-29 | 2018-06-29 | 上海品顺信息科技有限公司 | A kind of method and distributed system that multiple machine distributing is controlled to access external system |
CN108234481B (en) * | 2017-12-29 | 2020-10-30 | 上海品顺信息科技有限公司 | Method for controlling multi-machine distributed access to external system and distributed system |
CN108737898A (en) * | 2018-05-23 | 2018-11-02 | 武汉斗鱼网络科技有限公司 | A kind of hot spot live streaming method for pushing, server and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10176057B2 (en) | Multi-lock caches | |
US11307765B2 (en) | System and methods for storage data deduplication | |
US9454533B2 (en) | Reducing metadata in a write-anywhere storage system | |
US9268653B2 (en) | Extent metadata update logging and checkpointing | |
EP1654660B1 (en) | A method of data caching | |
US7725661B2 (en) | Data-aware cache state machine | |
US9940060B1 (en) | Memory use and eviction in a deduplication storage system | |
EP3066572B1 (en) | Cache memory budgeted by chunks based on memory access type | |
US10366010B1 (en) | Cache memory data management using relative access frequency | |
US20150193144A1 (en) | System and Method for Implementing SSD-Based I/O Caches | |
CN107077300A (en) | For balancing segmentation removing and the rate-matched technology of I/O workloads | |
US9229869B1 (en) | Multi-lock caches | |
US20060069876A1 (en) | Method and system of clock with adaptive cache replacement and temporal filtering | |
CN107256235A (en) | A kind of caching system hot spot data access method | |
US9558123B2 (en) | Retrieval hash index | |
WO2009067499A2 (en) | Statistical counting for memory hierarchy optimization | |
US9244861B2 (en) | Efficient caching system | |
CN106775684A (en) | A kind of disk buffering power loss recovery method based on new nonvolatile memory | |
US20020143799A1 (en) | Memory record update filtering | |
CN112799590A (en) | Differential caching method for online main storage deduplication | |
Zaidenberg et al. | New caching algorithms performance evaluation | |
US11132128B2 (en) | Systems and methods for data placement in container-based storage systems | |
Kee et al. | An Integrated Solution to Improve Performance of In-Memory Data Caching with an Efficient Item Retrieving Mechanism and a Near-Memory Accelerator | |
US20200264987A1 (en) | Object cache candidate filter | |
Xu et al. | PM-RAD: An Efficient Restore Algorithm in Deduplication by Pattern Matching |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20171017 |