EBPF-based key value storage system performance optimization system and method

By optimizing the key-value storage system using eBPF technology, the problems of resource contention and latency under mixed loads are solved, achieving performance optimization with low latency and high throughput, making it suitable for key-value storage services in cloud-native environments.

CN120929469APending Publication Date: 2025-11-11ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511143554.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-15
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

Existing key-value storage systems suffer from resource contention, long-tail latency, user-kernel mode switching overhead, and cache consistency issues under mixed loads, leading to performance bottlenecks and throughput limitations, especially in cloud-native environments where they struggle to adapt to dynamic load changes.

Method used

It employs an eBPF-based traffic interception and parsing module, a dynamic threshold sharding module, a resource-aware scheduling module, a kernel-level cache management module, and a hybrid load optimization module. By intercepting network packets in real time, dynamically classifying requests, optimizing CPU core allocation and cache management, it reduces user-mode switching overhead and achieves efficient resource utilization under hybrid loads.

Benefits of technology

It achieves a balance between low latency, high throughput, and resource efficiency, making it suitable for key-value storage services in cloud-native environments. It significantly reduces tail latency and increases throughput, ensuring data consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120929469A_ABST
    Figure CN120929469A_ABST
Patent Text Reader

Abstract

The invention discloses an eBPF-based key value storage system performance optimization system and method, and the system comprises a traffic interception and analysis module which intercepts a key value request in real time, extracts request metadata, and recombines a cross-fragment request; the dynamic threshold fragmentation module is used for updating classification thresholds in real time so as to divide large requests and small requests; the resource awareness scheduling module is used for routing a large request to an isolation queue for processing, and preferentially accelerating the response of a small request through a kernel cache; the kernel level cache management module adopts an LRU elimination strategy and a write operation consistency lock mechanism to guarantee data consistency; and the hybrid load optimization module is used for aggregating a plurality of write operation requests through a batch processing submission method and merging adjacent interrupt signals through an interrupt aggregation method. According to the method, low delay, high throughput and low resource overhead of the key value storage system can be realized, the tail delay is stably lower than 150 microseconds under the mixed load, meanwhile, the CPU utilization rate is kept to be smaller than or equal to 85%, and the method is suitable for large-scale key value storage services.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of performance optimization technology for distributed storage systems, and in particular to a performance optimization system and method for key-value storage systems based on eBPF (Extended Berkeley Packet Filter). Background Technology

[0002] Key-value stores, as core components of modern internet services, are widely used in caching, databases, and real-time data processing scenarios. With the increasing prevalence of cloud-native applications, the performance requirements for key-value stores are becoming increasingly stringent, demanding microsecond-level latency and millions of queries per second (QPS) in mixed load scenarios (such as read / write hybrid scenarios). However, existing technologies face the following challenges: ① Resource contention: Traditional kernel bypassing technologies (such as DPDK) move the network stack to user space, reducing latency but leading to exclusive use of CPU core resources, making it difficult to dynamically adapt to load changes; ② Mixed load scheduling bottleneck: When large requests (such as batch writes) are mixed with small requests (such as single-key queries), long-tail latency is easily triggered, and existing scheduling algorithms struggle to balance throughput and fairness; ③ User-kernel mode switching overhead: In high-frequency write scenarios, frequent system calls result in significant context switching overhead, limiting throughput improvement; ④ Cache consistency cost: Complex synchronization mechanisms are required between the kernel-level cache and the user-space storage engine, increasing the risk of data inconsistency.

[0003] For example, during a major promotional period, a sudden surge in traffic caused the tail latency (P99) of a key-value storage system on an e-commerce platform to spike to over 500μs, with core utilization exceeding 95%, triggering service degradation. Existing solutions such as sharding scheduling or static resource allocation cannot adapt to dynamic loads in real time, necessitating a low-overhead, adaptive performance optimization method. Summary of the Invention

