A data processing method and device, electronic equipment and storage medium

By combining an in-memory database with a relational database using a sharding mechanism, the problem of excessively long processing time in traditional inventory systems under high concurrency requests is solved. This achieves inventory accuracy and stability under high concurrency, and is suitable for high-concurrency processing of low-value virtual items and data consistency of high-value virtual items.

CN116955494BActive Publication Date: 2026-02-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210393525.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-14
Publication Date
2026-02-27
Estimated Expiration
2042-04-14

AI Technical Summary

Technical Problem

Existing inventory systems based on traditional relational databases experience excessively long processing times when handling high-concurrency requests, making them unable to support high-concurrency scenarios.

Method used

An inventory database architecture combining an in-memory database and a relational database based on a sharding mechanism is adopted. The in-memory database is used to store inventory information of low-value virtual items, while the relational database is used to store inventory information of high-value virtual items. Virtual item acquisition requests are handled through a consistent hashing algorithm and a primary/backup storage node design.

Benefits of technology

While ensuring inventory accuracy, it supports service stability and processing efficiency under high concurrency, improves the concurrent processing capability for low-value virtual items, and ensures data consistency for high-value virtual items through a database sharding and table partitioning mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116955494B_ABST
    Figure CN116955494B_ABST
Patent Text Reader

Abstract

The application discloses a data processing method and device, electronic equipment and storage medium, and the method comprises the following steps: obtaining a virtual object acquisition request for a target virtual object in a target service scenario; determining a target inventory database from a preset inventory database based on a target virtual resource quantity corresponding to the target virtual object; the preset inventory database comprises an in-memory database and a relational database based on a split-database and split-table mechanism, the in-memory database is used for storing inventory information corresponding to virtual objects with virtual resource quantities less than a preset virtual resource quantity, and the relational database is used for storing inventory information corresponding to virtual objects with virtual resource quantities not less than the preset virtual resource quantity; determining a service key value based on a service scenario identifier and a service identifier; determining a target storage node matched with the service key value in a storage node included in the target inventory database, and processing the request based on inventory information in the target storage node. The application can ensure inventory accuracy while supporting high concurrency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a data processing method and device, electronic equipment and storage medium. BACKGROUND

[0002] With the development of Internet technology, the user installs more and more application programs in the terminal, and many application programs launch virtual item distribution activities of different business scenarios, such as killing activities, lucky draw activities and the like, in order to improve the user activity and the user's cognition of product ability.

[0003] The inventory system in the related art is usually based on a traditional relational database to ensure the accuracy of the inventory, but when processing the request in the above-mentioned activities, the traditional relational database uses row locks, table locks and the like, which greatly increases the processing time of the request, so that the inventory system in the related art cannot support high concurrency. SUMMARY

[0004] In order to solve the problems of the prior art, the embodiments of the present application provide a data processing method and device, electronic equipment and storage medium. The technical solution is as follows:

[0005] In one aspect, a data processing method is provided, the method comprising:

[0006] Obtaining a virtual item obtaining request for a target virtual item in a target business scenario; the virtual item obtaining request comprises a business scenario identifier of the target business scenario and a business identifier of a distribution business to which the target virtual item belongs, and the distribution business is a business in at least one virtual item distribution business corresponding to the target business scenario;

[0007] Determining a target inventory database from a preset inventory database based on a target virtual resource amount corresponding to the target virtual item; the preset inventory database comprises an in-memory database and a relational database based on a sharding mechanism, the in-memory database is used to store inventory information corresponding to a virtual item with a virtual resource amount less than a preset virtual resource amount, and the relational database is used to store inventory information corresponding to a virtual item with a virtual resource amount not less than the preset virtual resource amount;

[0008] Determining a business key value corresponding to the virtual item obtaining request based on the business scenario identifier and the business identifier;

[0009] Determining a target storage node in a storage node included in the target inventory database that matches the business key value, and processing the virtual item obtaining request based on the inventory information in the target storage node.

[0010] In another aspect, a data processing apparatus is provided, the apparatus comprising:

[0011] A request acquisition module is configured to acquire a virtual item acquisition request for a target virtual item in a target business scenario; the virtual item acquisition request comprises a business scenario identifier of the target business scenario and a business identifier of a distribution business to which the target virtual item belongs, the distribution business being a business in at least one virtual item distribution business corresponding to the target business scenario;

[0012] A target database determination module is configured to determine a target inventory database from a preset inventory database based on a target virtual resource amount corresponding to the target virtual item; the preset inventory database comprises an in-memory database and a relational database based on a sharding mechanism, the in-memory database being configured to store inventory information corresponding to a virtual item with a virtual resource amount less than a preset virtual resource amount, and the relational database being configured to store inventory information corresponding to a virtual item with a virtual resource amount not less than the preset virtual resource amount;

[0013] A business key value determination module is configured to determine a business key value corresponding to the virtual item acquisition request based on the business scenario identifier and the business identifier;

[0014] A storage node determination module is configured to determine a target storage node in storage nodes included in the target inventory database and matching the business key value, and process the virtual item acquisition request based on inventory information in the target storage node.

[0015] In an exemplary embodiment, the target database determination module comprises:

[0016] A first target database determination module is configured to determine the in-memory database as the target inventory database when the target virtual resource amount corresponding to the target virtual item is less than the preset virtual resource amount;

[0017] A second target database determination module is configured to determine the relational database based on the sharding mechanism as the target inventory database when the target virtual resource amount corresponding to the target virtual item is greater than or equal to the preset virtual resource amount.

[0018] In an exemplary embodiment, the storage node determination module comprises:

[0019] A request type determination module is configured to determine a request type of the virtual item acquisition request;

[0020] The first storage node determination module is configured to determine a target backup storage node matching the business key value from backup storage nodes included in the target inventory database when the request type is a read data request, and process the virtual item acquisition request based on inventory information in the target backup storage node.

[0021] The second storage node determination module is configured to determine a target primary storage node matching the business key value from primary storage nodes included in the target inventory database when the request type is a write data request, and process the virtual item acquisition request based on inventory information in the target primary storage node.

[0022] In an exemplary embodiment, when the target inventory database is a memory database, the memory database is a single-threaded mode memory database; and the second storage node determination module includes:

[0023] The request identifier determination module is configured to determine a request identifier corresponding to the virtual item acquisition request.

[0024] The inventory update instruction determination module is configured to generate an inventory update instruction based on an acquisition quantity in the virtual item acquisition request; the inventory update instruction indicates querying a current inventory quantity of the target virtual item in the inventory information, and updating the inventory information when the queried current inventory quantity is greater than or equal to the acquisition quantity.

[0025] The searching module is configured to search for a lock corresponding to the request identifier in a lock set.

[0026] The update processing module is configured to update the inventory information in the target primary storage node based on the inventory update instruction when the searching module does not find the lock.

[0027] In an exemplary embodiment, the apparatus further includes:

