Application software performance optimization method based on caching technology

Through the method based on caching technology, the problems of high time cost and poor applicability in software performance optimization are solved, and the software is quickly improved and stable. Through local cache, cache consistency and parallel asynchronous operation, the software is optimized. The read and write performance and throughput reduce costs.

CN119201445AInactive Publication Date: 2024-12-27GUIZHOU RADIO & TV UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411251378.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-07
Publication Date
2024-12-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing software performance optimization methods cannot effectively improve performance due to their high time cost, easy crash and poor applicability.

Method used

Adopting a caching technology-based approach, including introducing local caches to reduce distributed cache pressure, optimizing read and write performance, using LRU algorithm to manage caches, avoiding short-term large-scale failures, using delayed double deletion and CDC synchronization to ensure cache consistency, early processing and delay Post-processing for efficiency, parallel asynchronous operations to improve throughput, and compare performance with optimization verification model.

Benefits of technology

It achieves rapid improvement in software performance, reduces network and serialization overhead, improves system stability and throughput, reduces costs, and ensures efficient operation of caches.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

The invention provides an application software performance optimization method based on a cache technology, and relates to the technical field of computer software. The application software performance optimization method based on the cache technology specifically comprises the following steps of S1, cache introduction, S2, read-write performance improvement, S3, cache Miss, S4, short-term massive failure avoiding, S5, cache consistency, S6, advanced processing, S7, delayed processing, S8, parallel asynchronous operation and S9, optimization verification. According to the application software performance optimization method based on the cache technology, by introducing the local cache, the pressure of the distributed cache can be relieved, the network and serialization overhead can be reduced, the reading performance can be optimized, and when the request hits the cache, the request can be directly returned, so that the 10 reading is omitted, the reading cost is reduced, the writing is optimized, the writing operation is merged in the cache, and the performance of the application software is optimized. The IO equipment can perform batch processing, and the writing cost is reduced, so that software can run quickly.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer software, and in particular to a method for optimizing application software performance based on cache technology. Background Art

[0002] Existing software performance optimization methods cannot make significant progress in performance improvement due to the consistency of the fundamental ideas of the methods. When using traditional software performance optimization methods, the time cost of the algorithm is too high due to the large number of samples required. In addition, existing software performance optimization methods cannot achieve the maximum effect in processing, are prone to crash, and have poor applicability. Summary of the invention

[0004] 1. Technical issues to be solved

[0005] In view of the deficiencies of the prior art, the present invention provides an application software performance optimization method based on cache technology, which solves the problems of excessive time cost of the algorithm, failure to achieve maximum effect, easy crash and poor applicability.

[0006] (II) Technical solution

[0007] To achieve the above objectives, the present invention is implemented through the following technical solutions: a method for optimizing application software performance based on cache technology, specifically comprising the following steps:

[0008] S1. Introduction of cache

[0009] Distributed cache has also become a bottleneck. High-frequency QPS is a burden. In addition, cache eviction and network jitter will affect the stability of the system. At this time, introducing local cache can alleviate the pressure on distributed cache and reduce network and serialization overhead.

[0010] S2. Improved read and write performance

[0011] A1. Read optimization: When a request hits the cache, it can be returned directly, thus skipping 10 reads and reducing the read cost.

[0012] A2. Write optimization: Merge write operations in the buffer so that IO devices can process them in batches, reducing write costs.

[0013] S3. Cache Miss

[0014] Cache miss is an inevitable problem. The cache needs to ensure that hot data is maintained in the cache within limited capacity to achieve a balance between performance and cost. The cache uses the LRU algorithm to eliminate keys.

[0015] S4. Avoid short-term mass failure

[0016] In some scenarios, the program loads data into the cache in batches. For example, data is uploaded through Excel. After the system parses the data, it is written into the DB and cache in batches. At this time, if it is not designed, the timeout period of this batch of data is often consistent. After the cache expires, the traffic that should have been borne by the cache will be hit on the DB, thereby reducing the performance and stability of the interface and even the system. Random numbers can be used to break up the cache expiration time. For example, set TTL=8hr+random(8000)ms.

[0017] S5. Cache consistency

[0018] Avoid using unconventional cache design patterns: update the cache first and then update the DB, or update the DB first and then update the cache (cacheaside means directly invalidating the cache). These patterns have a high risk of inconsistency. There are some ways to mitigate cache inconsistency, such as delayed double deletion and CDC synchronization. These solutions increase the complexity of the system and require comprehensive consideration of the business tolerance and the complexity of the solution.

[0019] S6. Advance processing

[0020] The main purpose of advance processing is to speed up, such as the pre-fetch operation of the CPU and memory, which stores the instructions and data in the memory into the cache in advance, thereby speeding up the execution.

[0021] S7. Delayed processing

[0022] Do not execute it until it is necessary to save costs.

