Data writing method and device, electronic equipment and storage medium

By monitoring the relationship between the total amount of data written to the write cache and the traffic threshold, write requests are paused and write permissions are assigned to the target write requests. This ensures that the data volume reaches the upload fragment value before uploading, thus solving the problem of the write cache being filled with fragmented data and improving data writing efficiency and system performance.

CN121764408APending Publication Date: 2026-03-31BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-19
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

In scenarios such as large file uploads, log reporting, or streaming media transmission, write caching is prone to problems such as write deadlocks and write blocking due to concurrent write requests, which can lead to the cache space being filled with fragmented data and affect data writing efficiency and system performance.

Method used

By monitoring the relationship between the total amount of data written to the write cache and the preset traffic threshold, write requests are paused and write permissions are allocated to the target write requests based on the reserved cache space. This ensures that the data volume reaches the upload fragment value before uploading, thus avoiding the cache space being occupied by data that has not yet been filled.

Benefits of technology

It solves the write deadlock and write blocking problems, improves data writing efficiency and system concurrency performance, and optimizes resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121764408A_ABST
    Figure CN121764408A_ABST
Patent Text Reader

Abstract

The invention provides a data writing method and device, electronic equipment and a storage medium, relates to the field of cloud storage, and can be applied to a cloud platform. The method comprises the steps that in response to the fact that it is determined that the total amount of written data and a preset flow threshold value meet the preset size relation, a write request is suspended to write data into a write cache, the flow threshold value is determined according to the total cache space of the write cache and a reserved cache space, and the reserved cache space is determined according to an uploading fragment value of fragment data in the write cache; distributing a write permission for a target write request in the write requests according to the reserved cache space, so that the target write request continues to write data into the target fragmented data in the write cache; and in response to determining that the data volume of the target fragmented data reaches the uploading fragmentation value, uploading the target fragmented data. The data writing efficiency is improved, and the concurrency performance and the resource utilization rate of the system are also improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of cloud storage, and more particularly to a data writing method, apparatus, electronic device, and storage medium. Background Technology

[0002] In scenarios such as large file uploads, log reporting, or streaming media transmission on the front end, a fixed-size write cache is typically set up. Data is continuously written to the write cache, and when a segment of data in the write cache reaches a certain size (such as the size of a data chunk), an upload action is triggered to upload that data chunk. Summary of the Invention

[0003] This disclosure presents a data writing method, apparatus, electronic device, and storage medium.

[0004] According to a first aspect of this disclosure, a data writing method is provided, comprising: in response to determining that the total amount of data to be written and a preset traffic threshold satisfy a preset size relationship, pausing the writing of data from a write request to a write cache, wherein the traffic threshold is determined based on the total cache space of the write cache and a reserved cache space, and the reserved cache space is determined based on the upload fragment value of the fragmented data in the write cache; allocating write permissions to a target write request in the write request according to the reserved cache space, so that the target write request continues to write data to the target fragmented data in the write cache; and in response to determining that the amount of data in the target fragmented data has reached the upload fragment value, uploading the target fragmented data.

[0005] According to a second aspect of this disclosure, a data writing apparatus is provided, comprising: a pause writing module configured to pause writing requests to a write cache in response to determining that the total amount of data to be written and a preset traffic threshold satisfy a preset size relationship, wherein the traffic threshold is determined based on the total cache space of the write cache and a reserved cache space, and the reserved cache space is determined based on the upload fragment value of the fragmented data in the write cache; a permission allocation module configured to allocate write permissions to a target write request in the write requests according to the reserved cache space, so that the target write request can continue to write data to the target fragmented data in the write cache; and a data upload module configured to upload the target fragmented data in response to determining that the amount of data in the target fragmented data has reached the upload fragment value.

[0006] According to a third aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform a method as described in any implementation of the first aspect.

[0007] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions for causing a computer to perform a method as described in any implementation of the first aspect.

[0008] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method as described in any implementation of the first aspect.

[0009] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0010] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein: Figure 1 This is an exemplary system architecture diagram to which this disclosure can be applied; Figure 2 This is a flowchart of the first embodiment of the data writing method according to this disclosure; Figure 3 This is a flowchart of a second embodiment of the data writing method according to this disclosure; Figure 4 This is a flowchart of a third embodiment of the data writing method according to this disclosure; Figure 5 This is a flowchart of the fourth embodiment of the data writing method according to this disclosure; Figure 6 This is a flowchart of the fifth embodiment of the data writing method according to this disclosure; Figure 7-1 This is an application flowchart of the data writing method according to this disclosure; Figure 7-2 This is an application flowchart of a method for periodically checking cache space; Figure 8 This is a schematic diagram of a structure of an embodiment of the data writing apparatus according to the present disclosure; Figure 9 This is a block diagram of an electronic device used to implement the data writing method of the embodiments of this disclosure. Detailed Implementation

[0011] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0012] It should be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.

[0013] Figure 1 An exemplary system rack 100 is shown, to which embodiments of the data writing method or data writing apparatus of this disclosure may be applied.

[0014] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0015] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various applications for enabling information communication between the terminal devices 101, 102, and 103 and server 105 can be installed. These applications include cloud storage applications and instant messaging applications.

[0016] Terminal devices 101, 102, and 103 and server 105 can be either hardware or software. When terminal devices 101, 102, and 103 are hardware, they can be various electronic devices with displays, including but not limited to smartphones, tablets, laptops, and desktop computers. When terminal devices 101, 102, and 103 are software, they can be installed in the aforementioned electronic devices, and can be implemented as multiple software programs or software modules, or as a single software program or software module; no specific limitation is made here. When server 105 is hardware, it can be implemented as a distributed server cluster composed of multiple servers, or as a single server. When server 105 is software, it can be implemented as multiple software programs or software modules, or as a single software program or software module; no specific limitation is made here.