[0028] The lock generation module is configured to generate a lock corresponding to the request identifier based on the request identifier.

[0029] The lock storage module is configured to store the lock corresponding to the request identifier in the lock set.

[0030] In an exemplary embodiment, the second storage node determination module includes:

[0031] The scenario expiration determination module is configured to determine scenario expiration time information corresponding to the target business scenario.

[0032] The request processing module is configured to, in a case where it is determined based on the scenario expiration time information that the target service scenario is not expired, process the virtual item acquisition request based on inventory information in the target master storage node.

[0033] In one example embodiment, the second storage node determination module further comprises:

[0034] The scenario end time acquisition module is configured to, in a case where it is determined based on the scenario expiration time information that the target service scenario is expired, acquire an end time of the target service scenario.

[0035] The time information random selection module is configured to randomly select target time information from a preset time range.

[0036] The service expiration time determination module is configured to obtain service expiration time information based on a sum of the end time and the target time information.

[0037] The service expiration time setting module is configured to set an expiration time of inventory information in the target storage node according to the service expiration time information.

[0038] In one example embodiment, the apparatus further comprises:

[0039] The abnormality degree determination module is configured to determine an abnormality degree of a requester corresponding to the virtual item acquisition request.

[0040] The request interception module is configured to, in a case where the abnormality degree exceeds a preset abnormality degree, intercept the virtual item acquisition request.

[0041] In another aspect, an electronic device is provided, comprising a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the above-mentioned data processing method.

[0042] In another aspect, a computer-readable storage medium is provided, the computer-readable storage medium storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by a processor to implement the above-mentioned data processing method.

[0043] In another aspect, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the above-mentioned data processing method.

[0044] The embodiment of the present application sets the preset inventory database to include an in-memory database and a relational database based on a split-database and split-table mechanism, and the in-memory database is used to store inventory information corresponding to virtual items with virtual resource amounts less than a preset virtual resource amount, and the relational database is used to store inventory information corresponding to virtual items with virtual resource amounts not less than the preset virtual resource amount, so that when a virtual item obtaining request for a target virtual item under a target business scenario is obtained, a target inventory database is determined from the preset inventory database based on a target virtual resource amount corresponding to the target virtual item, a business key value corresponding to the virtual item obtaining request is determined based on a business scenario identifier and a business identifier, a target storage node in a storage node included in the target inventory database that matches the business key value is determined, and the virtual item obtaining request is processed based on inventory information in the target storage node, so that inventory accuracy is ensured while supporting service stability under a high concurrency scenario. BRIEF DESCRIPTION OF DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort based on these drawings.

[0046] Figure 1 is a schematic diagram of an implementation environment provided by the embodiment of the present application;

[0047] Figure 2a is a schematic diagram of a primary and backup storage mode of a storage node provided by the embodiment of the present application;

[0048] Figure 2b is a schematic diagram of a system architecture for data processing provided by the embodiment of the present application;

[0049] Figure 3 is a flowchart of a data processing method provided by the embodiment of the present application;

[0050] Figure 4 is a flowchart of another data processing method provided by the embodiment of the present application;

[0051] Figure 5a is a schematic diagram of a front-end display interface provided by the embodiment of the present application;

[0052] Figure 5b is a flowchart of another data processing method provided by the embodiment of the present application;

[0053] Figure 6 is a flowchart of another data processing method provided by the embodiment of the present application;

[0054] Figure 7 is a flowchart of another data processing method provided by an embodiment of the present application;

[0055] Figure 8 is a flowchart of another data processing method provided by an embodiment of the present application;

[0056] Figure 9 is a structural block diagram of a data processing device provided by an embodiment of the present application;

[0057] Figure 10 is a hardware structural block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0058] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.

[0059] It should be noted that the terms "first", "second", and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or server including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to the process, method, product, or device.

[0060] It can be understood that in the specific embodiments of the present application, data related to user information and the like is involved, and when the above embodiments of the present application are applied to specific products or technologies, user permission or consent needs to be obtained, and the collection, use, and processing of related data need to comply with relevant laws, regulations, and standards of relevant countries and regions.

[0061] The embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, intelligent transportation, and assisted driving.

[0062] Among them, cloud technology refers to the series of resources such as hardware, software, network, etc. in the wide area network or local area network, to realize the calculation, storage, processing and sharing of data. Cloud technology (Cloud technology) is based on the network technology, information technology, integration technology, management platform technology, application technology and other applications of cloud computing business model, which can form a resource pool, and can be used as needed. Cloud computing technology will become an important support. The background service of the technical network system needs a lot of computing and storage resources, such as video websites, picture websites and more portals. With the high development and application of Internet industry, every item may have its own identification mark in the future, which needs to be transmitted to the background system for logical processing. Different levels of data will be processed separately, and various industry data will need strong system support, which can only be realized through cloud computing.

[0063] Cloud storage is a new concept extended and developed on the basis of cloud computing concept. Distributed cloud storage system (hereinafter referred to as storage system) refers to the application of cluster, grid technology and distributed storage file system to collect and work together a large number of storage devices (storage devices are also called storage nodes) in the network to provide data storage and business access functions. At present, the storage method of the storage system is: creating a logical volume, and allocating physical storage space to each logical volume when creating the logical volume. The physical storage space may be a disk composed of a certain storage device or several storage devices. The client stores data on a certain logical volume, that is, stores data on the file system. The file system divides the data into many parts, each part is an object, and the object contains not only data but also additional information such as data ID (ID entity). The file system writes each object to the physical storage space of the logical volume, and records the storage location information of each object, so that the file system can access the data according to the storage location information of each object when the client requests to access the data. The process of allocating physical storage space to the logical volume by the storage system is as follows: according to the capacity estimation of the object stored in the logical volume (the estimation often has a large margin compared with the actual capacity of the object to be stored) and the group of redundant array of independent disk (RAID), the physical storage space is divided into strips in advance. A logical volume can be understood as a strip, so the logical volume is allocated with physical storage space.

[0064] Database, in short, can be regarded as an electronic file cabinet - a place to store electronic files, users can add, query, update, delete and other operations on the data in the file. So-called "database" is a collection of data stored together in a certain way, can be shared by multiple users, with as little redundancy as possible, independent of each other with the application program.

[0065] Database Management System (DBMS for short) is a computer software system designed to manage databases, generally with storage, interception, security, backup and other basic functions. Database management systems can be classified according to the database model they support, such as relational, XML (Extensible Markup Language); or according to the type of computer they support, such as server clusters, mobile phones; or according to the query language used, such as SQL (Structured Query Language), XQuery; or according to the performance focus, such as maximum size, highest speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories, such as supporting multiple query languages at the same time.

[0066] Please refer to Figure 1 , which shows an implementation environment provided by an embodiment of the application, which can include a terminal 110, a data processing server 120 and a preset inventory database 130. The terminal 110 and the data processing server 120, and the data processing server 120 and the preset inventory database 130 can be connected and communicated through a network.