[0004] The purpose of this invention is to address the problems of uneven resource utilization, long-tail latency, and throughput bottlenecks in existing key-value storage systems under mixed loads, and to provide a performance optimization system and method for key-value storage systems based on eBPF. This invention achieves a balance between low latency, high throughput, and resource efficiency, and is suitable for high-concurrency, low-latency key-value storage services in cloud-native environments.

[0005] The objective of this invention is achieved through the following technical solution: The first aspect of this invention provides a performance optimization system for a key-value storage system based on eBPF, comprising:

[0006] The traffic interception and parsing module, located in the Linux kernel network driver layer, is used to intercept network packets in real time, filter non-key-value storage protocol traffic, extract request metadata, and reassemble cross-shard requests.

[0007] The dynamic threshold sharding module is used to adaptively update the classification threshold in real time through an interval-based dynamic programming scheme to divide the recombined requests into large requests and small requests.

[0008] The resource-aware scheduling module allocates dedicated CPU cores based on dynamic load ratios, routing large requests to isolated queues for processing and prioritizing smaller requests through kernel caching to accelerate response; the number of CPU cores allocated is based on the formula... Dynamically adjusted, where n l This represents the number of CPU cores allocated to a large request, where n represents the total number of requests, and p represents the number of CPU cores allocated to that request. L The proportion of large requests;

[0009] The kernel-level cache management module is used to build a lightweight key-value cache based on the eBPF hash table, and uses an LRU eviction policy and a write operation consistency lock mechanism to ensure data consistency.

[0010] The hybrid load optimization module is used to aggregate multiple write operation requests in kernel mode through batch submission and merge interrupt signals within adjacent time windows through interrupt aggregation to achieve hybrid load optimization.

[0011] Furthermore, the traffic interception and parsing module is implemented using the following method:

[0012] First, the eBPF program is bound to the XDP hook in the network card driver layer to capture network packets in real time; then, protocol parsing logic is executed on the network packets to filter non-key-value storage protocol traffic, retaining only key-value request protocol traffic that conforms to the custom protocol or Redis protocol.

[0013] Then, the headers of the data packets corresponding to the key-value request protocol traffic are parsed to extract request metadata; cross-shard requests are reassembled, and data integrity is verified before being timestamped.

[0014] Finally, traffic is classified and forwarded. Legitimate requests are marked and forwarded directly to the dynamic threshold sharding module, while illegitimate requests are discarded at the network driver layer. Illegitimate requests refer to reassembly requests that fail to complete data integrity verification or time out.

[0015] Furthermore, the request metadata includes the operation type, the key length of the key-value pair, the value length, the request timestamp, and the client IP address;

[0016] The cross-shard requests are reassembled by maintaining a session state table, which records the ID of each session, the request buffer address, the current offset, and the timeout period.

[0017] Furthermore, the dynamic threshold slicing module is specifically implemented through the following method:

[0018] First, maintain an eBPF hash table in the user kernel space to count the proportion S[j] of requests within the interval with median j; synchronize the request data within the interval to the user space service every 100 milliseconds.

[0019] Then, the user space service calculates the dynamically updated classification threshold based on the interval-based dynamic programming scheme of the request data it receives within the interval.

[0020] Finally, the length of the request value is compared with the updated classification threshold. Requests with a length greater than the updated classification threshold are classified as large requests, and requests with a length less than or equal to the updated classification threshold are classified as small requests.

[0021] Furthermore, the update formula for the classification threshold is:

[0022]

[0023] In the formula, Threshold t Threshold represents the classification threshold at time t. t-1 Let represent the classification threshold at time t-1, α represent the attenuation coefficient, S[j] represent the proportion of requests within the interval with median j, and N represent the total number of requests. This is the initial value for the classification threshold.

[0024] Furthermore, the resource-aware scheduling module adopts a two-level queue architecture, and its CPU core allocation strategy includes:

[0025] Static core pool: Reserve at least one dedicated CPU core to handle large requests;

[0026] Dynamic core pool: Remaining CPU cores are dynamically allocated according to the load of small request queues, and CPU time slices are allocated based on a weighted round-robin algorithm, where the weights are calculated from the queue length and processing rate.