[0017] Server 105 can provide various services through its built-in applications, taking cloud storage applications as an example. Users can operate through the cloud storage applications on terminal devices 101, 102, and 103 and send data upload requests to server 105. Server 105 can receive data upload requests and run the cloud storage applications for processing, performing the following actions: In response to determining that the total amount of data to be written meets the preset size relationship with the preset traffic threshold, the write request is paused from writing data to the write cache; write permissions are allocated to the target write request in the write request according to the reserved cache space, so that the target write request can continue to write data to the target fragment data in the write cache; In response to determining that the data volume of the target fragment data has reached the upload fragment value, the target fragment data is uploaded.

[0018] It should be noted that the data writing method provided in this embodiment is generally executed by the server 105, and correspondingly, the data writing device is generally located in the server 105.

[0019] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0020] Continue to refer to Figure 2 The diagram illustrates a flow 200 of a first embodiment of a data writing method according to the present disclosure. The data writing method includes the following steps: Step 201: In response to determining that the total amount of data to be written and the preset traffic threshold meet the preset size relationship, the write request to write data to the write cache is paused.

[0021] In this embodiment, the execution body of the data writing method (e.g.) Figure 1 If the server 105 shown determines that the total amount of data written meets the preset size relationship with the preset traffic threshold, it suspends the write request and writes data to the write cache. The traffic threshold is determined based on the total cache space of the write cache and the reserved cache space. The reserved cache space is determined based on the upload fragment value of the fragmented data in the write cache.

[0022] The aforementioned execution entity pre-allocates a portion of the write cache as a reserved cache space, also known as write reserved space. The size of the reserved cache space is determined based on the upload fragment value of the fragmented data in the write cache. Data fragment upload means that data is continuously written to the write cache. When a segment of data in the write cache reaches a specific size (the upload fragment value of the fragmented data), that fragmented data is uploaded. This upload fragment value can be set according to actual conditions. The size of the reserved cache space is usually greater than or equal to the size of a fragmented data, that is, the reserved cache space is usually greater than or equal to the upload fragment value.

[0023] After determining the reserved cache space, the aforementioned execution entity will also obtain the total cache space for writing cache, and determine the traffic threshold based on the total cache space and the reserved cache space. This traffic threshold is used to determine whether to trigger the rate limiting protection mechanism. For example, the difference between the total cache space and the reserved cache space can be used as the traffic threshold.

[0024] The aforementioned execution entity monitors the used or remaining space of the write cache in real time, i.e., it monitors the used space of the write cache in real time to determine the amount of data to be written to the write cache. In response to a write request, the execution entity determines the amount of data to be written to the write cache and the amount of data to be written by the write request. Based on the amount of data to be written and the amount of data to be written by the write request, the total amount of data to be written to the write cache is determined. Specifically, the sum of the amount of data to be written and the amount of data to be written by the write request can be used as the total amount of data to be written to the write cache.

[0025] After determining the total amount of data to be written to the write cache, the aforementioned execution entity will determine the relationship between the total amount of data written to the write cache and the traffic threshold. If the relationship between the total amount of data written to the write cache and the traffic threshold is determined to be within a preset range, a rate limiting protection mechanism will be triggered. At this time, write requests to the write cache will be suspended. The preset relationship here can be that the total amount of data written is greater than or equal to the traffic threshold. Since in real-world application scenarios, multiple concurrent write requests may simultaneously write data to the write cache, the aforementioned execution entity will then suspend all write requests from writing data to the write cache.

[0026] Furthermore, if the aforementioned execution entity determines that the total amount of data written to the write cache and the traffic threshold do not meet the preset size relationship, that is, if it determines that the total amount of data written to the write cache is not greater than or equal to the traffic threshold, i.e., the total amount of data written to the write cache is less than the traffic threshold, then the rate limiting protection mechanism will not be triggered, i.e., all concurrent write requests are allowed to write data normally.

[0027] Step 202: Assign write permissions to the target write request in the write request according to the reserved cache space, so that the target write request can continue to write data to the target fragment data in the write cache.

[0028] In this embodiment, the execution entity will allocate write permissions to the target write request in the write request according to the reserved cache space, so that the target write request can continue to write data to the target fragment data in the write cache.

[0029] When the rate limiting protection mechanism is triggered, the aforementioned execution entity will suspend all write requests writing data to the write cache. At this time, all write requests will request write permissions from the system. The aforementioned execution entity will allocate write permissions to one or more write requests based on the cache reserved space, and the write request that has been allocated write permissions will be recorded as the target write request. The target write request can continue to write data to the target shard data in the write cache. After allocating write permissions to the target write request, the aforementioned execution entity will also update the remaining allocable amount of cache reserved space.

[0030] Specifically, for each write request, the aforementioned execution entity first determines the space size to be allocated for the current write request based on the amount of data already written in the sharded data to be written by the current write request, and records it as the space to be allocated. Then, it checks whether the sharded data to be written by the write request exists in the predefined set of data structures. If the sharded data to be written by the write request already exists in the set of data structures, it is determined that the write permission application for the current write request is successful, that is, write permission is allocated to the current write request.

[0031] It's important to note that the data structure set is a Map set. As a key-value data structure, Map sets offer advantages such as efficient querying, flexible traversal, and unique keys. They can accurately match the mapping needs between task identifiers and status data under multiple concurrent tasks, serving as a data storage medium. Map sets store key information about concurrent tasks, achieving a one-to-one mapping between task IDs (Identity documents) and task states. Map sets also record cache space allocation, enabling precise control over resource identifiers and usage details. Furthermore, Map sets manage write permission allocation status, enabling dynamic updates of permission IDs and task associations.