[0023] S8. Parallel asynchronous operations

[0024] Parallel operations have high processing efficiency (provided that the machine has multiple cores), which greatly shortens the processing time and greatly reduces the RT time.

[0025] S9. Optimization and verification

[0026] The optimized samples obtained through caching technology are tested on the software system to obtain the throughput or latency value of the optimized samples, and the throughput or latency value of the optimized samples are compared with that of the original samples to obtain the performance optimization effect of the generated caching technology model and the software system.

[0027] Preferably, in the buffer consistency of S5, delayed double deletion: after the main thread invalidates the cache, it puts the invalid instruction into the delay queue, and another thread polls the queue to obtain the instruction and executes it.

[0028] Preferably, in the cache consistency of S5, CDC synchronization: subscribe to the changes of MySQL binlog through canal, report to Kafka, and the system monitors Kafka messages to trigger cache invalidation.

[0029] Preferably, when the synchronous operation encounters a large number of internal I / O operations, the performance loss is very large. At this time, asynchronous operation is adopted, and the system throughput will be greatly improved.

[0030] Preferably, in the above S8. parallel asynchronous operation, most Internet servers either use multi-process or multi-thread to process user requests to make full use of multi-core CPUs. Another situation is that in places where there is IO blocking, it is also very suitable to use multi-threaded parallel operation, because in this case the CPU is basically idle, and multi-threading can allow the CPU to do more work. Asynchronous relative to synchronous is whether to wait for the result or return immediately.

[0031] Preferably, in the S6. advance processing, the decision engine needs to optimize and compress the execution time of the strategy in order to ensure that the execution RT of the strategy is controlled within 200ms. Assuming that no matter how a strategy is optimized, the execution time is more than 200ms, then the preprocessing operation can be triggered in advance in the previous event (scenario).

[0032] Preferably, in the S7. Then processing, the delayed operation in risk control is mainly to save costs. For the ultimate performance of the decision engine, many variables (or features / indicators) are loaded in parallel at one time. However, some variables are third-party charging indicators at this time, such as IP, Tongdun, Yidun, etc. The benefits of pre-loading are obvious, but it also greatly increases the cost. Users may be rejected or directly passed by the whitelist before reaching the payment variable decision node. At this time, it is a great waste for these users to request the third party in advance. Only when they really reach the payment strategy will they request it, and the cost is the lowest at this time.

[0033] (III) Beneficial effects

[0034] The present invention provides a method for optimizing application software performance based on cache technology. It has the following beneficial effects:

[0035] 1. The present invention provides an application software performance optimization method based on cache technology. The application software performance optimization method based on cache technology can reduce the pressure of distributed cache and reduce network and serialization overhead by introducing local cache, optimize the read performance, and when the request hits the cache, it can be returned directly, thereby skipping 10 reads and reducing the cost of reading. It optimizes writing and merges write operations in the buffer, so that IO devices can be processed in batches, reducing the cost of writing, so that the software can run quickly.

[0036] 2. The present invention provides an application software performance optimization method based on cache technology. The application software performance optimization method based on cache technology can be accelerated by advance processing, such as pre-fetching operations of the CPU and memory, storing instructions and data in the memory in the cache in advance, thereby speeding up the execution speed. When synchronous operations encounter a large number of internal I / O operations, the performance loss is extremely large. At this time, asynchronous operations are used, and the system throughput will be greatly improved, thereby making the software performance smoother. DETAILED DESCRIPTION

[0037] The technical solutions in the embodiments of the present invention are described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0038] Example:

[0039] The embodiment of the present invention provides a method for optimizing application software performance based on cache technology, which specifically includes the following steps:

[0040] S1. Introduction of cache

[0041] Distributed cache has also become a bottleneck. High-frequency QPS is a burden. In addition, cache eviction and network jitter will affect the stability of the system. At this time, introducing local cache can alleviate the pressure on distributed cache and reduce network and serialization overhead.

[0042] S2. Improved read and write performance

[0043] A1. Read optimization: When a request hits the cache, it can be returned directly, thus skipping 10 reads and reducing the read cost.

[0044] A2. Write optimization: Merge write operations in the buffer so that IO devices can process them in batches, reducing write costs.

[0045] S3. Cache Miss

[0046] Cache miss is an inevitable problem. The cache needs to ensure that hot data is maintained in the cache within limited capacity to achieve a balance between performance and cost. The cache uses the LRU algorithm to eliminate keys.

[0047] You can first imagine the implementation of strict LRU. Assuming that Redis currently has 500,000 keys, first obtain all keys through Keys traversal, then compare the key with the longest idle time, and finally eliminate it. This process is very expensive. The Keys command is a considerable expense, and large-scale comparison is also expensive.

[0048] S4. Avoid short-term mass failure