[0027] Furthermore, the write operation consistency locking mechanism of the kernel-level cache management module includes:

[0028] Add read-write locks to the cached key-value pairs. Read operations use a shared lock to allow concurrent access by multiple threads, while write operations use an exclusive lock to block other threads.

[0029] After the write operation is completed, the atomic version number of the cache is updated through atomic operations. When querying in user space, the atomic version number is verified to ensure data consistency.

[0030] Furthermore, in the hybrid load optimization module, the batch submission method uses a circular queue structure to manage the buffer. The queue capacity is 64 request items. Each request item contains an operation type, a key-value pointer, and request metadata. When the buffer is full or times out, the batch submission is made to the user space storage engine through a single system call.

[0031] Furthermore, the system also includes a performance monitoring module, which is used to directly collect performance indicators in real time in kernel mode through the eBPF program to monitor the system performance in real time; wherein, the performance indicators include CPU core utilization, cache hit rate, queue depth, request latency distribution, and throughput.

[0032] A second aspect of this invention provides a method for optimizing the performance of a key-value storage system based on eBPF as described above, comprising the following steps:

[0033] S1. Intercept and parse key-value requests at the kernel network driver layer through the traffic interception and parsing module;

[0034] S2. The dynamic threshold segmentation module classifies request sizes in real time and dynamically adjusts the classification threshold.

[0035] S3. Allocate CPU cores through the resource-aware scheduling module to isolate large requests and accelerate the response of small requests;

[0036] S4. A key-value cache is built through a kernel-level cache management module, and a low-latency caching service is provided by an LRU eviction policy and a write operation consistency lock mechanism to ensure data consistency.

[0037] S5. The hybrid load optimization module aggregates multiple write operation requests in kernel mode through batch submission and merges interrupt signals within adjacent time windows through interrupt aggregation to achieve hybrid load optimization.

[0038] The beneficial effects of this invention are:

[0039] (1) Low latency and high throughput: This invention implements request parsing and cached response in kernel mode through eBPF, reducing user-kernel mode switching overhead. Experiments show that the system tail latency (P99) is consistently below 150μs under mixed load, and the throughput is increased by 40%.

[0040] (2) Dynamic resource optimization: The present invention is based on a real-time load CPU core allocation strategy to keep the CPU utilization rate stable at ≤85% and avoid performance drop caused by resource overload.

[0041] (3) Hybrid load adaptability: This invention reduces the number of system calls to 1 / 8 in high write scenarios (70% write ratio) by batch processing and interrupt aggregation technology, which significantly improves throughput.

[0042] (4) Strong consistency guarantee: This invention ensures data consistency between the cache and the storage engine through atomic version number and read-write lock mechanism. Tests show that the data inconsistency rate is less than 0.001%.

[0043] (5) This invention provides a lightweight and adaptive performance optimization solution for cloud-native key-value storage systems, which is suitable for large-scale application scenarios that are sensitive to latency, such as e-commerce and real-time recommendation, and can achieve a balance between low latency, high throughput and resource efficiency. Attached Figure Description

[0044] Figure 1 This is the overall flowchart of the performance optimization system for the key-value storage system based on eBPF of the present invention;

[0045] Figure 2 This is a schematic diagram of the size-sensing segmentation of the present invention;

[0046] Figure 3 This is a representation diagram of the size-aware cache of the present invention;

[0047] Figure 4 This is a schematic diagram of the system call process of the present invention. Detailed Implementation

[0048] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.

[0049] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The singular forms “a,” “the,” and “the” used in this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0050] It should be understood that although the terms first, second, third, etc., may be used in this invention to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of this invention, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."

[0051] The present invention will now be described in detail with reference to the accompanying drawings. Unless otherwise specified, the features of the following embodiments and implementations can be combined with each other.