[0032] Furthermore, if the data structure set does not contain the shard data to be written by the write request, the execution entity will continue to determine whether the remaining space of the reserved cache space is sufficient. If it is determined that the remaining space of the reserved cache space is sufficient, the current write request will be identified as the target write request, that is, write permission will be assigned to the current write request so that the current write request can continue to write data into the shard data.

[0033] If it is determined that the remaining space in the cache is insufficient, the current write request will be set to a dormant state. After a preset interval (e.g., 100 milliseconds), the write request will re-apply for write permission from the system, and the aforementioned execution entity will re-determine whether to allocate write permission to the write request.

[0034] Step 203: In response to the determination that the data volume of the target fragment has reached the upload fragment value, upload the target fragment data.

[0035] In this embodiment, if the execution entity determines that the data volume of the target fragment has reached the upload fragment value, it uploads the target fragment data. After successfully obtaining write permission, the target write request will continue to write data into the target fragment data. When the target fragment data is full, i.e., the upload fragment value has been reached, the execution entity will upload the target fragment data and release the space occupied by the target fragment data, as well as the write permission of the target write request, after uploading.

[0036] In real-world applications, due to limited cache space, during multi-way concurrent writes (such as uploading multiple files simultaneously), if all concurrent requests write data to the cache, but the amount of data written by each write request has not yet reached the upload chunk size (upload chunk value), a "write deadlock" will occur if the cache space is filled with this incomplete data.

[0037] For example, suppose the total write cache space is 10MB (Megabit), the chunked upload threshold (i.e., the upload chunk value) is 4MB, and there are 3 concurrent tasks, each writing 3.3MB. Then, these 3 concurrent tasks occupy a total of 9.9MB, leaving 0.1MB of space. Now, if any task wants to reach 4MB to trigger an upload, it needs to write another 0.7MB of data, but the write cache space is only 0.1MB. The result is that all tasks cannot trigger uploads, the cache cannot be released, and the system is stuck in write blocking.

[0038] The data writing method provided in this disclosure firstly suspends write requests to the write cache in response to determining that the total amount of data to be written meets a preset size relationship with a preset traffic threshold. Then, it allocates write permissions to the target write request within the write requests based on reserved cache space, allowing the target write request to continue writing data to the target fragment data in the write cache. Finally, in response to determining that the data volume of the target fragment data has reached the upload fragment value, it uploads the target fragment data. This method triggers rate limiting protection when the total amount of data to be written meets a preset size relationship with the preset traffic threshold, and allocates write permissions to the target write request based on the reserved cache space. This ensures that the reserved cache space is not filled with new fragment data, but is reserved for data blocks that are about to reach the upload fragment value, thus triggering the upload condition and resolving the logical deadlock problem during concurrent writing, solving the write blocking problem of the system, thereby improving data writing efficiency, system concurrency performance, and resource utilization.

[0039] Furthermore, the collection, storage, use, processing, transmission, provision, and disclosure of any type of information, such as user personal information, involved in the technical solutions disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0040] Continue to refer to Figure 3 , Figure 3 A flow 300 of a second embodiment of the data writing method according to this disclosure is shown. The data writing method includes the following steps: Step 301: Determine the amount of data to be written to the write cache and the amount of data to be written in the write request.

[0041] In this embodiment, the execution body of the data writing method (e.g.) Figure 1 The server 105 shown determines the amount of data to be written to the write cache and the amount of data to be written in the write request. That is, the aforementioned execution entity monitors the usage space of the write cache in real time to determine the amount of data to be written to the write cache. In response to a write request, the aforementioned execution entity determines the amount of data to be written to the write cache and the amount of data to be written by the write request (the amount of data to be written), and thus determines the total amount of data to be written to the write cache based on the amount of data to be written and the amount of data to be written in the write request.

[0042] Step 302: The sum of the amount of data to be written and the amount of data to be written is taken as the total amount of data to be written.

[0043] In this embodiment, the execution entity will use the sum of the amount of data to be written and the amount of data to be written as the total amount of data to be written.

[0044] Step 303: In response to determining that the total amount of data written is greater than or equal to the traffic threshold, the write request to write data to the write cache is suspended.

[0045] In this embodiment, if the execution entity determines that the total amount of data written is greater than or equal to the traffic threshold, it will suspend write requests to the write cache. After determining the total amount of data written to the write cache, the execution entity will determine the relationship between the total amount of data written to the write cache and the traffic threshold. If it determines that the total amount of data written is greater than or equal to the traffic threshold, it will trigger the rate limiting protection mechanism, at which point it will suspend write requests to the write cache. Since in real-world application scenarios, multiple concurrent write requests may simultaneously write data to the write cache, the execution entity will suspend all write requests from writing to the write cache.

[0046] Therefore, when the total amount of data written is greater than or equal to the traffic threshold, rate limiting protection is triggered, that is, write requests to write data to the write cache are suspended, thereby preventing the cache space from being filled with fragmented data and avoiding write blocking.

[0047] In some optional implementations of this embodiment, the traffic threshold is determined according to the following steps: determining the reserved cache space based on the uploaded fragment value of the fragmented data; and using the difference between the total cache space of the write cache and the reserved cache space as the traffic threshold.