[0049] In some scenarios, the program loads data into the cache in batches. For example, data is uploaded through Excel. After the system parses the data, it is written into the DB and cache in batches. At this time, if it is not designed, the timeout period of this batch of data is often consistent. After the cache expires, the traffic that should have been borne by the cache will be hit on the DB, thereby reducing the performance and stability of the interface and even the system. Random numbers can be used to break up the cache expiration time. For example, set TTL=8hr+random(8000)ms.

[0050] S5. Cache consistency

[0051] Avoid using unconventional cache design patterns: update the cache first and then the DB, or update the DB first and then the cache (cache aside directly invalidates the cache). These patterns have a high risk of inconsistency. There are some ways to mitigate cache inconsistency, such as delayed double deletion and CDC synchronization. These solutions increase the complexity of the system. You need to consider the tolerance of the business and the complexity of the solution.

[0052] S6. Advance processing

[0053] The main purpose of early processing is to speed up, such as the pre-fetch operation of the CPU and memory, storing the instructions and data in the memory into the cache in advance, thereby speeding up the execution. When the user places an order, the group risk needs to be determined, but accessing the group is relatively time-consuming. In this case, the query group information can be triggered and paused before the user enters the order. When the order is actually placed, the last result can be directly read. Similarly, we can trigger some operations when the user logs in, which is conducive to the perception of subsequent risk control events.

[0054] S7. Delayed processing

[0055] Do not execute until it is necessary to save costs. The most famous example of this strategy is COW (Copy On Write). Suppose multiple threads want to operate a copy of the data. Generally, each thread can copy it and put it in its own space, but the copy operation is time-consuming. If the system uses lazy processing, the copy operation will be postponed. If multiple threads only have read requests for the data, then the same data resource can be shared, because the "read" operation will not change the data. When a thread needs to modify the data (write operation), the system will copy the resource for the thread to use and allow rewriting, so that it will not affect other threads.

[0056] Delayed operation is mainly used in risk control to save costs. In order to achieve the ultimate performance of the decision engine, many variables (or features / indicators) are loaded in parallel at one time. However, some variables are third-party charging indicators, such as IP, Tongdun, Yidun, etc. The benefits of preloading are obvious, but it also greatly increases the cost: users may be rejected or directly passed by the whitelist before reaching the paid variable decision node. At this time, it is a huge waste for these users to request third parties in advance. Only when they really reach the payment strategy will they make requests, and the cost is minimal at this time.

[0057] S8. Parallel asynchronous operations

[0058] Parallel operation has high processing efficiency (assuming the machine has multiple cores), greatly shortens the processing time, and greatly shortens the RT time. Most Internet servers either use multiple processes or multiple threads to process user requests to fully utilize multi-core CPUs. Another situation is where there is IO blocking, which is also very suitable for multi-threaded parallel operation, because in this case the CPU is basically idle, and multi-threading can allow the CPU to do more work. Asynchronous operation is relative to synchronous operation, which is whether to wait for the result or return immediately. When synchronous operation encounters a large number of internal I / O operations, the performance loss is extremely large. At this time, asynchronous operation is used, and the system throughput will be greatly improved.

[0059] S9. Optimization and verification

[0060] The optimized samples obtained through caching technology are tested on the software system to obtain the throughput or latency value of the optimized samples, and the throughput or latency value of the optimized samples are compared with that of the original samples to obtain the performance optimization effect of the generated caching technology model and the software system.

[0061] S5. In buffer consistency, delayed double deletion: After the main thread invalidates the cache, it puts the invalid instruction into the delay queue, and another thread polls the queue to obtain the instruction and executes it.

[0062] S5. In cache consistency, CDC synchronization: Subscribe to changes in MySQL binlog through canal and report to Kafka. The system monitors Kafka messages to trigger cache invalidation.

[0063] When synchronous operations encounter a large number of internal I / O operations, the performance loss is very large. At this time, asynchronous operations are used to greatly improve the system throughput.

[0064] S8. In parallel asynchronous operation, most Internet servers either use multi-process or multi-thread to handle user requests to make full use of multi-core CPUs. Another situation is where there is IO blocking, which is also very suitable for multi-threaded parallel operation, because in this case the CPU is basically idle, and multi-threading can allow the CPU to do more work. Asynchronous relative to synchronous is whether to wait for the result or return immediately.

[0065] S6. In advance processing, the decision engine needs to optimize and compress the execution time of the strategy to ensure that the execution RT of the strategy is controlled within 200ms. Assuming that no matter how a strategy is optimized, the execution time is still more than 200ms, then the pre-processing operation can be triggered in advance in the previous event (scenario).