[0052] See Figure 1 This invention discloses a performance optimization system for a key-value store system based on eBPF, comprising a traffic interception and parsing module, a dynamic threshold sharding module, a resource-aware scheduling module, a kernel-level cache management module, and a hybrid load optimization module. The traffic interception and parsing module, located in the Linux kernel network driver layer (XDP), is used to intercept network packets in real time, filter non-key-value store protocol traffic, extract request metadata, and reassemble cross-shard requests. The dynamic threshold sharding module adaptively updates the classification threshold in real time using a range-based dynamic programming scheme to classify the reassembled requests into large and small requests. The resource-aware scheduling module allocates dedicated CPU cores according to the dynamic load ratio to route large requests to isolated queues for processing, while prioritizing small requests through the kernel cache for faster response; the number of CPU cores allocated is based on the formula... Dynamically adjusted, where n l This represents the number of CPU cores allocated to a large request, where n represents the total number of requests, and p represents the number of CPU cores allocated to that request. L For high request volumes, the kernel-level cache management module builds a lightweight key-value cache based on an eBPF hash table. It employs an LRU (Least Recently Used) eviction policy and a write operation consistency locking mechanism (read-write locks + atomic version numbers) to ensure data consistency. The hybrid load optimization module aggregates multiple write operation requests in kernel space using batch submission and merges interrupt signals within adjacent time windows using interrupt aggregation. This achieves hybrid load optimization, reducing user-kernel space switching overhead and improving throughput in high-write scenarios.

[0053] In this embodiment, the traffic interception and parsing module is located in the Linux kernel network driver layer. It is used to intercept network packets in real time, filter non-key-value storage protocol traffic, and intercept key-value request traffic, effectively avoiding the context switching overhead between user mode and kernel mode. Its implementation steps specifically include:

[0054] (1.1) XDP Program Deployment: The eBPF program is bound to an XDP hook in the network card driver layer to capture inbound network packets in real time. Protocol parsing logic is executed on the captured network packets to filter non-key-value storage protocol traffic (such as TCP handshake packets (SYN), etc.), retaining only key-value request protocol traffic conforming to a custom protocol or Redis protocol for subsequent processing. After parsing the content of the network packets, the port number can be used to determine whether the network packet is a key-value request or a non-key-value request. For example, the default port number for memcached is 11211, and key-value storage systems all have corresponding default ports; if a port number needs to be changed, it can be reset. Network packet traffic conforming to a custom protocol or Redis protocol is key-value request protocol traffic.

[0055] (1.2) Extracting Request Metadata: Parse the header of the data packet corresponding to the key-value request protocol traffic to extract request metadata, which includes the operation type (read / write / delete), key length K_len, value length V_len, request timestamp T_req, and client IP address; reassemble cross-shard requests, verify data integrity, and mark the timestamp. Cross-shard requests are reassembled by maintaining a session state table, which records the ID of each session, request buffer address, current offset, and timeout (default 10ms).

[0056] (1.3) Traffic Classification and Forwarding: Legitimate requests are marked and forwarded directly to the dynamic threshold fragmentation module, while illegitimate requests are discarded at the network driver layer. Illegitimate requests refer to reassembly requests that fail to complete data integrity verification or time out (this can be determined based on the timeout recorded in the session state table).

[0057] It should be noted that key mechanisms in this traffic interception and parsing module include: ① Zero-copy processing: Adjusting the packet pointer using XDP's "bpf_xdp_adjust_head" function to avoid memory copying. ② Protocol compatibility: Supporting binary protocol and Redis protocol parsing, compatible with mainstream key-value storage systems (such as Redis, Memcached, etc.).

[0058] In this embodiment, the goal of the dynamic threshold sharding module and the resource-aware scheduling module is to dynamically divide large or small requests based on the real-time request size, thereby optimizing CPU resource allocation and load balancing. For example... Figure 2 As shown, the specific implementation steps include:

[0059] (2.1) Request statistics and analysis: The eBPF program is used to statistically analyze the distribution of request size in real time in kernel space. That is, an eBPF hash table is maintained in the kernel to calculate the proportion of requests S[j] within the interval with median j (divided into 1KB intervals). Every 100 milliseconds, the request data within the interval is synchronized to the user space service for subsequent classification threshold calculation to ensure that classification decisions are synchronized with load changes.