[0067] Among them, the terminal 110 includes but is not limited to mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The terminal 110 runs an application program with human-computer interaction function, which can launch virtual item distribution activities in different business scenarios, such as flash sale activities, lottery activities, task completion and reward activities, etc.

[0068] The data processing server 120 can provide background service for the application program in the terminal 110. Specifically, the service can include inventory service, which can obtain the virtual item acquisition request for the target virtual item in the target business scenario sent by the terminal 110, and then respond to the virtual item acquisition request in combination with the preset inventory database 130 to process the virtual item acquisition request, and return the processing result to the terminal 110.

[0069] The preset inventory database 130 includes an in-memory database 131 and a relational database 132 based on a sharding mechanism. The in-memory database 131 stores inventory information for virtual items with virtual resource quantities less than the preset virtual resource quantity, while the relational database 132 stores inventory information for virtual items with virtual resource quantities not less than the preset virtual resource quantity. In other words, the in-memory database 131 stores inventory information for low-value virtual items, and the relational database 132 stores inventory information for high-value virtual items. For example, the in-memory database 131 could be a Redis database, capable of handling hundreds of thousands of concurrent requests.

[0070] A relational database based on sharding and partitioning is a distributed database deployed in the cloud that is compatible with the MySQL protocol and syntax and supports automatic horizontal partitioning. In this distributed database, each logical table is split into multiple sub-tables, and each sub-table is a real physical table distributed across a specific partition in MySQL. Relational databases based on sharding and partitioning can achieve financial-grade high data consistency.

[0071] Both the in-memory database 131 and the relational database 132 based on a sharding mechanism can include multiple storage nodes, each with a corresponding node number. Different storage nodes have different node numbers, which can be used for request routing. In an exemplary implementation, such as... Figure 2a As shown, each storage node can include a primary storage node and a standby storage node. Data synchronization is achieved between the primary and standby storage nodes. Under normal circumstances, the primary storage node handles the data. When the primary storage node encounters a problem (such as network interruption or crash), the standby storage node takes over. This primary-standby storage mode can improve system availability and achieve fault self-healing. Furthermore, the inventory service can use a consistent hashing algorithm for request routing, which will be described in detail later in this embodiment.

[0072] In one specific implementation, such as Figure 2bAs shown is a system architecture schematic diagram provided by an embodiment of the application for data processing, which can include an access layer, a logic layer and a storage layer. The access layer directly interacts with a terminal through a common gateway interface (CGI). The logic layer includes an inventory system for implementing data processing and other dependent systems. The inventory system can include inventory services, risk control services and reconciliation services. Other dependent services can include shipping services, redemption services, lottery services, task services, general probability and message integration. It can be understood that other dependent systems can also include other required services. The storage layer includes a Redis database and a relational database (Midatabase) based on a sharding mechanism.

[0073] It should be noted that the server, database, node and the like of the embodiment of the application can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms.

[0074] In an exemplary embodiment, the terminal 110, the data processing server 120 and the preset inventory database 130 can be node devices in a blockchain system, capable of sharing the acquired and generated information to other node devices in the blockchain system, realizing information sharing between multiple node devices. The multiple node devices in the blockchain system can be configured with the same blockchain, which is composed of multiple blocks, and the adjacent blocks have an association relationship, so that when the data in any block is tampered with, it can be detected through the next block, thereby avoiding the data in the blockchain from being tampered with, and ensuring the security and reliability of the data in the blockchain.

[0075] Please refer to Figure 3 As shown is a flowchart of a data processing method provided by an embodiment of the application, which can be applied to Figure 1 The execution subject of the method can be Figure 1 the data processing server in It should be noted that the present specification provides method operation steps as described in the embodiments or flowcharts, but more or fewer operation steps can be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one of the many execution orders, and does not represent the only execution order. In actual system or product execution, the method order shown in the embodiments or the drawings can be executed in sequence or in parallel (for example, in a parallel processor or multi-threaded processing environment). Specifically, asFigure 3 As shown, the method can include:

[0076] S301, obtaining a virtual item acquisition request for a target virtual item in a target business scenario.

[0077] The virtual item acquisition request includes a business scenario identifier of the target business scenario and a business identifier of a distribution business to which the target virtual item belongs, and the distribution business is a business in at least one virtual item distribution business corresponding to the target business scenario.

[0078] It should be noted that the virtual item in the embodiment of the application can be electronic money, points, gold beans, gift money coupons, exchange coupons, coupons, gift cards, virtual coins for use only within a certain platform, and can also be game props or diamonds that can be exchanged for game props in a game, and the embodiment of the disclosure does not make specific limitations.

[0079] The business scenario is used to implement virtual item distribution in the form of a theme activity, for example, a flash sale activity, a draw activity, a task completion activity, etc., and each business scenario can correspond to at least one virtual item distribution business. Different virtual item distribution businesses under the same business scenario can be different in terms of rules for distributing virtual items or different virtual items distributed. Taking a flash sale activity as an example, 100 points for 2 yuan A platform shopping card and 1000 points for B platform member card are different virtual item distribution businesses under the same business scenario. The target business scenario is a business scenario displayed by the terminal to the user, for example, the target business scenario can be any one of a flash sale activity, a draw activity, or a task completion activity.

[0080] In a specific implementation, the terminal can display the target business scenario to the user through an interactive interface, and when the terminal determines that the user has participated in the target business scenario, the terminal can send a virtual item acquisition request for the target virtual item in the target business scenario to the background. The virtual item acquisition request carries the business scenario identifier of the target business scenario and the business identifier of the distribution business to which the target virtual item belongs. The business scenario identifier of the target business scenario can uniquely identify the target business scenario, and the business identifier can uniquely identify the virtual item distribution business.

[0081] The terminal determines that the user has participated in the target service scenario in a manner and the target virtual item is associated with the specific target service scenario. For example, when the target service scenario is a flash sale activity, if the user issues an order placing instruction for a virtual item in the flash sale activity, the terminal can determine that the user has participated in the target service scenario when the order placing instruction is received, and the target virtual item is the virtual item ordered by the user. When the target service scenario is a draw activity, if the user performs a draw action and generates a draw result, the terminal can determine that the user has participated in the target service scenario when the draw result is received, and the target virtual item is the prize corresponding to the draw result. When the target service scenario is a task completion activity, if the user completes a specified task, the terminal can determine that the user has participated in the target service scenario when a specified task completion instruction is received, and the target virtual item is the prize associated with the specified task.

[0082] In S303, a target inventory database is determined from a preset inventory database based on a target virtual resource amount corresponding to the target virtual item.

[0083] In the embodiment of the application, the virtual resource amount corresponding to the virtual item can represent the value of the virtual item. The greater the virtual resource amount, the higher the value of the corresponding virtual item, and vice versa. The virtual resource amount refers to the quantity of virtual resources used to measure the value of the virtual item. The virtual resource can be an electronic resource different from the virtual item.