[0048] In this implementation, the aforementioned execution entity pre-allocates a portion of the write cache as a reserved cache space, also known as write reserved space. The size of the reserved cache space is determined based on the upload fragment value of the fragmented data in the write cache. Data fragment upload means that data is continuously written to the write cache. When a segment of data in the write cache reaches a specific size (the upload fragment value of the fragmented data), that fragmented data is uploaded. This upload fragment value can be set according to actual conditions. The size of the reserved cache space is usually greater than or equal to the size of a fragmented data, that is, the reserved cache space is usually greater than or equal to the upload fragment value.

[0049] After determining the reserved cache space, the aforementioned execution entity will also obtain the total cache space for writing cache, and use the difference between the total cache space and the reserved cache space as the traffic threshold. This traffic threshold is used to determine whether to trigger the rate limiting protection mechanism.

[0050] This allows for the determination of traffic thresholds based on the uploaded fragment values ​​and total cache space, avoiding resource waste caused by excessively large reserved space configurations or insufficient configurations to meet fragment rounding requirements.

[0051] Step 304: Assign write permissions to the target write request in the write request according to the reserved cache space, so that the target write request can continue to write data to the target fragment data in the write cache.

[0052] Step 305: In response to the determination that the data volume of the target fragment has reached the upload fragment value, upload the target fragment data.

[0053] Steps 304-305 are basically the same as steps 202-203 in the aforementioned embodiments. For specific implementation methods, please refer to the aforementioned description of steps 202-203, which will not be repeated here.

[0054] from Figure 3 It can be seen from this that, with Figure 2 Compared to the corresponding embodiments, the data writing method in this embodiment triggers rate limiting protection when the total amount of data written is greater than or equal to the traffic threshold. That is, it suspends the write request to write data to the write cache, thereby avoiding the cache space from being filled with fragmented data and avoiding the occurrence of write blocking.

[0055] Continue to refer to Figure 4 , Figure 4 A flow 400 of a third embodiment of the data writing method according to this disclosure is shown. The data writing method includes the following steps: Step 401: Determine the amount of data to be written to the write cache and the amount of data to be written in the write request.

[0056] Step 402: The sum of the amount of data to be written and the amount of data to be written is taken as the total amount of data to be written.

[0057] Step 403: In response to determining that the total amount of data written is greater than or equal to the traffic threshold, the write request to write data to the write cache is suspended.

[0058] Steps 401-403 are basically the same as steps 301-303 in the aforementioned embodiments. For specific implementation methods, please refer to the aforementioned description of steps 301-303, which will not be repeated here.

[0059] Step 404: Determine the space to be allocated for the write request based on the amount of data already written in the fragmented data written in the write request.

[0060] In this embodiment, the execution body of the data writing method (e.g.) Figure 1 The server 105 shown will determine the space to be allocated for the write request based on the amount of data already written in the fragmented data written by the write request. That is, for each write request, the above-mentioned execution entity will first determine the size of the space to be allocated for the current write request based on the amount of data already written in the fragmented data written by the current write request, and record it as the space to be allocated.

[0061] Step 405: In response to determining that there is no fragmented data to be written by the write request in the predefined data structure set, determine whether the reserved cache space and the space to be allocated satisfy the first preset relationship.

[0062] In this embodiment, when the execution entity determines that there is no fragmented data to be written by the write request in the predefined data structure set, it will determine whether the reserved cache space and the space to be allocated satisfy the first preset relationship.

[0063] The aforementioned execution entity will determine whether there is any fragmented data written by the write request in the predefined data structure set. If there is no fragmented data written by the write request in the data structure set, the aforementioned execution entity will continue to determine whether the remaining space of the reserved cache space is sufficient, that is, whether the reserved cache space and the space to be allocated satisfy the first preset relationship, such as whether the reserved cache space is greater than or equal to the space to be allocated.

[0064] It's important to note that the data structure set is a Map set. As a key-value pair data structure, Map sets offer advantages such as efficient querying, flexible traversal, and unique keys. They can accurately match the mapping requirements between task identifiers and status data under multiple concurrent tasks, serving as a data storage medium. Map sets store key information about concurrent tasks, achieving a one-to-one mapping between task IDs and task states. Map sets also record cache space allocation, enabling precise control over resource identifiers and usage details. Furthermore, Map sets manage write permission allocation status, enabling dynamic updates of permission IDs and task associations.

[0065] Step 406: In response to determining that the reserved cache space and the space to be allocated satisfy the first preset relationship, the write request is identified as the target write request, and write permission is assigned to the target write request.

[0066] In this embodiment, when the execution entity determines that the reserved cache space and the space to be allocated satisfy the first preset relationship, it will identify the write request as the target write request and assign write permission to the target write request so that the target write request can continue to write data to the target fragment data in the write cache.

[0067] If it is determined that the reserved cache space and the space to be allocated satisfy the first preset relationship, that is, when it is determined that the reserved cache space is greater than or equal to the space to be allocated, it proves that the remaining space of the cache reserved space is sufficient. Then the above-mentioned execution entity will determine the current write request as the target write request and allocate write permission to the target write request so that the current write request can continue to write data into the sharded data.

[0068] By using a predefined set of data structures for verification, write requests corresponding to existing sharded data can be quickly excluded, avoiding duplicate permission allocation. Furthermore, by determining the target write request based on the reserved cache space and the space to be allocated, the reserved space is focused on the write requests that are "most likely to release the cache quickly," shortening the cache occupancy cycle and improving the cache recycling rate.

[0069] In some optional implementations of this embodiment, the above data writing method further includes: in response to determining that the reserved cache space and the space to be allocated do not satisfy the first preset relationship, setting the write request to a dormant state; and reapplying for write permission for the write request after a preset interval.