[0060] (2.2) Calculating the dynamic classification threshold: Based on the requested data received within the interval, the user space service calculates the dynamically updated classification threshold using an interval-based dynamic programming scheme. The calculation formula is as follows:

[0061]

[0062] In the formula, Threshold t Threshold represents the classification threshold at time t. t-1 The classification threshold is represented at time t-1; α = 0.9 represents the attenuation coefficient, used to suppress the impact of instantaneous traffic fluctuations; S[j] represents the proportion of requests within the interval with median j, and N is the total number of requests; The initial value for the classification threshold is used, and an interval-based dynamic programming scheme is adopted to adaptively update the classification threshold. After the threshold is updated, the CPU core allocation strategy is adjusted.

[0063] (2.3) Sharding: The length of the request value is compared with the updated classification threshold, and then the requests with a length greater than the updated classification threshold are classified as large requests, and the requests with a length less than or equal to the updated classification threshold are classified as small requests.

[0064] (2.4) Core Allocation: Large requests (value length > classification threshold) are routed to isolated CPU core queues and processed by a dedicated thread pool; small requests (value length ≤ classification threshold) are preferentially responded to through the kernel-level cache and allocated high-priority interrupts. Specifically, the resource-aware scheduling module adopts a two-level queue architecture, and its CPU core allocation strategy includes: ① Static core pool: at least one dedicated CPU core is reserved for handling large requests to avoid tail latency fluctuations. ② Dynamic core pool: the remaining CPU cores are dynamically allocated according to the load of the small request queue, and CPU time slices are allocated based on a weighted round-robin algorithm; the weight is calculated by the queue length and processing rate, i.e., weight = queue length / processing rate. This formula calculates the "estimated time to clear the queue". The longer the queue backlog or the slower the processing, the higher the weight, indicating that it needs more CPU resources. CPU time slices are allocated according to the weight ratio. For example, if the weights of queues A and B are 2 and 6 respectively, then in one scheduling cycle, the CPU will be allocated two time slices to A and six time slices to B, ensuring that B can get 3 times the CPU processing time of A.

[0065] It should be noted that the key mechanisms in the dynamic threshold sharding module and the resource-aware scheduling module include: ① Resource isolation: Binding large request processing threads to independent physical cores through CPU affinity to avoid resource contention. ② Adaptive load balancing: Adjusting the sharding strategy based on dynamic thresholds combined with real-time load pressure (such as queue depth and CPU utilization).

[0066] In this embodiment, the goal of the kernel-level cache management module is to build a lightweight, low-latency key-value cache using an eBPF hash table, thereby reducing the access pressure on the user-space storage engine. For example... Figure 3 As shown, the specific implementation steps include:

[0067] (3.1) Design of cache data structure: adopt the LRU (Least Recently Used) eviction policy of eBPF hash table, the key is a 32-bit hash value, the value is the cache entry, and the entry contains atomic version number, read-write lock, value data and last access timestamp.

[0068] It should be understood that the LRU eviction policy is a classic cache eviction algorithm used to determine which data should be removed when cache space is insufficient. LRU and its variants are widely used in scenarios such as Redis, operating system page replacement, and database caching. The core idea of ​​the LRU eviction policy is to evict the least recently accessed data, assuming that "if data has been accessed recently, it is more likely to be accessed in the future."

[0069] (3.2) Consistency guarantee mechanism: ① Read operation: After acquiring the read lock, read the data and verify whether the atomic version number has changed (to prevent dirty reads). ② Write operation: After acquiring the write lock, update the data and increment the version number through "atomic_add" to ensure multi-threaded consistency.

[0070] Specifically, the write operation consistency locking mechanism includes: adding a read-write lock (RWLock) to the cache key-value pair; the read operation shared lock allows concurrent access by multiple threads, while the write operation exclusive lock blocks other threads; after the write operation is completed, the atomic version number of the cache is updated through an atomic operation, and the atomic version number is verified when the user space queries to ensure data consistency.