[0084] In the embodiment of the application, the virtual items are classified according to their virtual resource amounts. Specifically, virtual items with a virtual resource amount less than a preset virtual resource amount are classified as low-value virtual items, and virtual items with a virtual resource amount greater than or equal to the preset virtual resource amount are classified as high-value virtual items. The preset virtual resource amount can be set according to the actual application of measuring the value of the virtual item.

[0085] In actual applications, more inventories such as usually 100,000 copies are often configured for low-value virtual items, and fewer inventories such as usually only a few hundred copies are configured for high-value virtual items. Therefore, for low-value virtual items, it is usually only necessary to ensure that they are not over-issued, and strict data consistency is not required. However, over-issuing or under-issuing of high-value virtual items can cause serious adverse effects, and strict data consistency is required.

[0086] Based on this, the preset inventory database in the embodiment of the application is configured to include an in-memory database and a relational database based on a sharding mechanism, the in-memory database is used to store inventory information corresponding to virtual items with virtual resource amounts less than a preset virtual resource amount, and the relational database based on the sharding mechanism is used to store inventory information corresponding to virtual items with virtual resource amounts not less than the preset virtual resource amount. The inventory information corresponding to low-value virtual items with virtual resource amounts less than the preset virtual resource amount is stored in the in-memory database to support 100,000-level concurrency, and the inventory information corresponding to high-value virtual items with virtual resource amounts greater than or equal to the preset virtual resource amount is stored in the relational database based on the sharding mechanism to ensure strong consistency of data.

[0087] In a specific implementation, the virtual resource amounts corresponding to the virtual items can be preconfigured, for example, a correspondence between virtual item identifiers and virtual resource amounts is maintained, the virtual item identifier is used to uniquely identify a virtual item, so that after a virtual item request for a target virtual item is obtained, the target virtual item identifier can be extracted from the virtual item acquisition request, and then the target correspondence matching the target virtual item identifier is determined from the correspondence between the virtual item identifier and the virtual resource amount, and the virtual resource amount in the target correspondence is taken as the target virtual resource amount corresponding to the target virtual item.

[0088] Based on this, the determination of the target inventory database from the preset inventory database based on the target virtual resource amount corresponding to the target virtual item can include the following steps as shown in S303. Figure 4

[0089] S401, it is judged whether the target virtual resource amount corresponding to the target virtual item is less than a preset virtual resource amount, and when the result of the judgment is yes, step S403 can be performed; otherwise, when the result of the judgment is no, step S405 can be performed.

[0090] S403, the in-memory database is determined as the target inventory database.

[0091] S405, the relational database based on the sharding mechanism is determined as the target inventory database.

[0092] ​In the above embodiment, the value interval of the target virtual item is determined by comparing the target virtual resource quantity of the target virtual item with the preset virtual resource quantity, and when the value interval is a low value interval (i.e., the target virtual resource quantity is less than the preset virtual resource quantity), the in-memory database is determined as the target inventory database, and when the value interval is a high value interval (i.e., the target virtual resource quantity is greater than or equal to the preset virtual resource quantity), the relational database based on the sharding mechanism is determined as the target inventory database, so that the in-memory database supporting 100,000 concurrent processing capabilities can be used to cope with high-concurrency virtual item acquisition requests for the low value interval, and the strong data consistency capability of the relational database based on the sharding mechanism can be used to ensure the processing accuracy of virtual item acquisition requests for the high value interval.

[0093] In another exemplary embodiment, a corresponding virtual item identifier set can also be maintained for the low value interval and the high value interval, respectively, and when a virtual item request for a target virtual item is acquired, the target virtual item identifier can be extracted from the virtual item acquisition request, and then the target virtual item identifier is searched in the virtual item identifier set corresponding to the low value interval and the virtual item identifier set corresponding to the high value interval, respectively. If the target virtual item identifier is found in the virtual item identifier set corresponding to the low value interval, it indicates that the target virtual resource quantity corresponding to the target virtual item is less than the preset virtual resource quantity, and the in-memory database can be determined as the target inventory database. Conversely, if the target virtual item identifier is found in the virtual item identifier set corresponding to the high value interval, it indicates that the target virtual resource quantity corresponding to the target virtual item is greater than or equal to the preset virtual resource quantity, and the relational database based on the sharding mechanism can be determined as the target inventory database. This embodiment directly determines the size of the target virtual resource quantity corresponding to the target virtual item and the preset virtual resource quantity based on the virtual item identifier sets corresponding to the low value interval and the high value interval, respectively, which can more quickly determine the target inventory database, thereby facilitating the improvement of data processing efficiency.

[0094] It can be understood that the above-mentioned correspondence between the virtual item identifier and the virtual resource quantity, and the virtual item identifier sets corresponding to the low value interval and the high value interval, respectively, can be dynamically adjusted according to actual needs, so that the data processing method of the embodiment of the application has high flexibility.

[0095] S305, determining a business key value corresponding to the virtual item acquisition request based on the business scenario identifier and the business identifier.

[0096] In a specific implementation, the business key value can be calculated by using a consistent hash algorithm, wherein the business scenario identifier can be a business scenario ID (Identity, identity identifier), and the business identifier can be a business ID. When calculating the business key value, the business scenario ID and the business ID are added together, and then a hash value of the sum is calculated, so that the business key value can be mapped to a fixed-length output, i.e., the business key value is obtained.

[0097] S307, determining a target storage node in the storage nodes included in the target inventory database that matches the business key value, and processing the virtual item acquisition request based on inventory information in the target storage node.

[0098] The target storage node that matches the business key value can be a storage node whose node number is consistent with the business key value.

[0099] Considering that a business scenario often has multiple virtual item distribution businesses, a single storage node can not be able to load the requests of the entire business scenario, therefore, in the embodiment of the application, the preset inventory database is deployed with multiple storage nodes in a master-backup manner, for different virtual item distribution businesses, a hash algorithm is used to map them to corresponding storage nodes, and the requests are distributed, so as to realize high concurrency.

[0100] Since the concurrent processing performance of the in-memory database is much higher than that of the traditional relational database, if the in-memory database master node is down, theoretically, only 10 ms of data is lost, which is acceptable for low-value virtual items. However, for high-value virtual items, the loss caused by downtime is unacceptable, therefore, the relational database based on the database table splitting mechanism can use the transaction, lock and other characteristics of the database to ensure the strong consistency of the data, meet the needs of high-value virtual item distribution businesses, and thus ensure the accuracy of the inventory while supporting high concurrency.

[0101] In an exemplary embodiment, considering that not all requests need to update inventory information, sometimes only the front-end display needs to read the inventory quantity, such as Figure 5a As shown in FIG. 7, it is a schematic diagram of a front-end display interface, wherein a flash sale activity is involved, and when displaying the interface, the front-end needs to read the inventory quantity of each virtual item distribution business under the flash sale activity and the inventory quantity of the virtual items corresponding to each virtual item distribution business for display. In order to further improve the concurrent processing performance, the above step S307 can include the following steps when implemented, as shown in Figure 5b

