Data reading and writing method and device, electronic equipment and readable storage medium
By dynamically adjusting the weight value of the data bucket and selecting a high-availability target bucket for data reading and writing, the problem of low data storage reliability caused by a single cloud provider bucket is solved, and the success rate and stability of data reading and writing are improved. .
Patent Information
- Application Number
- CN202410507610.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-25
- Publication Date
- 2024-08-23
AI Technical Summary
In the existing technology, user data is stored in the storage bucket of a single cloud provider, resulting in low reliability of data storage and acquisition, and prone to failure. How to improve the success rate and stability of data reading and writing.
By receiving the client's request information, the data bucket mapped to the logical bucket is determined, and a high-availability target bucket is selected for data reading and writing based on the weight value of each data bucket. The weight value is dynamically adjusted based on the number of times the response information is stored. Ensure data storage availability.
It improves the efficiency and success rate of data reading and writing, achieves high availability and decoupling of data storage, and avoids data access failures caused by the failure of a single cloud provider.
Smart Images

Figure CN118535087A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data reading and writing method, device, electronic equipment and readable storage medium. Background Art
[0002] As Internet services continue to grow, the amount of data that users need to store and retrieve is increasing day by day. Object Storage Service (OSS) has become the first choice for many users to store data.
[0003] Currently, users directly access a storage bucket of a certain cloud provider, so the reliability of the data is directly affected by the storage bucket of the cloud provider, and data storage or retrieval failures may easily occur.
[0004] Therefore, how to improve the success rate and stability of data reading and writing is a problem that needs to be solved. Summary of the invention
[0005] The purpose of the embodiments of the present invention is to provide a data reading and writing method, device, electronic device and readable storage medium, which can improve the success rate and stability of data reading and writing. The specific technical solution is as follows:
[0006] In a first aspect of the present invention, a data reading and writing method is first provided, comprising:
[0007] Receive first request information sent by a client, where the first request information includes a first identifier, the first request information is used to request to read or write first data, and the first identifier is used to indicate a logical storage bucket;
[0008] Determine at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier;
[0009] In response to the first request information, determining a first weight value of each data storage bucket at the current moment; the first weight value is proportional to the number of times the data storage bucket generates storage response information;
[0010] According to the first weight value, determining at least one data storage bucket satisfying a first condition from at least one data storage bucket as a target storage bucket;
[0011] The first data is read from the target storage bucket or the first data is written to the target storage bucket.
[0012] In a second aspect of the present invention, a data reading and writing device is provided, comprising:
[0013] A receiving module, used for receiving first request information sent by a client, the first request information including a first identifier, the first request information is used for requesting to read or write first data, and the first identifier is used to indicate a logical storage bucket;
[0014] A first determining module, configured to determine at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier;
[0015] A second determination module is used to determine a first weight value of each data storage bucket at a current moment in response to the first request information; the first weight value is proportional to the number of times the data storage bucket generates storage response information;
[0016] A third determination module is used to determine, according to the first weight value, at least one data storage bucket satisfying the first condition from at least one data storage bucket as a target storage bucket;
[0017] The read / write module is used to read the first data from the target storage bucket or write the first data into the target storage bucket.
[0018] In another aspect of the present invention, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes any of the above-mentioned data forwarding methods.
[0019] In another aspect of the present invention, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned data reading and writing methods.
[0020] The data reading and writing method provided by the embodiment of the present invention receives a first request message sent by a client, the first request message includes a first identifier, the first request message is used to request to read or write the first data, and the first identifier is used to indicate a logical storage bucket; determines at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier; in response to the first request message, determines a first weight value of each data storage bucket at the current moment; the first weight value is proportional to the number of times the data storage bucket generates storage response information, the storage response information is generated when the data storage bucket successfully stores data, the more times the data storage bucket generates storage response information, the larger the first weight value of the data storage bucket is, that is, the first weight value can characterize the availability of the data storage bucket, and according to the first weight value, determines at least one data storage bucket that meets the first condition from at least one data storage bucket as a target storage bucket, here, a data storage bucket with high availability can be quickly and accurately determined as the target storage bucket; finally, reading the first data from the target storage bucket or writing the first data to the target storage bucket can improve the efficiency and success rate of data reading and writing. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0022] Figure 1 is a flow chart of a data reading and writing method provided by an embodiment of the present invention;
[0023] Figure 2 is a schematic diagram of a data reading and writing architecture provided by an embodiment of the present invention;
[0024] Figure 3 It is a structural schematic diagram of a data reading and writing device provided by an embodiment of the present invention;
[0025] Figure 4 It is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0027] The data reading and writing method provided by the embodiment of the present invention can be applied to at least the following application scenarios, which are described below.
[0028] At present, with the continuous increase of Internet business, the amount of data that companies need to store is increasing day by day. Object Storage Service (OSS) has the characteristics of high bandwidth, high concurrency, massive storage, horizontal expansion and low price, and has become the first choice for many companies to store data.
[0029] The basic storage unit of object storage is the object, and the corresponding storage bucket is the bucket. Currently, the commonly used object storage in the industry is generally provided by public clouds. Users first create a bucket through the public cloud platform, and then access the objects in the bucket through the software development kit provided by the corresponding cloud provider.
[0030] Cloud commerce, also known as smart cloud commerce, is a general architecture based on cloud strategy. It adopts cloud computing service middleware integration technology and super resource integration capabilities, is based on the service delivery of mature business models, and is a platform derived from traditional, public cloud computing, and cloud service products.
[0031] Generally, users will directly access a bucket of a certain cloud provider. This has the disadvantage that the user's data is strongly bound to a single bucket of a single cloud provider, so the reliability of the data is directly affected by the bucket of the cloud provider. If the bucket of the cloud provider fails, the user's access to the data will also be directly affected. From the user's perspective, there is still a probability of failure in accessing the bucket.
[0032] The storage bucket of public cloud object storage is a storage bucket. Users often read and write data directly from the bucket. Therefore, the reliability of data access is completely affected by the availability of the bucket. If a public cloud bucket fails, data access will also fail. How to solve the problem of strong binding between business and a single cloud vendor's storage bucket, realize the decoupling of data access, and then improve the reliability of object storage is a problem that needs to be solved.
[0033] Based on the above application scenarios, the data reading and writing method provided by the embodiment of the present invention is described in detail below.
[0034] Figure 1 A flowchart of a data reading and writing method provided by an embodiment of the present invention.
[0035] like Figure 1 As shown, the data reading and writing method may include steps 110 to 150, and the method is applied to a data reading and writing device, as shown below:
[0036] Step 110, receiving first request information sent by a client, the first request information including a first identifier, the first request information is used to request to read or write first data, and the first identifier is used to indicate a logical storage bucket;
[0037] Step 120, determining at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier;
[0038] Step 130, in response to the first request information, determining a first weight value of each data storage bucket at the current moment; the first weight value is proportional to the number of times the data storage bucket generates storage response information;
[0039] Step 140, determining at least one data storage bucket satisfying a first condition from at least one data storage bucket according to the first weight value as a target storage bucket;
[0040] Step 150: read the first data from the target storage bucket or write the first data into the target storage bucket.
[0041] The data reading and writing method provided by the embodiment of the present invention receives a first request message sent by a client, the first request message includes a first identifier, the first request message is used to request to read or write the first data, and the first identifier is used to indicate a logical storage bucket; determines at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier; in response to the first request message, determines a first weight value of each data storage bucket at the current moment; the first weight value is proportional to the number of times the data storage bucket generates storage response information, the storage response information is generated when the data storage bucket successfully stores data, the more times the data storage bucket generates storage response information, the larger the first weight value of the data storage bucket is, that is, the first weight value can characterize the availability of the data storage bucket, and according to the first weight value, determines at least one data storage bucket that meets the first condition from at least one data storage bucket as a target storage bucket, here, a data storage bucket with high availability can be quickly and accurately determined as the target storage bucket; finally, reading the first data from the target storage bucket or writing the first data to the target storage bucket can improve the efficiency and success rate of data reading and writing.
[0042] The specific implementation methods of the above steps are introduced below.
[0043] This involves step 110 .
[0044] A first request message sent by a client is received, where the first request message includes a first identifier, the first request message is used to request to read or write first data, and the first identifier is used to indicate a logical storage bucket.
[0045] For the client, the first identifier is used to indicate the storage bucket where the client wants to store the first data. For the server, the first identifier is used to indicate the logical storage bucket, which is not responsible for storing data. At least one data storage bucket having a mapping relationship with the logical storage bucket is used to store data.
[0046] The object storage service on the server side may include multiple identifiers for indicating logical storage buckets, including a first identifier. The server side determines the storage bucket where the client wants to store data based on the first identifier in the request information sent by the client.
[0047] This involves step 120 .
[0048] At least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier is determined.
[0049] Exemplarily, the first identifier is used to indicate a logical storage bucket BucketABC, and at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier includes: BucketA, BucketB, and BucketC.
[0050] BucketA, BucketB and BucketC can belong to the same cloud provider or different cloud providers, which is not limited here. Cloud providers, also known as smart cloud providers, are a common architecture based on cloud strategies, using cloud computing service middleware integration technology and super resource integration capabilities, based on mature business model service delivery, and a platform derived from traditional, public cloud computing, and cloud service products.
[0051] The configuration information corresponding to the first identifier includes: a mapping relationship between a logical storage bucket and a data storage bucket, a logical storage bucket access method, and a domain name of the logical storage bucket.
[0052] In a possible embodiment, before step 120, the following steps may also be included:
[0053] At least one mapping relationship is stored, each mapping relationship being used to indicate a relationship between a logical storage bucket and at least one data storage bucket.
[0054] Each mapping relationship is used to indicate the relationship between a logical storage bucket and at least one data storage bucket.
[0055] Exemplarily, the mapping relationship is a mapping relationship between a logical storage bucket BucketABC and data storage buckets BucketA, BucketB and BucketC. Alternatively, the mapping relationship is a mapping relationship between a logical storage bucket Buck123 and data storage buckets Buck1, Bucket2 and Buck3.
[0056] Thus, storing at least one mapping relationship facilitates determining, based on the stored mapping relationship, at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier.
[0057] This involves step 130 .
[0058] In response to the first request information, a first weight value of each data storage bucket at the current moment is determined; the first weight value is proportional to the number of times the data storage bucket generates storage response information.
[0059] Among them, the storage response information is generated when the data storage bucket successfully stores data. The more times the data storage bucket generates storage response information, the larger the first weight value of the data storage bucket will be, that is, the first weight value can represent the availability of the data storage bucket.
[0060] Thus, the first weight value is used to identify the availability of the data storage bucket, and the data storage bucket with a high first weight value will be used to upload data first. The size of the first weight value changes in real time, and the first weight value can be determined in the following way.
[0061] In a possible embodiment, step 130 includes:
[0062] In response to the first request information, for each data storage bucket, determine the first number of request information received by the data storage bucket in the N-1th unit time, the second number of response failure information generated by the data storage bucket in the N-1th unit time, and the second weight value in the N-1th unit time; N is an integer greater than 1; the response failure information is used to indicate a data storage failure or a data acquisition failure; the current time is in the Nth unit time;
[0063] A first weight value is determined according to the first quantity, the second quantity, and the second weight value.
[0064] For each data storage bucket, the first number of request information received by the data storage bucket in the N-1th unit time, the second number of response failure information generated by the data storage bucket in the N-1th unit time, and the second weight value in the N-1th unit time are continuously collected.
[0065] The received request information refers to the request information received from each client.
[0066] The response failure information is used to indicate a data storage failure or a data acquisition failure. The generation scenario of the response failure information may include: the data storage bucket fails to store data in response to the first request information, and the response failure information is generated; or the data storage bucket fails to read data in response to the second request information, and the response failure information is generated. Here, the response failure information is used to indicate that the data storage bucket has a fault.
[0067] According to the first quantity, the second quantity and the second weight value, the first weight value is determined, and the first weight value of the data storage bucket can be dynamically updated according to the trend of the number of errors per unit time of each data storage bucket. Thus, the weight value of the data storage bucket can be determined timely and efficiently, so that according to the first weight value that can be used to characterize the availability size of the data storage bucket, a data storage bucket with strong availability is allocated to the first data, thereby improving the efficiency and success rate of data storage.
[0068] The specific calculation method is as follows: Assume that the number of visits to a data storage bucket in the N-1th minute is H, of which A requests return failures and HA requests return successes. The first weight value at the current moment is as follows:
[0069] W(N)=[(HA) / H+W(N-1)] / 2;
[0070] The first number of request information received by the data storage bucket in the N-1th unit time is H.
[0071] The second amount of response failure information generated by the data storage bucket in the N-1th unit time is: A;
[0072] The second weight value at the N-1th unit time: W(i-1);
[0073] The first weight value at the Nth unit time: W(N).
[0074] Based on an embodiment of the present invention, the first weight value corresponding to the data storage bucket is dynamically adjusted according to the availability of the data storage bucket. The weight of the data storage bucket with low availability will be reduced, and the weight of the data storage bucket with high availability will be increased. This can reflect the availability of each data storage bucket, so that subsequently, at least one data storage bucket that meets the first condition can be determined from at least one data storage bucket according to the first weight value as the target storage bucket.
[0075] This involves step 140 .
[0076] At least one data storage bucket satisfying a first condition is determined from at least one data storage bucket according to the first weight value to serve as a target storage bucket.
[0077] The first weight value represents the availability of the data storage bucket. A data storage bucket with high availability will be selected as the target storage bucket to read and write data, thereby improving the overall availability of the data storage bucket.
[0078] In a possible embodiment, 140 includes:
[0079] Obtain configuration information corresponding to the first identifier, where the configuration information includes a third number of data storage buckets required by the client;
[0080] According to the first weight value, a third number of data storage buckets satisfying the first condition are determined from the at least one data storage bucket.
[0081] The configuration information is configured when at least one data storage bucket corresponding to the first identifier is created, and the configuration information includes a third quantity, wherein the third quantity is used to indicate the quantity of the first data to be backed up.
[0082] The first condition is used to indicate that the first weight value is greater than a preset weight threshold, or the first weight value corresponding to the data storage bucket is in the top R% of all first weight values, where R is a positive integer.
[0083] Thus, according to the first weight value, a third number of data storage buckets satisfying the first condition are determined from at least one data storage bucket, so that data storage buckets with high availability can be selected quickly and efficiently, and the backup requirements of the user can be met.
[0084] In a possible embodiment, the above-mentioned step of determining a third number of data storage buckets satisfying the first condition from at least one data storage bucket according to the first weight value may specifically include the following steps:
[0085] After sorting the first weight values in descending order, determine the first N first weight values, where N is a positive integer;
[0086] Determine, from at least one data storage bucket, data storage buckets corresponding to first N first weight values;
[0087] A third number of data storage buckets are determined from the data storage buckets corresponding to the first N first weight values.
[0088] After sorting the first weight values in descending order, determine the first N first weight values, where N can be 1, 2, 3, and so on;
[0089] Determine the data storage buckets corresponding to the first N first weight values from at least one data storage bucket, indicating that the first N first weight values are one or more first weight ranking buckets in the at least one data storage bucket.
[0090] Since the first weight value represents the availability of the data storage bucket, a higher weight value indicates a higher availability, that is, the data storage buckets corresponding to the first N first weight values are data storage buckets with higher availability.
[0091] Exemplarily, the data storage bucket corresponding to the first identifier is BucketABC, and BucketABC is bound to BucketA, BucketB, BucketC, ... and BucketM, M data storage buckets.
[0092] As shown in Table 1, the first weight values corresponding to BucketA, BucketB and BucketC are 0.81, 0.92 and 0.99 respectively. The first weight values corresponding to BucketA, BucketB and BucketC are greater than the first weight values corresponding to other storage buckets (not shown in the table) in at least one data storage bucket. Therefore, the data storage buckets corresponding to the first N first weight values are: BucketA, BucketB and BucketC.
[0093] Table 1
[0094] Data Bucket The first weight value BucketA 0.81 BucketB 0.92 BucketC 0.99
[0095] Since the third number is 2, the third number of data storage buckets are: Bucket B and Bucket C. The first data to be stored is: object objectXYZ, so object objectXYZ can be uploaded to Bucket B and Bucket C. That is, object objectXYZ is stored in Bucket B and Bucket C respectively.
[0096] Therefore, according to the size of the first weight value, a data storage bucket with high availability is determined from at least one data storage bucket, so that the data storage bucket with high availability can be selected quickly and efficiently, and the backup requirements of the user can be met.
[0097] This involves step 150 .
[0098] The first data is read from the target storage bucket or the first data is written to the target storage bucket.
[0099] When the first request information is used to request to read the first data, read the first data from the target storage bucket;
[0100] In a case where the first request information is used to request reading and writing of the first data, the first data is written into the target storage bucket.
[0101] In the case where the first request information is used to request reading or writing of the first data, the first request information may include identification information of the first data, and the identification information of the first data is used to indicate the first data.
[0102] In a possible embodiment, step 150 includes:
[0103] In the case of detecting response failure information generated by a data storage bucket, re-determining a data storage bucket from at least one data storage bucket; the response failure information is used to indicate a data write failure;
[0104] The first data is written into the re-determined data storage bucket.
[0105] At this time, when the response failure information generated by the data storage bucket is detected, the time of the response failure information generated by the data storage bucket can be located in the time period of the whole process of writing data to the data storage bucket. At this time, the data storage bucket is re-determined from at least one data storage bucket.
[0106] The step of re-determining the data storage bucket from at least one data storage bucket may specifically include the following steps:
[0107] A data storage bucket is re-determined from at least one data storage bucket according to the first weight value.
[0108] The first weight value corresponding to the re-determined data storage bucket may be greater than the preset weight value.
[0109] Alternatively, the re-determined first weight value corresponding to the data storage bucket may be the first M first weight values obtained by sorting the first weight values of at least one data storage bucket in descending order, where M is a positive integer.
[0110] Then, the first request information is scheduled to the re-determined data storage bucket, so as to write the first data into the re-determined data storage bucket, thereby improving data storage efficiency and success rate.
[0111] In a possible embodiment, the first request information is used to request to read the first data. After step 150, the following steps may also be included:
[0112] The first data is sent to the client.
[0113] In the case where the first request information is for requesting to read the first data, step 150 specifically reads the first data from the target storage bucket, and then, after step 150, sends the first data to the client to meet the user's demand for reading the first data.
[0114] The data reading and writing method provided by the embodiment of the present invention receives a first request message sent by a client, the first request message includes a first identifier, the first request message is used to request to read or write the first data, and the first identifier is used to indicate a logical storage bucket; determines at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier; in response to the first request message, determines a first weight value of each data storage bucket at the current moment; the first weight value is proportional to the number of times the data storage bucket generates storage response information, the storage response information is generated when the data storage bucket successfully stores data, the more times the data storage bucket generates storage response information, the larger the first weight value of the data storage bucket is, that is, the first weight value can characterize the availability of the data storage bucket, and according to the first weight value, determines at least one data storage bucket that meets the first condition from at least one data storage bucket as a target storage bucket, here, a data storage bucket with high availability can be quickly and accurately determined as the target storage bucket; finally, reading the first data from the target storage bucket or writing the first data to the target storage bucket can improve the efficiency and success rate of data reading and writing.
[0115] Based on the above Figure 1 The data reading and writing method shown in the embodiment of the present invention also provides a data reading and writing architecture, such as Figure 2 As shown, the data reading and writing architecture includes a client 100 and a server 800. The server 800 is a structural example of a data reading and writing device involved in an embodiment of the present invention, which is specifically shown as follows:
[0116] The client 100 is used to send a first request message, where the first request message includes a first identifier, where the first request message is used to request to read or write first data, and where the first identifier is used to indicate a logical storage bucket.
[0117] Server 800, including:
[0118] The scheduling module 200 is used to determine at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier, and query the weight configuration module 300 for a first weight value of each data storage bucket at a current moment;
[0119] The weight configuration module 300 is used to store the first weight value of each data storage bucket at the current moment, so that the first weight value can be modified in real time by the policy module 400 and queried in real time by the scheduling module 200.
[0120] The policy module 400 is used to determine a first number of request information received by the data storage bucket in the N-1th unit time, a second number of response failure information generated by the data storage bucket in the N-1th unit time, and a second weight value in the N-1th unit time; and determine a first weight value based on the first number, the second number and the second weight value.
[0121] The error statistics module 500 is used to read the response failure information generated by the data storage bucket in the N-1th unit time, and to count the second number of response failure information; the response failure information is used to indicate data storage failure or data acquisition failure.
[0122] The index module 600 is used to store a mapping relationship between a logical storage bucket and at least one data storage bucket; and to store a mapping relationship between a name of the first data and a data storage bucket where the first data is stored.
[0123] Based on the above Figure 1 The data reading and writing method shown in the figure, the embodiment of the present invention also provides a data reading and writing device, such as Figure 3 As shown, the data reading and writing device 300 may include:
[0124] The receiving module 310 is used to receive first request information sent by a client, where the first request information includes a first identifier, the first request information is used to request to read or write first data, and the first identifier is used to indicate a logical storage bucket;
[0125] A first determination module 320, configured to determine at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier;
[0126] The second determination module 330 is used to determine a first weight value of each data storage bucket at a current moment in response to the first request information; the first weight value is proportional to the number of times the data storage bucket generates storage response information;
[0127] A third determination module 340 is used to determine, according to the first weight value, at least one data storage bucket satisfying the first condition from at least one data storage bucket as a target storage bucket;
[0128] The read / write module 350 is configured to read the first data from the target storage bucket or write the first data into the target storage bucket.
[0129] In a possible embodiment, the second determining module 330 is specifically configured to:
[0130] In response to the first request information, for each data storage bucket, determine the first number of request information received by the data storage bucket in the N-1th unit time, the second number of response failure information generated by the data storage bucket in the N-1th unit time, and the second weight value in the N-1th unit time; N is an integer greater than 1; the response failure information is used to indicate a data storage failure or a data acquisition failure; the current time is in the Nth unit time;
[0131] A first weight value is determined according to the first quantity, the second quantity, and the second weight value.
[0132] In a possible embodiment, the third determining module 340 is specifically configured to:
[0133] Obtain configuration information corresponding to the first identifier, where the configuration information includes a third number of data storage buckets required by the client;
[0134] According to the first weight value, a third number of data storage buckets satisfying the first condition are determined from the at least one data storage bucket.
[0135] In a possible embodiment, the third determining module 340 is specifically configured to:
[0136] After sorting the first weight values in descending order, determine the first N first weight values, where N is a positive integer;
[0137] Determine, from at least one data storage bucket, data storage buckets corresponding to first N first weight values;
[0138] A third number of data storage buckets are determined from the data storage buckets corresponding to the first N first weight values.
[0139] In a possible embodiment, the data reading and writing device 300 may further include:
[0140] The sending module is used to send the first data to the client.
[0141] In a possible embodiment, the read-write module 350 is specifically used for:
[0142] In the case of detecting response failure information generated by a data storage bucket, re-determining a data storage bucket from at least one data storage bucket; the response failure information is used to indicate a data write failure;
[0143] The first data is written into the re-determined data storage bucket.
[0144] In a possible embodiment, the data reading and writing device 300 may further include:
[0145] The storage module is used to store at least one mapping relationship, each mapping relationship is used to indicate the relationship between a logical storage bucket and at least one data storage bucket.
[0146] The data reading and writing method provided by the embodiment of the present invention receives a first request message sent by a client, the first request message includes a first identifier, the first request message is used to request to read or write the first data, and the first identifier is used to indicate a logical storage bucket; determines at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier; in response to the first request message, determines a first weight value of each data storage bucket at the current moment; the first weight value is proportional to the number of times the data storage bucket generates storage response information, the storage response information is generated when the data storage bucket successfully stores data, the more times the data storage bucket generates storage response information, the larger the first weight value of the data storage bucket is, that is, the first weight value can characterize the availability of the data storage bucket, and according to the first weight value, determines at least one data storage bucket that meets the first condition from at least one data storage bucket as a target storage bucket, here, a data storage bucket with high availability can be quickly and accurately determined as the target storage bucket; finally, reading the first data from the target storage bucket or writing the first data to the target storage bucket can improve the efficiency and success rate of data reading and writing.
[0147] The embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it includes a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.
[0148] Memory 403, used for storing computer programs;
[0149] The processor 401 is used to execute the program stored in the memory 403 to implement the following steps:
[0150] Receive a first request message sent by a client, the first request message includes a first identifier, the first request message is used to request to read or write first data, and the first identifier is used to indicate a logical storage bucket; determine at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier; in response to the first request message, determine a first weight value of each data storage bucket at the current moment; the first weight value is proportional to the number of times the data storage bucket generates storage response information; according to the first weight value, determine at least one data storage bucket that meets the first condition from at least one data storage bucket as a target storage bucket; read the first data from the target storage bucket or write the first data to the target storage bucket.
[0151] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0152] The communication interface is used for communication between the above terminal and other devices.
[0153] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0154] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0155] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions. When the computer-readable storage medium is executed on a computer, the computer executes the data reading and writing method described in any one of the above embodiments.
[0156] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the data reading and writing method described in any one of the above embodiments.
[0157] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0158] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0159] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0160] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A data reading and writing method, characterized in that: The method comprises: Receive first request information sent by a client, where the first request information includes a first identifier, the first request information is used to request to read or write first data, and the first identifier is used to indicate a logical storage bucket; Determine at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier; In response to the first request information, determining a first weight value of each of the data storage buckets at a current moment; the first weight value is proportional to the number of times the data storage bucket generates storage response information; According to the first weight value, determining at least one data storage bucket satisfying a first condition from the at least one data storage bucket as a target storage bucket; The first data is read from the target storage bucket or the first data is written into the target storage bucket.
2. The method according to claim 1, characterized in that Determining, in response to the first request information, a first weight value of each of the data storage buckets at a current moment includes: In response to the first request information, for each of the data storage buckets, determine a first number of request information received by the data storage bucket in the N-1th unit time, a second number of response failure information generated by the data storage bucket in the N-1th unit time, and a second weight value in the N-1th unit time; N is an integer greater than 1; the response failure information is used to indicate a data storage failure or a data acquisition failure; and the current moment is within the Nth unit time; The first weight value is determined according to the first number, the second number, and the second weight value.
3. The method according to claim 1, characterized in that The step of determining, according to the first weight value, at least one data storage bucket that satisfies a first condition from the at least one data storage bucket comprises: Acquire configuration information corresponding to the first identifier, where the configuration information includes a third number of data storage buckets required by the client; The third number of data storage buckets satisfying the first condition are determined from the at least one data storage bucket according to the first weight value.
4. The method according to claim 3, characterized in that: The step of determining the third number of data storage buckets satisfying the first condition from the at least one data storage bucket according to the first weight value includes: After sorting the first weight values in descending order, first N first weight values are determined, where N is a positive integer; Determine, from the at least one data storage bucket, data storage buckets corresponding to the first N first weight values; The third number of data storage buckets is determined from the data storage buckets corresponding to the first N first weight values.
5. The method according to claim 1, characterized in that: The first request information is used to request to read the first data. After reading the first data from the data storage bucket or writing the first data into the target storage bucket, the method further includes: The first data is sent to the client.
6. The method according to claim 1, characterized in that The reading the first data from the target storage bucket or writing the first data into the target storage bucket includes: In the case of detecting response failure information generated by the data storage bucket, re-determining a data storage bucket from the at least one data storage bucket; the response failure information is used to indicate data writing failure; The first data is written into the re-determined data storage bucket.
7. The method according to claim 1, characterized in that Before determining at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier, the method further includes: At least one mapping relationship is stored, each of the mapping relationships being used to indicate a relationship between the logical storage bucket and at least one of the data storage buckets.
8. A data reading and writing device, characterized in that: The device comprises: A receiving module, configured to receive first request information sent by a client, wherein the first request information includes a first identifier, the first request information is used to request to read or write the first data, and the first identifier is used to indicate a logical storage bucket; A first determining module, configured to determine at least one data storage bucket having a mapping relationship with the logical storage bucket indicated by the first identifier; A second determination module is used to determine a first weight value of each of the data storage buckets at a current moment in response to the first request information; the first weight value is proportional to the number of times the data storage bucket generates storage response information; A third determining module, configured to determine, according to the first weight value, at least one data storage bucket satisfying a first condition from the at least one data storage bucket as a target storage bucket; A read / write module is used to read the first data from the target storage bucket or write the first data into the target storage bucket.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