[0071] (3.3) Cache backfilling strategy: Requests that miss the cache are forwarded to the user-space storage engine for processing, and the results are asynchronously backfilled to the kernel cache; during backfilling, the cache level is dynamically selected based on the value length (e.g., data less than 4KB is cached first).

[0072] It should be noted that key mechanisms in the kernel-level cache management module include: ① Atomic operations: Lock-free version number updates are achieved through eBPF's built-in atomic instructions (such as "atomic64_add"). ② Hot and cold data separation: Combining access frequency and value size, high-frequency small data is kept in the cache, while large data is passed through directly.

[0073] In this embodiment, the goal of the hybrid load optimization module is to reduce system call overhead and improve throughput in high-concurrency scenarios by using batch submission and interrupt aggregation methods. The specific implementation steps include:

[0074] (4.1) Batch Submission Mechanism: User-space services submit I / O requests in batches via the io_uring interface (up to 64 write operations per batch). Before submission, batch requests are sorted by key hash value, and accesses to adjacent disk sectors are merged to reduce disk seek time. The batch submission method uses a circular queue structure to manage the buffer, with a queue capacity of 64 request items. Each request item contains the operation type, key pointer, and request metadata. When the buffer is full or a timeout occurs (the timeout threshold is set to 10μs), the batch submission is performed to the user-space storage engine via a single system call.

[0075] (4.2) Interrupt aggregation configuration: Adjust the network card interrupt merging parameters (e.g., set rx-usecs = 100μs) to merge adjacent interrupt events and reduce the CPU interrupt frequency; allocate high-priority interrupts (e.g., IRQ_PRIORITY_HIGH) to small request queues to ensure low-latency response. The interrupt aggregation method reduces the number of interrupt handling operations by merging interrupt signals within adjacent time windows.

[0076] (4.3) Zero-copy network response: The response data packet is sent directly to the network card through the XDP layer, bypassing the kernel protocol stack processing.

[0077] It should be noted that key mechanisms in the hybrid load optimization module include: ① Dynamic batch window: automatically adjusting the batch size based on load pressure (e.g., reducing batch size to lower latency under low load). ② Interrupt priority grading: using low interrupt priority for large request queues, which can effectively avoid affecting the real-time performance of small requests.

[0078] In other embodiments, the system also includes a performance monitoring module, which collects performance metrics directly in real time in kernel space via an eBPF program to monitor system performance in real time. These performance metrics include CPU core utilization, cache hit rate, queue depth, request latency distribution, and throughput; the performance metrics are collected 100 times per second, and the data is transmitted to a user-space visualization component via shared memory.

[0079] Specifically, the goal of this performance monitoring module is to monitor the system status in real time and dynamically adjust parameters to adapt to load changes. Its implementation steps include:

[0080] (5.1) Real-time collection of performance metrics: eBPF Maps can directly collect performance metrics such as CPU core utilization, cache hit rate, queue depth, request latency distribution (P50 / P90 / P99), and throughput (QPS) in real time in kernel space, which can effectively avoid user space polling overhead; user space services aggregate data and generate monitoring reports (such as P50 / P99 latency and QPS trend).

[0081] (5.2) Parameter adaptive tuning: Dynamic sharding threshold, batch size and other parameters are automatically adjusted according to monitoring data: ① High load scenario: Increase the batch processing window and increase the sharding threshold to prioritize small requests; ② Low load scenario: Reduce the batch processing window and decrease the sharding threshold to reduce resource reservation.

[0082] (5.3) Anomaly detection and circuit breaking: When long-tail latency (e.g., P99>200μs) or CPU overload (utilization>90%) is detected, a degradation strategy (e.g., rate limiting, rejecting some write requests) is triggered.

[0083] It should be noted that the key mechanisms in the performance monitoring module include: ① Feedback control loop: using a PID (proportional-integral-derivative) algorithm to dynamically adjust parameters and suppress system oscillations. ② Circuit breaker threshold grading: triggering alarms, rate limiting, or service degradation according to the severity of the anomaly.