[0102] S501, determining the request type of the virtual item acquisition request;

[0103] ​Specifically, the request type of the virtual item obtaining request includes a read data request and a write data request. The read data request only performs a read operation on the database, and the write data request performs a write operation on the database.

[0104] S503, when the request type is the read data request, determining a target backup storage node matching the business key value from backup storage nodes included in the target inventory database, and processing the virtual item obtaining request based on inventory information in the target backup storage node.

[0105] S505, when the request type is the write data request, determining a target master storage node matching the business key value from master storage nodes included in the target inventory database, and processing the virtual item obtaining request based on inventory information in the target master storage node.

[0106] Taking the target inventory database as a memory database such as a Redis database as an example, when the virtual item obtaining request is determined to be a read data request, a target backup Redis node matching the business key value can be determined from backup Redis nodes of the Redis database, and then the virtual item obtaining request is processed based on inventory information in the target backup Redis node; when the virtual item obtaining request is determined to be a write data request, a target master Redis node matching the business key value can be determined from master Redis nodes of the Redis database, and then the virtual item obtaining request is processed based on inventory information in the target master Redis node. Through the above method, the read data request can be diverted to the backup storage node, reducing the pressure on the master storage node and improving the system concurrency.

[0107] In an exemplary embodiment, when the target inventory database is a memory database, in order to support high concurrency while further improving the accuracy of data processing, a single-threaded mode memory database such as a Redis database is used to store the corresponding inventory information for low-value virtual items. Based on this, the above step S505 can include the following steps when implemented: Figure 6

[0108] S601, when the request type is the write data request, determining a target master storage node matching the business key value from master storage nodes included in the single-threaded mode memory database;

[0109] S603, determining a request identifier corresponding to the virtual item obtaining request.

[0110] The request identifier is used to uniquely identify a virtual item obtaining request.

[0111] ​S605, generate an inventory update instruction based on the acquisition quantity in the virtual item acquisition request.

[0112] The acquisition quantity refers to the quantity of the target virtual item that needs to be acquired, and the inventory update instruction indicates the current inventory quantity of the target virtual item in the queried inventory information, and the inventory information is updated when the queried current inventory quantity is greater than or equal to the acquisition quantity. The inventory update instruction makes the query and update atomic, that is, there is no intermediate state of the request between the query and the update.

[0113] S607, find the lock corresponding to the request identifier in the lock set.

[0114] Specifically, the lock in the lock set is a lock corresponding to the historical write data request generated after the historical write data request is processed, and the lock in the lock set can be named by the request identifier corresponding to the historical write data request, so that it can be found whether there is a lock named by the current request identifier in the lock set. If not, it means that the lock corresponding to the current request identifier is not found, and step S609 can be executed at this time.

[0115] On the contrary, if there is a lock named by the current request identifier in the lock set, it means that the lock corresponding to the current request identifier is found, which means that the virtual item acquisition request corresponding to the current request identifier has been processed, which is a repeated request. At this time, the virtual item acquisition request can not be processed, which ensures that it is not over-issued or under-issued.

[0116] S609, update the inventory information in the target master storage node based on the inventory update instruction.

[0117] Specifically, in response to the inventory update instruction, the current inventory quantity of the target virtual item is queried based on the inventory information in the target master storage node, and the inventory information is updated when the current inventory quantity is greater than or equal to the acquisition quantity. The update includes reducing the current inventory quantity by the acquisition quantity. Since the inventory update instruction executes the query and update in one instruction to ensure atomicity and is in single-thread mode, the over-issuing situation caused by the query and update in two instructions in the related art is avoided, and the accuracy of data processing is improved.

[0118] In an exemplary embodiment, continuing to refer to Figure 6 After updating the inventory information in the target master storage node based on the inventory update instruction, the method can further include:

[0119] S611, generate a lock corresponding to the request identifier based on the request identifier;

[0120] S613, latch corresponding to the request identification is stored in the lock set.

[0121] In the above embodiment, after updating the inventory information in the target master storage node based on the inventory update instruction, the lock corresponding to the current request identification is generated in time and stored in the lock set, avoiding the repeated processing of the same virtual item acquisition request, and ensuring that the number of issues is not exceeded or the number of issues is not reduced.

[0122] In another exemplary embodiment, in order to ensure service stability, the above step S505 can include, when implemented, as shown in Figure 7

[0123] S701, when the request type is a write data request, determining a target master storage node matching the business key value from the master storage node included in the target inventory database.

[0124] S703, determining the scene expiration time information corresponding to the target business scene.

[0125] The scene expiration time information indicates the time when the target business scene expires. In a specific implementation, the scene expiration time information can be used as attribute information of the target business scene corresponding key value, so that the scene expiration time information can be obtained by querying the attribute information of the target business scene corresponding key value when writing inventory.

[0126] S705, judging whether the target business scene is expired based on the scene expiration time information.

[0127] Specifically, the scene expiration time information can be compared with the current system time. If the current system time exceeds the scene expiration time information, it can be determined that the target business scene has expired, and steps S709 to S715 can be executed. Otherwise, if the current system time does not exceed the scene expiration time information, it can be determined that the target business scene has not expired, and step S707 can be executed.

[0128] For example, the scene expiration time information is 2022-1-20 07:00:00, and the current system time is 2022-1-2007:00:05, then it can be determined that the target business scene has expired. Otherwise, if the current system time is 2022-1-2006:59:55, it can be determined that the target business scene has not expired.

[0129] S707, in the case where it is determined that the target business scene has not expired based on the scene expiration time information, processing the virtual item acquisition request based on the inventory information in the target master storage node.

[0130] ​S709, in the case where it is determined that the target service scenario is expired based on the scenario expiration time information, obtaining an end time of the target service scenario.

[0131] Taking the scenario expiration time information 2022-1-20 07:00:00 as an example, the end time of the target service scenario is 2022-1-20 07:00:00.

[0132] S711, randomly selecting target time information within a preset time range.

[0133] The preset time range can be set according to actual needs, for example, the preset time range is [0, 30] minutes, and a number within the range [0, 30] minutes can be randomly selected as the target time information.

[0134] S713, obtaining service expiration time information based on the sum of the end time and the target time information.

[0135] Suppose the target time information is 1 minute and the end time is 2022-1-20 07:00:00, then the service expiration time information can be obtained as 2022-1-20 07:01:00.

[0136] S715, setting the expiration time of the inventory information in the target storage node according to the service expiration time information.

[0137] Specifically, the expiration time of the inventory information in the target storage node is set to the service expiration time information, so that when the service expiration time information is reached, the inventory information in the target storage node can be automatically cleared.