[0066] S7. Then in the processing, the delayed operation in risk control is mainly to save costs. For the ultimate performance of the decision engine, many variables (or features / indicators) are loaded in parallel at one time. However, some variables are third-party charging indicators, such as IP, Tongdun, Yidun, etc. The benefits of pre-loading are obvious, but it also greatly increases the cost. Users may be rejected or directly passed by the whitelist before they reach the paid variable decision node. At this time, it is a huge waste for these users to request the third party in advance. Only when they really reach the payment strategy will they make the request, and the cost is the lowest at this time.

[0067] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for optimizing application software performance based on cache technology, characterized in that: The specific steps include: S1. Introduction of cache Distributed cache has also become a bottleneck. High-frequency QPS is a burden. In addition, cache eviction and network jitter will affect the stability of the system. At this time, introducing local cache can alleviate the pressure on distributed cache and reduce network and serialization overhead. S2. Improved read and write performance A1. Read optimization: When a request hits the cache, it can be returned directly, thus skipping 10 reads and reducing the read cost. A2. Write optimization: Merge write operations in the buffer so that IO devices can process them in batches, reducing write costs. S3. Cache Miss Cache miss is an inevitable problem. The cache needs to ensure that hot data is maintained in the cache within limited capacity to achieve a balance between performance and cost. The cache uses the LRU algorithm to eliminate keys. S4. Avoid short-term mass failure In some scenarios, the program loads data into the cache in batches. For example, data is uploaded through Excel. After the system parses the data, it is written into the DB and cache in batches. At this time, if it is not designed, the timeout period of this batch of data is often consistent. After the cache expires, the traffic that should have been borne by the cache will be hit on the DB, thereby reducing the performance and stability of the interface and even the system. Random numbers can be used to break up the cache expiration time. For example, set TTL=8hr+random(8000)ms. S5. Cache consistency Avoid using unconventional cache design patterns: update the cache first and then the DB, or update the DB first and then the cache (cache aside directly invalidates the cache). These patterns have a high risk of inconsistency. There are some ways to mitigate cache inconsistency, such as delayed double deletion and CDC synchronization. These solutions increase the complexity of the system. You need to consider the tolerance of the business and the complexity of the solution. S6. Advance processing The main purpose of advance processing is to speed up, such as the pre-fetch operation of the CPU and memory, which stores the instructions and data in the memory into the cache in advance, thereby speeding up the execution. S7. Delayed processing Do not execute it until it is necessary to save costs. S8. Parallel asynchronous operations Parallel operations have high processing efficiency (provided that the machine has multiple cores), which greatly shortens the processing time and greatly reduces the RT time. S9. Optimization and verification The optimized samples obtained through caching technology are tested on the software system to obtain the throughput or latency value of the optimized samples, and the throughput or latency value of the optimized samples are compared with that of the original samples to obtain the performance optimization effect of the generated caching technology model and the software system.

2. The method for optimizing application software performance based on cache technology according to claim 1, characterized in that: In the buffer consistency of S5, delayed double deletion: after the main thread invalidates the cache, it puts the invalid instruction into the delay queue, and another thread polls the queue to obtain the instruction and executes it.

3. The method for optimizing application software performance based on cache technology according to claim 1, characterized in that: In S5. cache consistency, CDC synchronization: subscribe to changes in MySQL binlog through canal and report to Kafka. The system monitors Kafka messages to trigger cache invalidation.

4. The method for optimizing application software performance based on cache technology according to claim 1, characterized in that: The synchronous operation will cause great performance loss when there are a large number of I / O operations inside. At this time, asynchronous operation can greatly improve the system throughput.

5. The method for optimizing application software performance based on cache technology according to claim 1, characterized in that: In the above S8. parallel asynchronous operation, most Internet servers either use multi-process or multi-thread to handle user requests to make full use of multi-core CPUs. Another situation is where there is IO blocking, which is also very suitable for multi-threaded parallel operation, because in this case the CPU is basically idle, and multi-threading can allow the CPU to do more work. Asynchronous relative to synchronous is whether to wait for the result or return immediately.

6. The method for optimizing application software performance based on cache technology according to claim 1, characterized in that: In the above S6. advance processing, the decision engine needs to optimize and compress the execution time of the strategy in order to ensure that the execution RT of the strategy is controlled within 200ms. Assuming that no matter how a strategy is optimized, the execution time is still more than 200ms, then the pre-processing operation can be triggered in advance in the previous event (scenario).

7. The method for optimizing application software performance based on cache technology according to claim 1, characterized in that: In the above S7. Then, in the processing, the delayed operation in risk control is mainly to save costs. For the ultimate performance of the decision engine, many variables (or features / indicators) are loaded in parallel at one time. However, some variables are third-party charging indicators at this time, such as IP, Tongdun, Yidun, etc. The benefits of pre-loading are obvious, but it also greatly increases the cost. Users may be rejected or directly passed by the whitelist before reaching the payment variable decision node. At this time, it is a great waste for these users to request the third party in advance. Only when they really reach the payment strategy will they request it, and the cost is the lowest at this time.