[0084] For example, in this embodiment, the implementation effect is verified. The system is deployed in a 3-node Redis cluster, and the test results are as follows: ① Latency optimization: Tail latency (P99) decreased from 500μs to 150μs, a reduction of 70%; ② Throughput improvement: QPS under mixed load increased from 120k to 170k, an improvement of 41.7%; ③ Resource efficiency: CPU utilization decreased from 95% to 82%, and the fluctuation range narrowed (±5%). Typical application scenarios of the system described in this invention include, but are not limited to: ① Financial transaction system: Order processing latency decreased from 1ms to 300μs, with peak availability reaching 99.999%; ② Real-time recommendation system: Ad retrieval response time stabilized within 100μs, and throughput increased by 35%. The system described in this invention has been successfully applied to cloud computing platforms and distributed database systems, significantly improving the performance and stability of key-value storage under mixed loads. It is suitable for scenarios with high concurrency and low latency requirements, such as real-time risk control and IoT data processing, and has broad commercial value, verifying the industrial applicability of the system described in this invention.

[0085] It is worth mentioning that the embodiments of the present invention also provide a method for optimizing the performance of the key-value storage system based on eBPF as described in the above embodiments, such as... Figure 4 As shown, the specific steps include the following:

[0086] Step S1: Intercept and parse key-value requests at the kernel network driver layer using the traffic interception and parsing module.

[0087] Step S2: The dynamic threshold sharding module classifies the request size in real time and dynamically adjusts the classification threshold.

[0088] Step S3: Allocate CPU cores through the resource-aware scheduling module to isolate large requests and accelerate the response of small requests.

[0089] Step S4: Build a key-value cache through the kernel-level cache management module, and use the LRU eviction policy and write operation consistency lock mechanism to provide low-latency caching services and ensure data consistency.

[0090] Step S5: The hybrid load optimization module aggregates multiple write operation requests in kernel mode through batch submission and merges interrupt signals within adjacent time windows through interrupt aggregation to achieve hybrid load optimization, improve throughput in high write scenarios, and reduce system call overhead.

[0091] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A performance optimization system for a key-value storage system based on eBPF, characterized in that, include: The traffic interception and parsing module, located in the Linux kernel network driver layer, is used to intercept network packets in real time, filter non-key-value storage protocol traffic, extract request metadata, and reassemble cross-shard requests. The dynamic threshold sharding module is used to adaptively update the classification threshold in real time through an interval-based dynamic programming scheme to divide the recombined requests into large requests and small requests. The resource-aware scheduling module allocates dedicated CPU cores based on dynamic load ratios, routing large requests to isolated queues for processing and prioritizing smaller requests through kernel caching to accelerate response; the number of CPU cores allocated is based on the formula... Dynamically adjusted, where n l This represents the number of CPU cores allocated to a large request, where n represents the total number of requests, and p represents the number of CPU cores allocated to that request. L The proportion of large requests; The kernel-level cache management module is used to build a lightweight key-value cache based on the eBPF hash table, and uses an LRU eviction policy and a write operation consistency lock mechanism to ensure data consistency. The hybrid load optimization module is used to aggregate multiple write operation requests in kernel mode through batch submission and merge interrupt signals within adjacent time windows through interrupt aggregation to achieve hybrid load optimization.

2. The performance optimization system for a key-value storage system based on eBPF according to claim 1, characterized in that, The traffic interception and parsing module is implemented using the following methods: First, the eBPF program is bound to the XDP hook in the network card driver layer to capture network packets in real time; then, protocol parsing logic is executed on the network packets to filter non-key-value storage protocol traffic, retaining only key-value request protocol traffic that conforms to the custom protocol or Redis protocol. Then, the header of the data packet corresponding to the key-value request protocol traffic is parsed to extract the request metadata; Requests across shards are reassembled, and data integrity is verified before being timestamped. Finally, traffic is classified and forwarded. Legitimate requests are marked and forwarded directly to the dynamic threshold sharding module, while illegitimate requests are discarded at the network driver layer. Illegitimate requests refer to reassembly requests that fail to complete data integrity verification or time out.