[0070] In this implementation, if the execution entity determines that the reserved cache space and the space to be allocated do not meet the first preset relationship, that is, the reserved cache space is not greater than or equal to (i.e., less than) the space to be allocated, it proves that the remaining space of the reserved cache space is insufficient. Then, the current write request is set to a dormant state, and after a preset interval (e.g., 100 milliseconds), the write request will re-apply for write permission from the system, and the execution entity will re-determine whether to allocate write permission to the write request.

[0071] When the reserved cache space and the space to be allocated do not meet the preset relationship, if the write request continues to request permissions, it will create invalid competition with the target write request that meets the conditions, consuming system scheduling resources. The hibernation mechanism, through active pausing and timed retries, allows requests that do not meet the conditions to temporarily leave the competition queue, thereby reducing high-frequency invalid operations such as permission requests and status checks.

[0072] Step 407: In response to the determination that the fragmented data to be written by the write request already exists in the data structure set, the write request is identified as the target write request, and write permissions are assigned to the target write request.

[0073] In this embodiment, if the execution entity determines that the fragmented data to be written by the write request already exists in the data structure set, it identifies the write request as the target write request and assigns write permissions to the target write request. That is, if the fragmented data to be written by the write request already exists in the data structure set, it determines that the write permission application for the current write request has been successful, and write permissions are assigned to the current write request. Thus, through existence verification, permissions are directly assigned to the write request corresponding to the existing fragment, ensuring that it can quickly resume writing and avoiding transmission delays or data redundancy caused by fragmented write interruptions.

[0074] Step 408: In response to the determination that the data volume of the target fragment has reached the upload fragment value, the target fragment data is uploaded.

[0075] Step 408 is basically the same as step 203 in the aforementioned embodiment. For the specific implementation method, please refer to the aforementioned description of step 203, which will not be repeated here.

[0076] from Figure 4 It can be seen from this that, with Figure 3 Compared to the corresponding embodiments, the data writing method in this embodiment can quickly exclude write requests corresponding to existing sharded data through a verification step of a predefined data structure set, avoiding duplicate allocation of permissions; and determine the target write request based on the reserved cache space and the space to be allocated, so that the reserved space focuses on the write request that is "most likely to release the cache quickly", shortening the cache occupation cycle and improving the cache recycling rate.

[0077] Continue to refer to Figure 5 , Figure 5 A flowchart 500 is shown according to a fourth embodiment of the data writing method according to the present disclosure. The data writing method includes the following steps: Step 501: Determine the amount of data to be written to the write cache and the amount of data to be written in the write request.

[0078] Step 502: The sum of the amount of data to be written and the amount of data to be written is taken as the total amount of data to be written.

[0079] Step 503: In response to determining that the total amount of data written is greater than or equal to the traffic threshold, the write request to write data to the write cache is suspended.

[0080] Steps 501-503 are basically the same as steps 301-303 in the aforementioned embodiments. For specific implementation methods, please refer to the aforementioned description of steps 301-303, which will not be repeated here.

[0081] Step 504: For a write request, determine the amount of data to be written to the shard, where the amount of data to be written to the shard is the amount of data already written to the shard in the write request.

[0082] In this embodiment, for a write request, the execution body of the data writing method (e.g.) Figure 1 The server 105 shown will determine the amount of data written in the fragment, where the amount of data written in the fragment is the amount of data already written in the fragment data written by the write request.

[0083] For each write request, the aforementioned execution entity will first determine the amount of data already written in the fragment data to be written by the current write request, i.e., the amount of fragment data written.

[0084] Step 505: Use the difference between the uploaded shard value and the amount of data written to the shard as the space to be allocated.

[0085] In this embodiment, the execution entity calculates the difference between the uploaded fragment value and the fragment write data volume, and uses this difference as the space to be allocated.

[0086] By calculating the uploaded shard value and the amount of data written to the shard, the resources required for shard rounding are quantified into specific values ​​of space to be allocated. This provides clear data basis for resource allocation decisions, improves resource allocation efficiency and accuracy, and avoids resource waste.

[0087] Step 506: In response to determining that there is no fragmented data to be written by the write request in the predefined data structure set, determine whether the reserved cache space and the space to be allocated satisfy the first preset relationship.

[0088] Step 507: In response to determining that the reserved cache space and the space to be allocated satisfy the first preset relationship, the write request is identified as the target write request, and write permission is assigned to the target write request.

[0089] Step 508: In response to the determination that the fragmented data to be written by the write request already exists in the data structure set, the write request is identified as the target write request, and write permissions are assigned to the target write request.

[0090] Steps 506-508 are basically the same as steps 405-407 in the previous embodiment. For specific implementation methods, please refer to the above description of steps 405-407, which will not be repeated here.

[0091] Step 509: Record the target fragment data into the data structure set.

[0092] In this embodiment, the aforementioned execution entity records the information of the target shard data into a data structure set. This data structure set centrally stores the core attributes of all active target shard data through key-value pair mapping, enabling the system to quickly obtain the real-time status of any target shard. For example, using the shard ID as the key, key information such as the amount of data written to the shard and the space to be allocated can be directly queried from the set without traversing the entire cache or multiple scattered variables. This visual management provides clear data support for subsequent decisions such as permission allocation and traffic control, improving scheduling efficiency and avoiding blind scheduling.

[0093] Step 510: Update the reserved cache space and the amount of data written to obtain the updated reserved cache space and the updated amount of data written.

[0094] In this embodiment, after the execution entity identifies the target write request and assigns write permissions to it, the target write request continues to write data to the target shard data. At this time, the execution entity updates the reserved cache space and the amount of data written, obtaining the updated reserved cache space and the updated amount of data written. Thus, by updating the reserved cache space and the amount of data written in real time, the system ensures that the resource status obtained is completely consistent with the actual situation.