[0138] In the above embodiment, when writing inventory, it is first determined whether the target service scenario is expired, and if it is expired, the corresponding inventory information is not written. At the same time, the expiration time of the inventory information in the target storage node is set to the end time of the target service scenario plus a random value within a preset time range, so that CPU (Central Processing Unit, CPU) rise caused by all data corresponding to the target service scenario expiring at the same time point can be avoided, and service stability is ensured.

[0139] In order to improve the security of data in each storage node, in an exemplary embodiment, after obtaining the virtual item acquisition request for the target virtual item under the target service scenario, the method can further include:

[0140] Determining the abnormality degree of the requestor corresponding to the virtual item acquisition request;

[0141] In the case where the abnormality degree exceeds a preset abnormality degree, intercepting the virtual item acquisition request.

[0142] Specifically, the abnormality degree of the virtual item obtaining request corresponding to the requestor can be represented by the number of requests of the requestor in a preset time period, and correspondingly, the preset abnormality degree can be represented by a preset number of requests in the preset time period. If the number of requests of the requestor in the preset time period exceeds the preset number of requests, it indicates that the requestor is an abnormal requestor, and the virtual item obtaining request of the abnormal requestor is intercepted; otherwise, if the number of requests of the requestor in the preset time period does not exceed the preset number of requests, it indicates that the requestor is a normal requestor, and the virtual item obtaining request can be responded to, and the target inventory database is determined from the preset inventory database based on the target virtual resource amount corresponding to the target virtual item.

[0143] In an exemplary embodiment, in order to avoid malicious tampering of data in each storage node by the non-virtual item issuing business corresponding business party, the data processing method of the embodiment of the application can further include:

[0144] In response to the invocation request of the business party, the business party is verified.

[0145] When the verification is passed, the invocation of the invocation request is allowed.

[0146] Specifically, the token information carried in the invocation request can be parsed, and then it is determined whether the token information is stored token information. If not found, it indicates that the business party is an unauthorized business party, and the invocation of the service by the business party is not allowed; if found, it indicates that the business party is an authorized business party, and the invocation of the service by the business party is allowed.

[0147] In an exemplary embodiment, the business identifier of the virtual item issuing business and the request identifier of the virtual item obtaining request in the embodiment of the application can be determined according to the preset identifier of the business party to improve the universality of the embodiment of the application.

[0148] In order to more clearly illustrate the technical solutions of the embodiments of the application, the following will be combined with Figure 8 Taking the in-memory database as a Redis database and the relational database based on the sharding mechanism as a Midas database as an example, specifically:

[0149] The inventory service determines, for a virtual item acquisition request, whether a virtual item targeted by the virtual item acquisition request is a low-value virtual item, and if so, determines a corresponding storage node in a Redis database according to a key value, and then performs atomic processing on the request to obtain an inventory update instruction, and sends the inventory update instruction to the storage node for inventory update processing, wherein the atomic processing can use a Lua script containing atomic processing logic; if it is a high-value virtual item, a corresponding storage partition is determined in a Midas database according to the key value, and then a strong consistency calculation is performed using the transaction feature of the Midas database to perform inventory update processing on the storage partition. The key value is obtained by consistent hash calculation according to {business scenario ID: business ID}.

[0150] Corresponding to the data processing method provided by the above-mentioned embodiments, the embodiment of the present application also provides a data processing device. Since the data processing device provided by the embodiment of the present application corresponds to the data processing method provided by the above-mentioned embodiments, the implementation of the foregoing data processing method is also applicable to the data processing device provided by the present embodiment, which will not be described in detail in the present embodiment.

[0151] Please refer to Figure 9 , which shows a structure schematic diagram of a data processing device provided by an embodiment of the present application. The device has the function of implementing the data processing method in the above-mentioned method embodiments. The function can be realized by hardware, or the corresponding software can be executed by hardware. As Figure 9 shown, the data processing device 900 can include:

[0152] The request acquisition module 910 is configured to acquire a virtual item acquisition request for a target virtual item in a target business scenario; the virtual item acquisition request includes a business scenario identifier of the target business scenario and a business identifier of a distribution business to which the target virtual item belongs, and the distribution business is a business in at least one virtual item distribution business corresponding to the target business scenario;

[0153] The target database determination module 920 is configured to determine a target inventory database from a preset inventory database based on a target virtual resource amount corresponding to the target virtual item; the preset inventory database includes an in-memory database and a relational database based on a database-table separation mechanism, the in-memory database is configured to store inventory information corresponding to virtual items with a virtual resource amount less than a preset virtual resource amount, and the relational database is configured to store inventory information corresponding to virtual items with a virtual resource amount not less than the preset virtual resource amount;

[0154] The business key value determination module 930 is configured to determine a business key value corresponding to the virtual item acquisition request based on the business scenario identifier and the business identifier;

[0155] The storage node determination module 940 is configured to determine a target storage node in the storage nodes included in the target inventory database that matches the business key value, and process the virtual item acquisition request based on inventory information in the target storage node.

[0156] In an example embodiment, the target database determination module 920 includes:

[0157] A first target database determination module is configured to determine the memory database as the target inventory database when the target virtual resource amount corresponding to the target virtual item is less than the preset virtual resource amount.

[0158] A second target database determination module is configured to determine the relational database based on the sharding mechanism as the target inventory database when the target virtual resource amount corresponding to the target virtual item is greater than or equal to the preset virtual resource amount.

[0159] In an example embodiment, the storage node determination module 940 includes:

[0160] A request type determination module is configured to determine a request type of the virtual item acquisition request.

[0161] A first storage node determination module is configured to determine a target backup storage node in a backup storage node included in the target inventory database that matches the business key value when the request type is a read data request, and process the virtual item acquisition request based on inventory information in the target backup storage node.

[0162] A second storage node determination module is configured to determine a target primary storage node in a primary storage node included in the target inventory database that matches the business key value when the request type is a write data request, and process the virtual item acquisition request based on inventory information in the target primary storage node.

[0163] In an example embodiment, when the target inventory database is a memory database, the memory database is a single-threaded mode memory database; and the second storage node determination module includes:

[0164] A request identifier determination module is configured to determine a request identifier corresponding to the virtual item acquisition request.

[0165] An inventory update instruction determination module is configured to generate an inventory update instruction based on an acquisition quantity in the virtual item acquisition request; the inventory update instruction indicates querying a current inventory quantity of the target virtual item in the inventory information, and updating the inventory information when the queried current inventory quantity is greater than or equal to the acquisition quantity.

[0166] The searching module is configured to search for a lock corresponding to the request identifier in the lock set.

[0167] The updating processing module is configured to, when the searching module fails to search, update the inventory information in the target master storage node based on the inventory updating instruction.

[0168] In an exemplary embodiment, the apparatus further comprises:

[0169] The lock generating module is configured to generate a lock corresponding to the request identifier based on the request identifier.

[0170] The storing module is configured to store the lock corresponding to the request identifier in the lock set.

[0171] In an exemplary embodiment, the second storage node determining module comprises:

[0172] The scenario expiration determining module is configured to determine scenario expiration time information corresponding to the target business scenario.

[0173] The request processing module is configured to, when it is determined based on the scenario expiration time information that the target business scenario is not expired, process the virtual item acquisition request based on the inventory information in the target master storage node.

[0174] In an exemplary embodiment, the second storage node determining module further comprises:

[0175] The scenario end time obtaining module is configured to, when it is determined based on the scenario expiration time information that the target business scenario is expired, obtain an end time of the target business scenario.

[0176] The time information random selecting module is configured to randomly select target time information from a preset time range.

[0177] The business expiration time determining module is configured to obtain business expiration time information based on a sum of the end time and the target time information.

[0178] The business expiration time setting module is configured to set an expiration time of the inventory information in the target storage node according to the business expiration time information.

[0179] In an exemplary embodiment, the apparatus further comprises:

[0180] The abnormality degree determining module is configured to determine an abnormality degree of a requestor corresponding to the virtual item acquisition request.

[0181] The request interception module is configured to intercept the virtual item acquisition request when the abnormality degree exceeds the preset abnormality degree.

[0182] It should be noted that the apparatus provided in the above embodiments is only used as an example for dividing the above functional modules, and in actual applications, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above-described functions. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be described here.

[0183] The electronic device provided in the embodiment of the present application includes a processor and a memory, and the memory stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the data processing method provided in the above method embodiment.

[0184] The memory can be used to store software programs and modules, and the processor can execute various function applications and data processing by running the software programs and modules stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required by functions, etc.; and the data storage area can store data created according to the use of the device, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device. Accordingly, the memory can also include a memory controller to provide access of the processor to the memory.

[0185] The method embodiments provided in the embodiments of the present application can be executed in a computer terminal, a server or a similar computing device. Taking the case of running on a server as an example, Figure 10 is the hardware structure block diagram of the server running the data processing method provided in the embodiments of the present application, like Figure 10As shown, the server 1000 can vary greatly in configuration and performance, and can include one or more Central Processing Units (CPU) 1010 (processor(s) 1010 can include, but are not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), etc.), a memory 1030 for storing data, one or more storage media 1020 (such as one or more mass storage devices) for storing applications 1023 or data 1022. The memory 1030 and the storage media 1020 can be of any type generally known or used in the art including, but not limited to, static random access memory (SRAM), dynamic random access memory (DRAM), phase change memory (PCM), and non-volatile memory (NVM) such as flash memory or read only memory (ROM). The storage media 1020 can include a storage media 1020 for storing data files, such as image files, and a storage media 1020 for storing applications software. The storage media 1020 for storing applications software can include an operating system 1021, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc. The server 1000 can also include one or more power supplies 1060, one or more wired or wireless network interfaces 1050, one or more input / output interfaces 1040, and / or one or more data input ports 1035.

[0186] The input / output interface 1040 can be configured to receive or transmit data via a network. Examples of the network can include a wireless network provided by a communication provider of the server 1000. In one example, the input / output interface 1040 includes a network interface controller (NIC) that can be connected to other network devices through a base station to communicate with the Internet. In one example, the input / output interface 1040 can be a radio frequency (RF) module that is configured to communicate with the Internet through a wireless manner.

[0187] Those skilled in the art can understand that Figure 10 The structure shown is merely illustrative and does not limit the structure of the electronic device described above. For example, the server 1000 can include more or less components than shown, or have a different configuration of components than shown. Figure 10 The structure shown is merely illustrative and does not limit the structure of the electronic device described above. For example, the server 1000 can include more or less components than shown, or have a different configuration of components than shown. Figure 10 The structure shown is merely illustrative and does not limit the structure of the electronic device described above. For example, the server 1000 can include more or less components than shown, or have a different configuration of components than shown.

[0188] The embodiment of the present application further provides a computer readable storage medium which can be arranged in an electronic device to store at least one instruction or at least one program for implementing a data processing method, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the data processing method provided by the above method embodiment.

[0189] Optionally, in the embodiment, the storage medium can include but is not limited to a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk and various storage program codes.

[0190] It should be noted that the above-mentioned sequence of the embodiments of the present application is only for description, not representing the advantages and disadvantages of the embodiments. The above-mentioned embodiments of the present application are described. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be executed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multi-task processing and parallel processing are possible or can be advantageous.

[0191] Each of the embodiments in the present specification is described in a progressive manner, and the same or similar parts between each embodiment can be referred to each other, and each embodiment mainly describes the difference from other embodiments. Especially, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the related parts can be referred to the part of the method embodiment.

[0192] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by program instructing relevant hardware to complete, and the program can be stored in a computer readable storage medium, and the above-mentioned storage medium can be a read-only memory, a magnetic disk or an optical disk.

[0193] The above-mentioned is only the preferred embodiment of the present application, and is not used to limit the present application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A data processing method, characterized in that, The method includes: Obtain a virtual item acquisition request for a target virtual item within a target business scenario; the virtual item acquisition request includes a business scenario identifier of the target business scenario and a business identifier of the distribution business to which the target virtual item belongs, wherein the distribution business is a business in at least one virtual item distribution business corresponding to the target business scenario; Based on the target virtual resource quantity corresponding to the target virtual item, a target inventory database is determined from a preset inventory database. The preset inventory database includes an in-memory database and a relational database based on a database sharding mechanism. The in-memory database is used to store inventory information corresponding to low-value virtual items whose virtual resource quantity is less than the preset virtual resource quantity. The relational database is used to store inventory information corresponding to high-value virtual items whose virtual resource quantity is not less than the preset virtual resource quantity. The inventory of low-value virtual items is higher than the inventory of high-value virtual items. Based on the business scenario identifier and the business identifier, determine the business key value corresponding to the virtual item acquisition request; Identify the target storage node in the target inventory database that matches the business key value, and process the virtual item acquisition request based on the inventory information in the target storage node; When the target inventory database is an in-memory database, the in-memory database is a single-threaded in-memory database; when the request type of the virtual item acquisition request is a write data request, the target storage node is the target primary storage node of the target inventory database; the processing of the virtual item acquisition request based on the inventory information in the target storage node includes: Determine the request identifier corresponding to the virtual item acquisition request; An inventory update instruction is generated based on the quantity to be acquired in the virtual item acquisition request; the inventory update instruction instructs the query of the current inventory quantity of the target virtual item in the inventory information, and updates the inventory information when the current inventory quantity is greater than or equal to the quantity to be acquired; Find the lock in the lock set that corresponds to the request identifier. The locks in the lock set are generated after the historical write data request is processed and correspond to the corresponding historical write data request. If not found, the inventory information in the target primary storage node is updated based on the inventory update instruction; If found, the virtual item acquisition request will not be processed.