3. The performance optimization system for a key-value storage system based on eBPF according to claim 1, characterized in that, The request metadata includes the operation type, key length of the key-value pair, value length, request timestamp, and client IP address; The cross-shard requests are reassembled by maintaining a session state table, which records the ID of each session, the request buffer address, the current offset, and the timeout period.

4. The performance optimization system for a key-value storage system based on eBPF according to claim 1, characterized in that, The dynamic threshold slicing module is implemented using the following method: First, maintain an eBPF hash table in the user kernel space to count the proportion S[j] of requests within the interval with median j; synchronize the request data within the interval to the user space service every 100 milliseconds. Then, the user space service calculates the dynamically updated classification threshold based on the interval-based dynamic programming scheme of the request data it receives within the interval. Finally, the length of the request value is compared with the updated classification threshold. Requests with a length greater than the updated classification threshold are classified as large requests, and requests with a length less than or equal to the updated classification threshold are classified as small requests.

5. The performance optimization system for a key-value storage system based on eBPF according to claim 1, characterized in that, The update formula for the classification threshold is: In the formula, Threshold t Threshold represents the classification threshold at time t. t-1 Let represent the classification threshold at time t-1, α represent the attenuation coefficient, S[j] represent the proportion of requests within the interval with median j, and N represent the total number of requests. This is the initial value for the classification threshold.

6. The performance optimization system for a key-value storage system based on eBPF according to claim 1, characterized in that, The resource-aware scheduling module adopts a two-level queue architecture, and its CPU core allocation strategy includes: Static core pool: Reserve at least one dedicated CPU core to handle large requests; Dynamic core pool: Remaining CPU cores are dynamically allocated according to the load of small request queues, and CPU time slices are allocated based on a weighted round-robin algorithm, where the weights are calculated from the queue length and processing rate.

7. The performance optimization system for a key-value storage system based on eBPF according to claim 1, characterized in that, The write operation consistency locking mechanism of the kernel-level cache management module includes: Add read-write locks to the cached key-value pairs. Read operations use a shared lock to allow concurrent access by multiple threads, while write operations use an exclusive lock to block other threads. After the write operation is completed, the atomic version number of the cache is updated through atomic operations. When querying in user space, the atomic version number is verified to ensure data consistency.

8. The performance optimization system for a key-value storage system based on eBPF according to claim 1, characterized in that, In the hybrid load optimization module, the batch submission method uses a circular queue structure to manage the buffer. The queue capacity is 64 request items. Each request item contains the operation type, key-value pointer and request metadata. When the buffer is full or times out, the batch submission is made to the user space storage engine through a single system call.

9. The performance optimization system for a key-value storage system based on eBPF according to claim 1, characterized in that, The system also includes a performance monitoring module, which is used to collect performance metrics directly in real time in kernel mode through the eBPF program to monitor the system performance in real time; among which, the performance metrics include CPU core utilization, cache hit rate, queue depth, request latency distribution, and throughput.

10. A method for optimizing the performance of a key-value storage system based on eBPF as described in any one of claims 1-9, characterized in that, Includes the following steps: S1. Intercept and parse key-value requests at the kernel network driver layer through the traffic interception and parsing module; S2. The dynamic threshold segmentation module classifies request sizes in real time and dynamically adjusts the classification threshold. S3. Allocate CPU cores through the resource-aware scheduling module to isolate large requests and accelerate the response of small requests; S4. A key-value cache is built through a kernel-level cache management module, and a low-latency caching service is provided by an LRU eviction policy and a write operation consistency lock mechanism to ensure data consistency. S5. The hybrid load optimization module aggregates multiple write operation requests in kernel mode through batch submission and merges interrupt signals within adjacent time windows through interrupt aggregation to achieve hybrid load optimization.

Citation Information

Patent Citations

  • Network traffic management method, system and device based on eBPF and medium

    CN118921326A

  • Industrial scene-oriented data acquisition system and acquisition method thereof

    CN120428658A