[0095] For example, if the target write request A has 0.5MB of space to be allocated and the original reserved cache space is 4MB, after 0.5MB is actually written, the system immediately updates the reserved cache space to 3.5MB and the written data volume to 4MB (reaching the upload threshold). When a new request B requests permission, the system judges based on the updated resource status, avoiding duplicate allocation or insufficient allocation due to data lag, thus improving the accuracy of flow control decisions.

[0096] In some optional implementations of this embodiment, step 510 includes: using the difference between the reserved cache space and the space to be allocated as the updated reserved cache space; and using the sum of the amount of data written and the amount of data written by the target write request in the target shard data as the updated amount of data written.

[0097] In this implementation, the execution entity calculates the difference between the reserved cache space and the space to be allocated, and uses this difference as the updated reserved cache space. The execution entity also calculates the sum of the amount of data written and the amount of data written by the target write request to the target shard, and uses this sum as the updated amount of data written. This ensures the real-time performance, consistency, and accuracy of the reserved cache space and the amount of data written, improving the security of resource management, the efficiency of cache release, and compatibility with multiple concurrency scenarios.

[0098] Step 511: In response to the determination that the data volume of the target fragment data has reached the upload fragment value, the target fragment data is uploaded.

[0099] Step 511 is basically the same as step 203 in the aforementioned embodiment. For the specific implementation method, please refer to the aforementioned description of step 203, which will not be repeated here.

[0100] from Figure 5 It can be seen from this that, with Figure 4 Compared to the corresponding embodiments, the data writing method in this embodiment quantifies the resources required for fragment rounding into specific values ​​of space to be allocated by calculating the uploaded fragment value and the amount of data written to the fragment. This provides clear data basis for resource allocation decisions, improves resource allocation efficiency and accuracy, and avoids resource waste.

[0101] Continue to refer to Figure 6 , Figure 6 A flow 600 of a fifth embodiment of a data writing method according to the present disclosure is shown. The data writing method includes the following steps: Step 601: In response to determining that the total amount of data to be written and the preset traffic threshold meet the preset size relationship, the write request to write data to the write cache is paused.

[0102] Step 602: Assign write permissions to the target write request in the write request according to the reserved cache space, so that the target write request can continue to write data to the target fragment data in the write cache.

[0103] Step 603: In response to the determination that the data volume of the target fragment data has reached the upload fragment value, the target fragment data is uploaded.

[0104] Steps 601-603 are basically the same as steps 201-203 in the aforementioned embodiments. For specific implementation methods, please refer to the aforementioned description of steps 201-203, which will not be repeated here.

[0105] Step 604: Release the space occupied by the target shard data in the write cache and release the write permission of the target write request.

[0106] In this embodiment, the execution body of the data writing method (e.g.) Figure 1 The server 105 shown will, after determining that the data volume of the target fragment has reached the upload fragment value, upload the target fragment data, release the space occupied by the target fragment data in the write cache, and release the write permission of the target write request. After the target fragment data is successfully uploaded, the cache space it occupies is released immediately, increasing the remaining space in the write cache and providing writing conditions for other fragment data that are not yet full, breaking the write deadlock cycle of full cache - inability to form fragments - inability to release. Moreover, as write permission is a scarce resource, its timely release can improve the turnover efficiency of the permission pool. After the target write request completes its task, the corresponding write permission is released immediately and returned to the permission pool, avoiding the permission being idle and occupied for a long time.

[0107] Step 605: In response to determining that the total amount of data written does not meet the preset size relationship with the flow threshold and the data structure set is a non-empty set, the data structure set is cleared and the allocated amount of the space to be allocated is cleared to zero.

[0108] In this embodiment, if the execution entity determines that the total amount of written data does not meet the preset size relationship with the traffic threshold and the data structure set is not empty, it clears the data structure set and resets the allocated space to zero. That is, the execution entity performs periodic checks on the cache space. It first sets the write cache usage to the current value and sets the write cache increment to 0. If it determines that the write cache usage is less than or equal to the traffic threshold and the data structure set is not empty, it clears the data structure set and resets the allocated space to zero. If the write cache usage is not less than or equal to the traffic threshold and the data structure set is not empty, the check ends.

[0109] By clearing the set and zeroing the allocated quantity in abnormal scenarios, the system's ability to overcome extreme blocking, resource release efficiency, and anomaly self-healing capability are improved, and the stability and reliability of the system in complex abnormal scenarios are further enhanced.

[0110] from Figure 6 It can be seen from this that, with Figure 2 Compared to the corresponding embodiments, the data writing method in this embodiment releases the cache space occupied by the target fragment data immediately after it is successfully uploaded, increasing the remaining space of the write cache and providing writing conditions for other fragment data that are not yet fully aggregated. This breaks the write deadlock loop of full cache - inability to aggregate fragments - inability to release data. Moreover, as write permissions are a scarce resource, timely release can improve the turnover efficiency of the permission pool. After the target write request completes its task, the corresponding write permission is released immediately and returned to the permission pool, avoiding the permission being idle and occupied for a long time.