2. The method according to claim 1, characterized in that, The step of determining the target inventory database from the preset inventory database based on the target virtual resource quantity corresponding to the target virtual item includes: When the target virtual resource quantity corresponding to the target virtual item is less than the preset virtual resource quantity, the memory database is determined to be the target inventory database; When the target virtual resource quantity corresponding to the target virtual item is greater than or equal to the preset virtual resource quantity, the relational database based on the database sharding and table partitioning mechanism is determined as the target inventory database.

3. The method according to claim 1, characterized in that, The step of determining the target storage node in the target inventory database that matches the business key value, and processing the virtual item acquisition request based on the inventory information in the target storage node, includes: Determine the request type of the virtual item acquisition request; When the request type is a read data request, a target backup storage node that matches the business key value is determined from the backup storage nodes included in the target inventory database, and the virtual item acquisition request is processed based on the inventory information in the target backup storage node; When the request type is a write data request, a target main storage node matching the business key value is determined from the main storage nodes included in the target inventory database, and the virtual item acquisition request is processed based on the inventory information in the target main storage node.

4. The method according to claim 3, characterized in that, After updating the inventory information in the target primary storage node based on the inventory update instruction, the method further includes: Based on the request identifier, generate a lock corresponding to the request identifier; The lock corresponding to the request identifier is stored in the lock set.

5. The method according to claim 3, characterized in that, The process of processing the virtual item acquisition request based on the inventory information in the target main storage node includes: Determine the scenario expiration time information corresponding to the target business scenario; If it is determined that the target business scenario has not expired based on the scenario expiration time information, the virtual item acquisition request is processed based on the inventory information in the target main storage node.

6. The method according to claim 5, characterized in that, The method further includes: If the target business scenario is determined to have expired based on the scenario expiration time information, the end time of the target business scenario is obtained. Randomly select target time information from a preset time range; Based on the sum of the end time and the target time information, the service expiration time information is obtained; Based on the business expiration time information, set the expiration time of the inventory information in the target storage node.

7. The method according to any one of claims 1 to 6, characterized in that, After obtaining the virtual item acquisition request for the target virtual item in the target business scenario, the method further includes: Determine the degree of abnormality of the requester corresponding to the virtual item acquisition request; If the anomaly level exceeds a preset anomaly level, the request to acquire the virtual item will be blocked.

8. A data processing apparatus, characterized in that, The device includes: The request acquisition module is used to acquire virtual item acquisition requests for a target virtual item under a target business scenario; the virtual item acquisition request includes a business scenario identifier of the target business scenario and a business identifier of the distribution business to which the target virtual item belongs, wherein the distribution business is a business in at least one virtual item distribution business corresponding to the target business scenario; The target database determination module is used to determine the target inventory database from the preset inventory database based on the target virtual resource quantity corresponding to the target virtual item. The preset inventory database includes an in-memory database and a relational database based on a database sharding mechanism. The in-memory database is used to store inventory information corresponding to low-value virtual items whose virtual resource quantity is less than the preset virtual resource quantity. The relational database is used to store inventory information corresponding to high-value virtual items whose virtual resource quantity is not less than the preset virtual resource quantity. The inventory of low-value virtual items is higher than the inventory of high-value virtual items. The business key value determination module is used to determine the business key value corresponding to the virtual item acquisition request based on the business scenario identifier and the business identifier; The storage node determination module is used to determine the target storage node that matches the business key value among the storage nodes included in the target inventory database, and to process the virtual item acquisition request based on the inventory information in the target storage node; When the target inventory database is an in-memory database, the in-memory database is a single-threaded in-memory database; when the request type of the virtual item acquisition request is a write data request, the target storage node is the target primary storage node of the target inventory database; the storage node determination module includes: The request identifier determination module is used to determine the request identifier corresponding to the virtual item acquisition request; The inventory update instruction determination module is used to generate an inventory update instruction based on the acquisition quantity in the virtual item acquisition request; the inventory update instruction instructs to query the current inventory quantity of the target virtual item in the inventory information, and to update the inventory information when the current inventory quantity is greater than or equal to the acquisition quantity; The lookup module is used to find the lock in the lock set that corresponds to the request identifier. The locks in the lock set are generated after the historical write data request is processed and correspond to the corresponding historical write data request. The update processing module is used to update the inventory information in the target main storage node based on the inventory update instruction if the item is not found; if the item is found, the virtual item acquisition request is not processed.

9. The apparatus according to claim 8, characterized in that, The target database determination module includes: The first target database determination module is used to determine the memory database as the target inventory database when the target virtual resource quantity corresponding to the target virtual item is less than the preset virtual resource quantity; The second target database determination module is used to determine the relational database based on the database sharding and table partitioning mechanism as the target inventory database when the target virtual resource quantity corresponding to the target virtual item is greater than or equal to the preset virtual resource quantity.

10. The apparatus according to claim 8, characterized in that, The storage node determination module includes: The request type determination module is used to determine the request type of the virtual item acquisition request; The first storage node determination module is used to determine a target backup storage node that matches the business key value from the backup storage nodes included in the target inventory database when the request type is a read data request, and to process the virtual item acquisition request based on the inventory information in the target backup storage node; The second storage node determination module is used to determine the target main storage node that matches the business key value from the main storage nodes included in the target inventory database when the request type is a write data request, and to process the virtual item acquisition request based on the inventory information in the target main storage node.

11. The apparatus according to claim 10, characterized in that, The device further includes: The lock generation module is used to generate a lock corresponding to the request identifier based on the request identifier after updating the inventory information in the target main storage node based on the inventory update instruction. The lock storage module is used to store the lock corresponding to the request identifier into the lock set.

12. The apparatus according to claim 10, characterized in that, The second storage node determination module includes: The scenario expiration determination module is used to determine the scenario expiration time information corresponding to the target business scenario; The request processing module is used to process the virtual item acquisition request based on the inventory information in the target main storage node, provided that the target business scenario has not expired based on the scenario expiration time information.

13. The apparatus according to claim 12, characterized in that, The second storage node determination module also includes: The scenario end time acquisition module is used to acquire the end time of the target business scenario when it is determined that the target business scenario has expired based on the scenario expiration time information. The time information random selection module is used to randomly select target time information from a preset time range; The service expiration time determination module is used to obtain service expiration time information based on the sum of the end time and the target time information; The business expiration time setting module is used to set the expiration time of the inventory information in the target storage node according to the business expiration time information.

14. The apparatus according to any one of claims 8-13, characterized in that, The device further includes: The anomaly determination module is used to determine the anomaly level of the requester corresponding to the virtual item acquisition request after obtaining the virtual item acquisition request for the target virtual item in the target business scenario. The request interception module is used to intercept the virtual item acquisition request when the anomaly level exceeds a preset anomaly level.

15. An electronic device, characterized in that, The method includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the data processing method as described in any one of claims 1 to 7.

16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction or at least one program, which is loaded and executed by a processor to implement the data processing method as described in any one of claims 1 to 7.

17. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the data processing method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and system for processing Internet user information

    CN107147699A

  • Data request processing method and device applied to high-concurrency scenario

    CN109150929A