[0111] Continue to refer to Figure 7-1 , Figure 7-1 An application flow of the data writing method according to this disclosure is shown, including: Step 7101, write request completed; Step 7102: Calculate the total amount of data written to the write cache. The total amount of data written is the sum of the amount of data written to the cache and the amount of data to be written in the write request. Step 7103: Determine whether the total amount of data written is less than or equal to the traffic threshold. If yes, proceed to step 7113; otherwise, proceed to step 7104. Step 7104: Obtain the amount of data written to the shard. The amount of data written to the shard is the amount of data already written to the shard in the write request. Step 7105: Calculate the space to be allocated. The space to be allocated is determined based on the difference between the uploaded fragment value and the fragment data volume. Step 7106: Determine whether the sharded data written by the write request exists in the Map collection. If yes, proceed to step 7110; otherwise, proceed to step 7107. Step 7107: Determine if the remaining space of the reserved cache is sufficient. If yes, proceed to step 7108; otherwise, proceed to step 7111. Step 7108: Record the sharded data of the write request into the Map collection and update the allocated space. Step 7109: Update the cache write data volume by adding the original cache write data volume to the number of data to be written. Step 7110: Application successful. Step 7111: Deny the request, that is, refuse to grant write permission for the write request; Step 7112: Set the write request to a dormant state and re-apply for write permission after an interval of 100 milliseconds, that is, execute step 7102 again after an interval of 100 milliseconds. Step 7113, update the cache write data volume; Step 7114: The current write request continues to write data and returns a success message.

[0112] Continue to refer to Figure 7-2 , Figure 7-2 The following is an application flow of the periodic cache space checking method: Step 7201: Begin cache space cycle check; Step 7202: Set the write cache size to the current value; Step 7203: Set the write request increment to 0; Step 7204: Determine whether the write cache usage is less than the traffic threshold and the Map collection is not empty. If yes, proceed to step 7205; otherwise, end this check. Step 7205: Clear the Map collection, set the allocated space to 0, and end this check.

[0113] Further reference Figure 8 As an implementation of the methods shown in the above figures, this disclosure provides an embodiment of a data writing device, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.

[0114] like Figure 8As shown, the data writing device 800 of this embodiment includes: a pause writing module 801, a permission allocation module 802, and a data upload module 803. The pause writing module 801 is configured to pause writing requests to the write cache in response to determining that the total amount of data to be written and a preset traffic threshold satisfy a preset size relationship. The traffic threshold is determined based on the total cache space of the write cache and the reserved cache space. The reserved cache space is determined based on the upload fragment value of the fragmented data in the write cache. The permission allocation module 802 is configured to allocate write permissions to the target write request in the write request according to the reserved cache space, so that the target write request can continue to write data to the target fragmented data in the write cache. The data upload module 803 is configured to upload the target fragmented data in response to determining that the amount of data in the target fragmented data has reached the upload fragment value.

[0115] In this embodiment, the specific processing of the pause writing module 801, the permission allocation module 802, and the data upload module 803 in the data writing device 800, and the resulting technical effects, can be found in the following references: Figure 2 The relevant descriptions of steps 201-203 in the corresponding embodiments will not be repeated here.

[0116] In some optional implementations of this embodiment, the data writing device 800 further includes a threshold generation module for generating a traffic threshold. The threshold generation module is configured to: determine the reserved cache space based on the uploaded fragment value of the fragmented data; and use the difference between the total cache space of the write cache and the reserved cache space as the traffic threshold.

[0117] In some optional implementations of this embodiment, the pause write module 801 is further configured to: determine the amount of data to be written in the write cache and the amount of data to be written in the write request; take the sum of the amount of data to be written and the amount of data to be written as the total amount of data to be written; and, in response to determining that the total amount of data to be written is greater than or equal to the traffic threshold, pause the write request from writing data to the write cache.

[0118] In some optional implementations of this embodiment, the permission allocation module 802 includes: a space determination submodule, configured to determine the space to be allocated for the write request based on the amount of data already written in the fragmented data written by the write request; a judgment submodule, configured to determine whether the reserved cache space and the space to be allocated satisfy a first preset relationship in response to determining that there is no fragmented data written by the write request in the predefined data structure set; and an allocation submodule, configured to determine the write request as the target write request and allocate write permission to the target write request in response to determining that the reserved cache space and the space to be allocated satisfy the first preset relationship.

[0119] In some optional implementations of this embodiment, the data writing device 800 further includes: a hibernation module, configured to set the write request to a hibernation state in response to determining that the reserved cache space and the space to be allocated do not satisfy a first preset relationship; and to re-apply for write permission for the write request after a preset interval.

[0120] In some optional implementations of this embodiment, the space determination submodule is further configured to: for a write request, determine the amount of data to be written in the fragment, wherein the amount of data to be written in the fragment is the amount of data already written in the fragment data to be written in the write request; and use the difference between the uploaded fragment value and the amount of data to be written in the fragment as the space to be allocated.

[0121] In some optional implementations of this embodiment, the data writing device 800 further includes: a recording module configured to record the target fragment data into a data structure set; and an updating module configured to update the reserved cache space and the amount of data to be written, thereby obtaining the updated reserved cache space and the updated amount of data to be written.

[0122] In some optional implementations of this embodiment, the update module is further configured to: use the difference between the reserved cache space and the space to be allocated as the updated reserved cache space; and use the sum of the amount of data written and the amount of data written by the target write request in the target shard data as the updated amount of data written.

[0123] In some optional implementations of this embodiment, the data writing device 800 further includes a target request determination module, configured to determine the write request as a target write request in response to determining that the fragmented data to be written by the write request already exists in the data structure set.

[0124] In some optional implementations of this embodiment, the data upload module 803 is further configured to: upload the target fragment data in response to determining that the data volume of the target fragment data has reached the upload fragment value; release the space occupied by the target fragment data in the write cache; and release the write permission of the target write request.

[0125] In some optional implementations of this embodiment, the data writing device 800 further includes: a release module, configured to clear the data structure set and reset the allocated amount of the space to be allocated to zero in response to determining that the total amount of written data and the flow threshold do not meet the preset size relationship and the data structure set is a non-empty set.

[0126] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0127] Figure 9A schematic block diagram of an example electronic device 900 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0128] Figure 9 A schematic block diagram of an example electronic device 900 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0129] like Figure 9 As shown, device 900 includes a computing unit 901, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 902 or a computer program loaded from storage unit 908 into random access memory (RAM) 903. RAM 903 may also store various programs and data required for the operation of device 900. The computing unit 901, ROM 902, and RAM 903 are interconnected via bus 904. Input / output (I / O) interface 905 is also connected to bus 904.

[0130] Multiple components in device 900 are connected to I / O interface 905, including: input unit 906, such as keyboard, mouse, etc.; output unit 907, such as various types of monitors, speakers, etc.; storage unit 908, such as disk, optical disk, etc.; and communication unit 909, such as network card, modem, wireless transceiver, etc. Communication unit 909 allows device 900 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0131] The computing unit 901 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above, such as the data writing method. For example, in some embodiments, the data writing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on device 900 via ROM 902 and / or communication unit 909. When the computer program is loaded into RAM 903 and executed by the computing unit 901, one or more steps of the data writing method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform the data writing method by any other suitable means (e.g., by means of firmware).

[0132] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0133] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0134] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0135] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0136] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0137] Cloud computing refers to a technological system that enables access to elastic and scalable shared physical or virtual resources via a network. These resources can include servers, operating systems, networks, software, and storage devices, and can be deployed and managed in an on-demand, self-service manner. Cloud computing technology can provide efficient and powerful data processing capabilities for applications such as artificial intelligence and blockchain, as well as for model training.

[0138] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and Virtual Private Server (VPS) services, such as high management difficulty and weak business scalability.

[0139] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0140] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A data writing method, comprising: suspending a write request from writing data into a write cache in response to determining that a total amount of the data to be written and a preset traffic threshold meet a preset size relationship, wherein the traffic threshold is determined according to a total cache space of the write cache and a reserved cache space, and the reserved cache space is determined according to an upload shard value of a shard data in the write cache; allocating a write permission for a target write request in the write request according to the reserved cache space, so as to enable the target write request to continue writing data into a target shard data in the write cache; uploading the target shard data in response to determining that a data amount of the target shard data reaches the upload shard value.

2. The method of claim 1, wherein, The traffic threshold is determined according to the following steps: determining the reserved cache space according to the upload shard value of the shard data; taking a difference between the total cache space of the write cache and the reserved cache space as the traffic threshold.

3. The method of claim 1, wherein, The suspending the write request from writing data into the write cache in response to determining that the total amount of the data to be written and the preset traffic threshold meet the preset size relationship comprises: determining a written data amount of the write cache and a to-be-written data amount of the write request; taking a sum of the written data amount and the to-be-written data amount as the total amount of the data to be written; suspending the write request from writing data into the write cache in response to determining that the total amount of the data to be written is greater than or equal to the traffic threshold.

4. The method of claim 3, wherein, The allocating the write permission for the target write request in the write request according to the reserved cache space comprises: determining a to-be-allocated space allocated for the write request according to a written data amount of a shard data written by the write request; determining whether the reserved cache space and the to-be-allocated space meet a first preset relationship in response to determining that the shard data written by the write request does not exist in a predefined data structure set; determining the write request as the target write request and allocating a write permission for the target write request in response to determining that the reserved cache space and the to-be-allocated space meet the first preset relationship.

5. The method of claim 4, further comprising: setting the write request to a dormant state in response to determining that the reserved cache space and the to-be-allocated space do not meet the first preset relationship; reapplying for a write permission for the write request after a preset time interval.

6. The method of claim 4, wherein, The determining the to-be-allocated space allocated for the write request according to the written data amount of the shard data written by the write request comprises: determining a shard written data amount for the write request, wherein the shard written data amount is the written data amount of the shard data written by the write request; taking a difference between the upload shard value and the shard written data amount as the to-be-allocated space.

7. The method of claim 4, further comprising: recording the target shard data into the data structure set; updating the reserved cache space and the written data amount to obtain an updated reserved cache space and an updated written data amount.

8. The method of claim 7, wherein, The updating the reserved cache space and the written data amount to obtain the updated reserved cache space and the updated written data amount comprises: a difference between the reserved cache space and the to-be-allocated space as the updated reserved cache space; a sum of the write data amount and a data amount of the target shard data written by the target write request as the updated write data amount.

9. The method of claim 4, further comprising: in response to determining that the shard data written by the write request already exists in the set of data structures, determining the write request as the target write request.

10. The method of claim 1, wherein, the uploading of the target shard data in response to determining that the data amount of the target shard data reaches the upload shard value, comprises: in response to determining that the data amount of the target shard data reaches the upload shard value, uploading the target shard data; releasing a space occupied by the target shard data in the write cache and releasing a write permission of the target write request.

11. The method of claim 4, further comprising: in response to determining that the total write data amount and the traffic threshold do not satisfy the preset size relationship and the set of data structures is a non-empty set, emptying the set of data structures and clearing the allocated amount of the to-be-allocated space.

12. A data writing apparatus, comprising: a pausing writing module configured to pause a write request from writing data into a write cache in response to determining that a total write data amount and a preset traffic threshold satisfy a preset size relationship, wherein the traffic threshold is determined according to a total cache space of the write cache and a reserved cache space, and the reserved cache space is determined according to an upload shard value of shard data in the write cache; a permission allocation module configured to allocate a write permission to a target write request in the write request according to the reserved cache space, so that the target write request continues to write data into target shard data in the write cache; a data uploading module configured to upload the target shard data in response to determining that a data amount of the target shard data reaches the upload shard value.

13. An electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-11.

14. A non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1-11.

15. A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1-11.