CN110909978A - Resource processing method, device, server and computer readable storage medium - Google Patents

Resource processing method, device, server and computer readable storage medium Download PDF

Info

Publication number
CN110909978A
CN110909978A CN201910979230.XA CN201910979230A CN110909978A CN 110909978 A CN110909978 A CN 110909978A CN 201910979230 A CN201910979230 A CN 201910979230A CN 110909978 A CN110909978 A CN 110909978A
Authority
CN
China
Prior art keywords
inventory
preset
stock
commodity identification
commodity
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910979230.XA
Other languages
Chinese (zh)
Inventor
贾晓磊
孙俊
陈琪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
JD Digital Technology Holdings Co Ltd
Original Assignee
JD Digital Technology Holdings Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by JD Digital Technology Holdings Co Ltd filed Critical JD Digital Technology Holdings Co Ltd
Priority to CN201910979230.XA priority Critical patent/CN110909978A/en
Publication of CN110909978A publication Critical patent/CN110909978A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0631Resource planning, allocation, distributing or scheduling for enterprises or organisations
    • G06Q10/06312Adjustment or analysis of established resource schedule, e.g. resource or task levelling, or dynamic rescheduling

Abstract

The invention relates to a resource processing method, a resource processing device, a server and a computer readable storage medium, wherein the method comprises the following steps: receiving an inventory query request, wherein the inventory query request comprises a commodity identifier; inquiring whether the commodity identification is located in an inventory-free set cached locally or not, wherein the inventory-free set comprises the commodity identification of local inventory-free commodities; and if the commodity identification is located in the stock-free set, returning first notification information. According to the embodiment of the invention, the local cached inventory-free set is set, the query request of the local inventory-free commodity can be quickly responded, the response speed is accelerated, the pressure of the redis cluster can be shared by the inventory-free set, and the resources of the redis cluster are saved.

Description

Resource processing method, device, server and computer readable storage medium
Technical Field
The present invention relates to the field of database management, and in particular, to a resource processing method, device, server, and computer-readable storage medium.
Background
There are often some sudden high concurrency scenarios in daily work and life, such as: sales reduction promotion for certain hot items during the shopping segment.
When a certain commodity is clicked and purchased hundreds of thousands, millions or even thousands of times, the inquiry of commodity preferential information (coupon, wane) can form a large demand. In the prior art, each inventory query request is generally concentrated on a redis cluster, however, in the process of implementing the present invention, the inventor finds that the resource of the redis cluster is limited, the response speed will be slow in the face of a large number of query requests, and for the user, the access speed will be slow, and the shopping efficiency will be reduced.
Disclosure of Invention
To solve the technical problem or at least partially solve the technical problem, embodiments of the present invention provide a resource processing method, device, server, and computer-readable storage medium
In a first aspect, an embodiment of the present invention provides a resource processing method, including:
receiving an inventory query request, wherein the inventory query request comprises a commodity identifier;
inquiring whether the commodity identification is located in an inventory-free set cached locally or not, wherein the inventory-free set comprises the commodity identification of local inventory-free commodities;
and if the commodity identification is located in the stock-free set, returning first notification information.
Optionally, each commodity identifier corresponds to a preset main counting field for inventory deduction, the preset main counting field corresponds to a plurality of preset auxiliary counting fields for inventory inquiry, and the inventory in the preset auxiliary counting fields is synchronous with the inventory in the preset main counting field.
Optionally, the method further comprises:
if the commodity identification is not located in the stock-free set, inquiring whether the commodity identification is located in a stock set cached locally or not, wherein the stock set comprises the commodity identification of local stock commodities and local stock corresponding to the commodity identification;
if the commodity identification is located in an inventory set of a local cache and the local inventory corresponding to the commodity identification is greater than 0, deducting the inventory in a preset main counting number field corresponding to the commodity identification;
and if the inventory deduction in the preset main design number field is successful, returning second notification information.
Optionally, if the inventory reduction in the preset main design number field is successful, the method further comprises:
and synchronizing the stock in the preset main counting field after the stock is deducted to the preset auxiliary counting field.
Optionally, the method further comprises:
if the inventory reduction in the preset main design number field fails, returning first notification information;
and deleting the commodity identification and the corresponding local inventory in an inventory set, and adding the commodity identification into the inventory-free set.
Optionally, the method further comprises:
if the commodity identification is not located in the inventory set, determining a target preset sub-counting field in a plurality of preset sub-counting fields corresponding to the commodity identification according to a preset copy distribution strategy;
if the stock quantity is larger than 0 in the target preset secondary counting field, executing a step of deducting the stock quantity in a preset main counting field corresponding to the commodity identification;
synchronizing the inventory in the preset main counting number field after the inventory is deducted to the inventory-free set or the inventory set cached locally.
Optionally, the method further comprises:
acquiring the stock in a preset main counting number field corresponding to the commodity identification;
calculating the product of the inventory and a preset distribution percentage;
and determining the quotient of the product and the number of the hosts in the cluster as the local inventory corresponding to the commodity identification.
Optionally, acquiring the inventory in a preset main counting number field corresponding to the commodity identification;
calculating the quotient of the inventory and the number of hosts in the cluster;
and determining the local inventory corresponding to the commodity identification as a preset fixed quantity, wherein the preset fixed quantity is less than or equal to the quotient.
Optionally, the method further comprises:
allocating a first preset amount of inventory for each host in the cluster, and recording allocation time;
when the stock distribution is to be carried out again, calculating the stock distribution quantity per second of the host;
if the distribution quantity per second is less than or equal to 1, allocating the stock for the host again according to the first preset quantity;
if the distribution quantity per second is larger than 1 and smaller than a preset distribution reference quantity, distributing the stock quantity for the host again according to the distribution quantity per second, wherein the distribution reference quantity is a product obtained by multiplying a quotient of the stock quantity in a preset main counting number section corresponding to the commodity identification and the quantity of the host in the cluster by a preset percentage, and the distribution reference quantity is larger than 1;
and if the distribution quantity per second is larger than the distribution reference quantity, distributing the stock quantity for the host again according to the distribution reference quantity.
In a second aspect, an embodiment of the present invention provides a resource processing apparatus, including:
the receiving module is used for receiving an inventory inquiry request, wherein the inventory inquiry request comprises a commodity identifier;
the first query module is used for querying whether the commodity identification is located in an inventory-free set cached locally, wherein the inventory-free set comprises the commodity identification of local inventory-free commodities;
and the first returning module is used for returning first notification information if the commodity identification is positioned in the stock-free set.
Optionally, each commodity identifier corresponds to a preset main counting field for inventory deduction, the preset main counting field corresponds to a plurality of preset auxiliary counting fields for inventory inquiry, and the inventory in the preset auxiliary counting fields is synchronous with the inventory in the preset main counting field.
Optionally, the apparatus further comprises:
the second query module is used for querying whether the commodity identification is located in an inventory set cached locally or not if the commodity identification is not located in the inventory-free set, wherein the inventory set comprises the commodity identification of local inventory commodities and local inventory corresponding to the commodity identification;
the first stock deduction module is used for deducting the stock in a preset main counting number field corresponding to the commodity identification if the commodity identification is located in a stock set cached locally and the local stock corresponding to the commodity identification is larger than 0;
and the second returning module is used for returning second notification information if the inventory deduction in the preset main design number field is successful.
Optionally, the apparatus further comprises:
and the first synchronization module is used for synchronizing the stock in the preset main counting field after the stock is deducted to the preset auxiliary counting field if the stock deduction in the preset main counting field is successful.
Optionally, the apparatus further comprises:
the third returning module is used for returning the first notification information if the inventory deduction failure occurs in the preset main design number field;
and the deleting module is used for deleting the commodity identification and the corresponding local inventory in the inventory set and adding the commodity identification into the inventory-free set.
Optionally, the apparatus further comprises:
a first determining module, configured to determine, if the commodity identifier is not located in the inventory set, a target preset sub-count field in a plurality of preset sub-count fields corresponding to the commodity identifier according to a preset copy allocation policy;
the second inventory deduction module is used for deducting the inventory in the preset main counting field corresponding to the commodity identification if the inventory is inquired to be larger than 0 in the target preset auxiliary counting field;
and the second synchronization module is used for synchronizing the inventory in the preset main counting number field after the inventory deduction to the local cached inventory-free set or the inventory set.
Optionally, the apparatus further comprises:
the first acquisition module is used for acquiring the stock in the preset main counting number field corresponding to the commodity identification;
the first calculation module is used for calculating the product of the inventory and the preset distribution percentage;
and the second determining module is used for determining the quotient of the product and the number of the hosts in the cluster as the local inventory corresponding to the commodity identification.
Optionally, the apparatus further comprises:
the second acquisition module is used for acquiring the inventory in the preset main counting number field corresponding to the commodity identification;
the second calculation module is used for calculating the quotient of the stock quantity and the number of the hosts in the cluster;
and the third determining module is used for determining the local inventory corresponding to the commodity identification as a preset fixed quantity, wherein the preset fixed quantity is smaller than or equal to the quotient.
Optionally, the apparatus further comprises:
the system comprises a recording module, a processing module and a processing module, wherein the recording module is used for distributing a first preset amount of inventory for each host in a cluster and recording distribution time;
the third calculation module is used for calculating the stock distribution quantity per second of the host when the stock distribution is to be carried out again;
the first distribution module is used for distributing the stock quantity for the host again according to the first preset quantity if the distribution quantity per second is less than or equal to 1;
the second distribution module is used for distributing the stock quantity for the host again according to the distribution quantity per second if the distribution quantity per second is larger than 1 and smaller than a preset distribution reference quantity, wherein the distribution reference quantity is a product obtained by multiplying the stock quantity in a preset main counting number section corresponding to the commodity identification and the number of the hosts in the cluster by a preset percentage, and the distribution reference quantity is larger than 1;
and the third distribution module is used for distributing the stock quantity for the host again according to the distribution reference quantity if the distribution quantity per second is greater than the distribution reference quantity.
In a third aspect, an embodiment of the present invention provides a server, including a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;
a memory for storing a computer program;
a processor configured to implement the resource processing method according to any one of the first aspect when executing a program stored in a memory.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where a resource processing method program is stored, and when executed by a processor, the resource processing method program implements the steps of the resource processing method according to any one of the first aspects.
Compared with the prior art, the technical scheme provided by the embodiment of the invention has the following advantages: in the embodiment of the invention, if the commodity identification is located in the inventory-free set of the local cache, the commodity identification indicates that the commodity has no inventory locally, and the first notification information can be returned.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a schematic flow chart of a resource processing method according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating another resource processing method according to another embodiment of the present invention;
FIG. 3 is a flow chart illustrating another resource processing method according to another embodiment of the present invention;
FIG. 4 is a flowchart illustrating another resource processing method according to another embodiment of the present invention;
FIG. 5 is a flowchart illustrating another resource processing method according to another embodiment of the present invention;
FIG. 6 is a flowchart illustrating another resource processing method according to another embodiment of the present invention;
FIG. 7 is a flowchart illustrating another resource processing method according to another embodiment of the present invention;
fig. 8 is a schematic structural diagram of a resource processing apparatus according to yet another embodiment of the present invention;
fig. 9 is a schematic structural diagram of a server according to another embodiment of the present invention.
Icon: 01-receiving module, 02-first query module; 03-first return module, 1110-processor; 1120-a communication interface; 1130-a memory; 1140-communication bus.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
As in the prior art, each inventory query request is concentrated on a redis cluster, but resources of the redis cluster are limited, and a response speed will be slow in the face of a large number of query requests, and for a user, a situation that an access speed is slow and shopping efficiency is reduced will occur, as shown in fig. 1, an embodiment of the present invention provides a resource processing method, which may be applied to a server, where the server may be communicatively connected to the redis cluster, and the redis cluster includes a plurality of hosts, where the method may include the following steps:
step S101, receiving an inventory inquiry request.
In the embodiment of the present invention, the inventory query request includes a product identifier, where the product identifier may refer to a product ID, and the inventory query request may be sent from a client to a server.
And step S102, inquiring whether the commodity identification is located in an inventory-free set cached locally.
In the embodiment of the invention, the inventory-free set comprises the commodity identification of local inventory-free commodities;
in the embodiment of the present invention, the non-inventory set may be cached locally in the server in advance, and the non-inventory set is set to share the pressure that the redis cluster is accessed at a high speed, and when a certain commodity of the redis cluster is actually out of inventory, if the access to the redis cluster is still requested, the resource of the redis cluster is occupied, and the access speed is reduced.
And step S103, if the commodity identification is located in the stock-free set, returning first notification information.
In the embodiment of the present invention, the first notification information may be negotiated with the client in advance, and when the local inventory is insufficient, the first notification information is returned to the client; the client may also set a stock field in the first notification information, assign the stock field as out, analyze the first notification information after receiving the first notification information, and obtain the value of the stock field as out, so that the local inventory deficiency may be known.
In the embodiment of the invention, an inventory query request carrying a commodity identifier is received firstly, and then whether the commodity identifier is located in an inventory-free set cached locally is queried, if the commodity identifier is located in the inventory-free set, first notification information can be returned.
In the embodiment of the invention, if the commodity identification is located in the inventory-free set of the local cache, the commodity identification indicates that the commodity has no inventory locally, and the first notification information can be returned.
The redis cluster is a non-relational database of a high-performance key-value pair (key-value), wherein a key is generally used for storing a commodity identifier, a value is used for storing inventory, when a high-concurrency scene of a request occurs, such as when a certain popular commodity is discounted, inventory query requests are all concentrated on a certain specific key on the redis cluster, and the specific key is accessed too many times, so that the traffic is excessively concentrated, the upper limit of a physical network card is reached, and the server of the redis database is down. To this end, in a further embodiment of the present invention, a preset primary count field for stock quantity deduction may be provided for each of the commodity identifications, the preset primary count field corresponding to a plurality of preset secondary count fields for stock quantity inquiry, the stock quantity in the preset secondary count field being synchronized with the stock quantity in the preset primary count field.
Based on the above, when stock deduction is needed, deducting the stock in the preset main counting field, and synchronizing the stock to the corresponding multiple preset auxiliary counting fields so as to ensure the accuracy of stock inquiry in the preset auxiliary counting fields; when the inventory query request is received, query can be performed in the inventory of one preset secondary counting field with the least current request quantity according to a load balancing principle, a pin hash value or a random strategy and the like, and the pressure of the high-concurrency inventory query request is shared by the plurality of preset secondary counting fields, so that the inventory query request is prevented from being concentrated on one key.
In practical application, the plurality of preset sub-count fields may be stored in different hosts of the redis cluster, so that when querying is performed in the inventory of one preset sub-count field with the smallest number of current requests, the query may be performed in different hosts, and the multiple hosts are used to share the pressure of highly concurrent inventory query requests, thereby preventing the inventory query requests from being concentrated on one host.
In another embodiment provided by the present invention, a preferred implementation is provided, and as shown in fig. 2, the resource processing method further includes:
step S201, if the product identifier is not located in the stock-free set, querying whether the product identifier is located in a locally cached stock set.
In the embodiment of the invention, the inventory set comprises a commodity identifier of a local inventory commodity and a local inventory corresponding to the commodity identifier;
in the embodiment of the present invention, the inventory set may be cached locally in the server in advance, and the purpose of setting the inventory set is to share the pressure that the redis cluster is accessed at a high speed, and when a certain commodity of the redis cluster is actually stored locally, if the reds cluster is still requested to be accessed, the resource of the redis cluster is occupied, and the access speed is reduced.
Step S202, if the commodity identification is located in an inventory set of a local cache and the local inventory corresponding to the commodity identification is greater than 0, deducting the inventory in a preset main counting number field corresponding to the commodity identification;
in step S203, if the stock quantity deduction in the preset main design number field is successful, the second notification information is returned.
In the embodiment of the present invention, the second notification information may be negotiated with the client in advance, and when the second notification information is stored locally, the second notification information is returned to the client; it is also possible to have specific fields set in the second notification message, such as: the value of the stock field is assigned to be in, the client receives the second notification information, analyzes the second notification information, and obtains the value of the stock field as in, that is, it can know that the stock is locally stored, and in practical application, other implementation manners can be set according to practical situations, which is not limited herein.
In the embodiment of the invention, if the commodity identification is located in the inventory set of the local cache, the commodity is in the local inventory, the inventory can be reduced, and the second notification information is returned.
In another embodiment of the present invention, if the stock reduction in the preset main design number field is successful, the method may further include:
and step S204, synchronizing the stock quantity in the preset main counting field after the stock quantity is deducted to the preset auxiliary counting field.
Because the stock in the preset main counting field is changed after the stock is deducted, in order to ensure the accuracy of the query result obtained by the subsequent stock query request, the stock in the preset main counting field after the stock is deducted can be synchronized to the plurality of corresponding auxiliary counting fields, so that the accurate query result can be obtained based on the data after the stock is deducted during the subsequent stock query request.
In another embodiment of the present invention, as shown in fig. 3, the resource processing method further includes:
step S301, if the inventory reduction in the preset main design number field fails, returning first notification information;
step S302, deleting the commodity identification and the corresponding local inventory in an inventory set, and adding the commodity identification into the inventory-free set;
in the embodiment of the present invention, the failure of deducting the stock may be due to limited stock, and under a high concurrent query request, there may be a large amount of rapid stock deductions, and due to network delay and other situations, a situation that the stock of an actual commodity is insufficient although the commodity identifier is still in the stock set may occur, so that the first notification information may be returned, the commodity identifier is deleted from the stock set and added to the stock-free set, data update is implemented, and a result that a user obtains delayed information and causes poor user experience is avoided.
In another embodiment of the present invention, as shown in fig. 4, the resource processing method further includes:
step S401, if the commodity identification is not located in the inventory set, determining a target preset sub-counting field in a plurality of preset sub-counting fields corresponding to the commodity identification according to a preset copy distribution strategy;
in this embodiment of the present invention, if the commodity identifier is not located in the inventory set, a target preset sub-count field may be determined from a plurality of preset sub-count fields stored in a plurality of hosts of a redis cluster according to a load balancing policy, a pin hash value, or a random allocation policy, for example.
Step S402, if the stock quantity is inquired to be larger than 0 in the target preset secondary counting field, the step of deducting the stock quantity in the preset main counting field corresponding to the commodity identification is executed;
in the embodiment of the invention, because the inventory in the main counting field and the plurality of corresponding secondary counting fields is the total inventory of the commodities corresponding to the commodity identifications in the redis cluster, the inventory in the target preset secondary counting field is also the total inventory of the commodities, and the inventory in the target secondary counting field can be inquired when the inventory in both the non-inventory set and the inventory set of the local cache is insufficient.
And if the target preset secondary counting field has the inventory, executing the step of deducting the inventory in the preset main counting field corresponding to the commodity identification, and if the inventory deduction in the preset main counting field succeeds, returning second notification information and synchronizing the inventory in the preset main counting field after the inventory deduction to the preset secondary counting field.
Step S403, synchronizing the stock quantity in the preset main counting number field after the stock quantity deduction to the stock-free set or the stock set cached locally.
In the embodiment of the present invention, if the inventory in the preset main counting field after deducting the inventory is 0, the commodity identifier may be added to the inventory-free set of the local cache, and if the inventory in the preset main counting field after deducting the inventory is greater than 0, the inventory in the preset main counting field after deducting the inventory may be calculated according to a preset local inventory allocation manner and then synchronized to the preset sub counting field.
The inventory in the preset main counting number field after the inventory is deducted is synchronized, local non-inventory collection or inventory collection data updating is realized, the condition that subsequent inventory inquiry requests acquire lagging information is avoided, the inventory information of commodities can be acquired from the local conveniently, the request response efficiency is improved while the server access pressure is reduced, and a user can receive response information at a higher speed conveniently.
Based on the above, the local inventory query efficiency is much higher than that of direct query in redis, the performance improvement effect is obvious, but the data synchronization problem is also brought, so the following embodiment provides a plurality of allocation strategies to avoid reducing the asynchronous problem when allocating the local cache, and the inventory query is verified again when passing the back deduction, so that the situation that a small amount of inventory passes through but the actual inventory is consumed occurs, and the situation is reduced by reasonably using the strategies.
In another embodiment of the present invention, a method for allocating an inventory amount in a local cache is further provided, as shown in fig. 5, where the resource processing method further includes:
step S501, acquiring the stock in a preset main counting number field corresponding to the commodity identification;
step S502, calculating the product of the inventory and the preset distribution percentage;
step S503, determining the quotient of the product and the number of hosts in the cluster as the local inventory amount corresponding to the commodity identifier.
In the embodiment of the present invention, the distribution percentage may be determined according to actual needs, for example: the total inventory amount is 100, the distribution percentage is 30%, the number of hosts in the redis cluster is 10, namely the redis inventory amount is 100, and the local inventory amount of the local cache of the server is 100 × 0.3/10 — 3.
When the local inventory of the local cache of the server is exhausted, the residual quantity is synchronously distributed to the local inventory of the local cache of the server according to the distribution percentage, the distribution is not carried out when the distribution is less than 1, the specific distribution mode is changed according to the actual condition, and the invention is not limited.
In another embodiment of the present invention, the resource may also be allocated according to a fixed allocation policy, as shown in fig. 6, where the resource processing method further includes:
step S601, acquiring the stock in a preset main counting number field corresponding to the commodity identification;
step S602, calculating the quotient of the stock quantity and the number of the hosts in the cluster;
step S603, determining the local inventory corresponding to the commodity identifier as a preset fixed quantity, where the preset fixed quantity is less than or equal to the quotient.
That is to say, the local inventory corresponding to the commodity identifier is a preset fixed quantity, and the preset fixed quantity is less than or equal to the quotient of the inventory in the preset main counting number section corresponding to the commodity identifier and the quantity of the hosts in the cluster;
in another embodiment of the present invention, a dynamic allocation policy may also be adopted, as shown in fig. 7, the resource processing method further includes:
step S701, allocating a first preset amount of inventory for each host in the cluster, and recording allocation time;
step S702, when the stock distribution is to be carried out again, calculating the stock distribution quantity per second of the host;
step S703, if the allocation amount per second is less than or equal to 1, allocating the stock amount to the host again according to the first preset amount;
step S704, if the distribution quantity per second is larger than 1 and smaller than a preset distribution reference quantity, the stock quantity is distributed to the host again according to the distribution quantity per second, the distribution reference quantity is a product obtained by multiplying the stock quantity in a preset main counting number section corresponding to the commodity identification and the number of the hosts in the cluster by a preset percentage, and the distribution reference quantity is larger than 1;
step S705, if the allocation amount per second is greater than the allocation reference amount, allocating the stock amount again to the host according to the allocation reference amount.
In the embodiment of the present invention, a dynamic allocation policy is adopted, the stock quantity is allocated for the host in the cluster for the first time, the data may be determined according to the actual situation, or the allocation manner described in the above embodiment may be adopted, and when the stock distribution is performed again, the stock quantity is allocated for the host again according to the allocation reference quantity, for example: and calculating the distribution quantity of the hosts per second, if the distribution quantity of the hosts per second is less than or equal to 1, continuing to distribute 1 inventory, otherwise, distributing the quantity per second, and if the distribution quantity is more than one third of the total inventory quantity/host quantity, distributing one third of the quantity (total inventory quantity/host quantity).
In another embodiment of the present invention, there is also provided a resource processing apparatus, as shown in fig. 8, including:
the receiving module 01 is used for receiving an inventory query request, wherein the inventory query request comprises a commodity identifier;
the first query module 02 is configured to query whether the commodity identifier is located in an inventory-free set cached locally, where the inventory-free set includes the commodity identifier of a local inventory-free commodity;
the first returning module 03 is configured to return first notification information if the product identifier is located in the inventory-free set.
In another embodiment of the present invention, each of the commodity identifications corresponds to a preset primary counting field for inventory deduction, the preset primary counting field corresponds to a plurality of preset secondary counting fields for inventory inquiry, and the inventory in the preset secondary counting fields is synchronous with the inventory in the preset primary counting field.
In yet another embodiment of the present invention, the apparatus further comprises:
the second query module is used for querying whether the commodity identification is located in an inventory set cached locally or not if the commodity identification is not located in the inventory-free set, wherein the inventory set comprises the commodity identification of local inventory commodities and local inventory corresponding to the commodity identification;
the first stock deduction module is used for deducting the stock in a preset main counting number field corresponding to the commodity identification if the commodity identification is located in a stock set cached locally and the local stock corresponding to the commodity identification is larger than 0;
and the second returning module is used for returning second notification information if the inventory deduction in the preset main design number field is successful.
In yet another embodiment of the present invention, the apparatus further comprises:
and the first synchronization module is used for synchronizing the stock in the preset main counting field after the stock is deducted to the preset auxiliary counting field if the stock deduction in the preset main counting field is successful.
In yet another embodiment of the present invention, the apparatus further comprises:
the third returning module is used for returning the first notification information if the inventory deduction failure occurs in the preset main design number field;
and the deleting module is used for deleting the commodity identification and the corresponding local inventory in the inventory set and adding the commodity identification into the inventory-free set.
In yet another embodiment of the present invention, the apparatus further comprises:
a first determining module, configured to determine, if the commodity identifier is not located in the inventory set, a target preset sub-count field in a plurality of preset sub-count fields corresponding to the commodity identifier according to a preset copy allocation policy;
the second inventory deduction module is used for deducting the inventory in the preset main counting field corresponding to the commodity identification if the inventory is inquired to be larger than 0 in the target preset auxiliary counting field;
and the second synchronization module is used for synchronizing the inventory in the preset main counting number field after the inventory deduction to the local cached inventory-free set or the inventory set.
In yet another embodiment of the present invention, the apparatus further comprises:
the first acquisition module is used for acquiring the stock in the preset main counting number field corresponding to the commodity identification;
the first calculation module is used for calculating the product of the inventory and the preset distribution percentage;
and the second determining module is used for determining the quotient of the product and the number of the hosts in the cluster as the local inventory corresponding to the commodity identification.
In yet another embodiment of the present invention, the apparatus further comprises:
the second acquisition module is used for acquiring the inventory in the preset main counting number field corresponding to the commodity identification;
the second calculation module is used for calculating the quotient of the stock quantity and the number of the hosts in the cluster;
and the third determining module is used for determining the local inventory corresponding to the commodity identification as a preset fixed quantity, wherein the preset fixed quantity is smaller than or equal to the quotient.
In yet another embodiment of the present invention, the apparatus further comprises:
the system comprises a recording module, a processing module and a processing module, wherein the recording module is used for distributing a first preset amount of inventory for each host in a cluster and recording distribution time;
the third calculation module is used for calculating the stock distribution quantity per second of the host when the stock distribution is to be carried out again;
the first distribution module is used for distributing the stock quantity for the host again according to the first preset quantity if the distribution quantity per second is less than or equal to 1;
the second distribution module is used for distributing the stock quantity for the host again according to the distribution quantity per second if the distribution quantity per second is larger than 1 and smaller than a preset distribution reference quantity, wherein the distribution reference quantity is a product obtained by multiplying the stock quantity in a preset main counting number section corresponding to the commodity identification and the number of the hosts in the cluster by a preset percentage, and the distribution reference quantity is larger than 1;
and the third distribution module is used for distributing the stock quantity for the host again according to the distribution reference quantity if the distribution quantity per second is greater than the distribution reference quantity.
The invention receives the inventory inquiry request which comprises the commodity identification; inquiring whether the commodity identification is located in an inventory-free set cached locally or not, wherein the inventory-free set comprises the commodity identification of local inventory-free commodities; if the commodity identification is located in the stock-free set, the stock-free set cached locally is accessed in advance in a mode of returning first notification information, if the stock-free set comprises the commodity identification of the local stock-free commodity, stock shortage information is returned, query requests of the stock-free commodity are screened and concentrated to the database, the access pressure of the database is reduced, and therefore the query requests are responded more efficiently.
In the embodiment of the present invention, there is also provided a server, as shown in fig. 9, including a processor 1110, a communication interface 1120, a memory 1130, and a communication bus 1140, where the processor 1110, the communication interface 1120, and the memory 1130 complete communication with each other through the communication bus 1140;
a memory 1130 for storing computer programs;
the processor 1110 is configured to implement the resource processing method according to any one of claims 1 to 8 when executing the program stored in the memory 1130.
In the server provided in the embodiment of the present invention, the processor 1110 implements a playing operation of obtaining a video by executing a program stored in the memory 1130, determines a corresponding frame rate reduction policy according to the playing operation, and performs playing after adjusting frame data corresponding to video data according to the frame rate reduction policy, thereby ensuring that a playing device can play the video well.
The communication bus 1140 mentioned above may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus 1140 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 9, but this does not indicate only one bus or one type of bus.
The communication interface 1120 is used for communication between the server and other devices.
The memory 1130 may include a Random Access Memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The processor 1110 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the integrated circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components.
In an embodiment of the present invention, a computer-readable storage medium is further provided, where a resource processing method program is stored, and when executed by a processor, the resource processing method program implements the steps of the resource processing method described in any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may 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. The procedures or functions according to the embodiments of the invention are brought about in whole or in part when the computer program instructions are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wirelessly (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (ssd)), among others.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (12)

1. A method for processing resources, comprising:
receiving an inventory query request, wherein the inventory query request comprises a commodity identifier;
inquiring whether the commodity identification is located in an inventory-free set cached locally or not, wherein the inventory-free set comprises the commodity identification of local inventory-free commodities;
and if the commodity identification is located in the stock-free set, returning first notification information.
2. The resource processing method according to claim 1, wherein each of the commodity identifications corresponds to a preset primary count field for stock quantity deduction, the preset primary count field corresponds to a plurality of preset secondary count fields for stock quantity inquiry, and stock quantities in the preset secondary count fields are synchronized with stock quantities in the preset primary count field.
3. The resource handling method of claim 2, wherein the method further comprises:
if the commodity identification is not located in the stock-free set, inquiring whether the commodity identification is located in a stock set cached locally or not, wherein the stock set comprises the commodity identification of local stock commodities and local stock corresponding to the commodity identification;
if the commodity identification is located in an inventory set of a local cache and the local inventory corresponding to the commodity identification is greater than 0, deducting the inventory in a preset main counting number field corresponding to the commodity identification;
and if the inventory deduction in the preset main design number field is successful, returning second notification information.
4. The resource handling method of claim 3, wherein if the inventory reduction is successful in the preset master inventory value, the method further comprises:
and synchronizing the stock in the preset main counting field after the stock is deducted to the preset auxiliary counting field.
5. The resource handling method of claim 3, wherein the method further comprises:
if the inventory reduction in the preset main design number field fails, returning first notification information;
and deleting the commodity identification and the corresponding local inventory in an inventory set, and adding the commodity identification into the inventory-free set.
6. The resource handling method of claim 3, wherein the method further comprises:
if the commodity identification is not located in the inventory set, determining a target preset sub-counting field in a plurality of preset sub-counting fields corresponding to the commodity identification according to a preset copy distribution strategy;
if the stock quantity is larger than 0 in the target preset secondary counting field, executing a step of deducting the stock quantity in a preset main counting field corresponding to the commodity identification;
synchronizing the inventory in the preset main counting number field after the inventory is deducted to the inventory-free set or the inventory set cached locally.
7. The resource handling method of claim 3, wherein the method further comprises:
acquiring a preset inventory corresponding to the commodity identification;
calculating the product of the inventory and a preset distribution percentage;
and determining the quotient of the product and the number of the hosts in the cluster as the local inventory corresponding to the commodity identification.
8. The resource handling method of claim 3, wherein the method further comprises:
acquiring the stock in a preset main counting number field corresponding to the commodity identification;
calculating the quotient of the inventory and the number of hosts in the cluster;
and determining the local inventory corresponding to the commodity identification as a preset fixed quantity, wherein the preset fixed quantity is less than or equal to the quotient.
9. The resource handling method of claim 3, wherein the method further comprises:
allocating a first preset amount of inventory for each host in the cluster, and recording allocation time;
when the stock distribution is to be carried out again, calculating the stock distribution quantity per second of the host;
if the distribution quantity per second is less than or equal to 1, allocating the stock for the host again according to the first preset quantity;
if the distribution quantity per second is larger than 1 and smaller than a preset distribution reference quantity, distributing the stock quantity for the host again according to the distribution quantity per second, wherein the distribution reference quantity is a product obtained by multiplying a quotient of the stock quantity in a preset main counting number section corresponding to the commodity identification and the quantity of the host in the cluster by a preset percentage, and the distribution reference quantity is larger than 1;
and if the distribution quantity per second is larger than the distribution reference quantity, distributing the stock quantity for the host again according to the distribution reference quantity.
10. A resource processing apparatus, comprising:
the receiving module is used for receiving an inventory inquiry request, wherein the inventory inquiry request comprises a commodity identifier;
the first query module is used for querying whether the commodity identification is located in an inventory-free set cached locally, wherein the inventory-free set comprises the commodity identification of local inventory-free commodities;
and the first returning module is used for returning first notification information if the commodity identification is positioned in the stock-free set.
11. A server is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing the communication between the processor and the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the resource processing method according to any one of claims 1 to 9 when executing a program stored in a memory.
12. A computer-readable storage medium, characterized in that a resource processing method program is stored on the computer-readable storage medium, which when executed by a processor implements the steps of the resource processing method of any one of claims 1 to 9.
CN201910979230.XA 2019-10-15 2019-10-15 Resource processing method, device, server and computer readable storage medium Pending CN110909978A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910979230.XA CN110909978A (en) 2019-10-15 2019-10-15 Resource processing method, device, server and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910979230.XA CN110909978A (en) 2019-10-15 2019-10-15 Resource processing method, device, server and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN110909978A true CN110909978A (en) 2020-03-24

Family

ID=69815696

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910979230.XA Pending CN110909978A (en) 2019-10-15 2019-10-15 Resource processing method, device, server and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN110909978A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112015745A (en) * 2020-08-19 2020-12-01 北京达佳互联信息技术有限公司 Data management method and device
CN113298596A (en) * 2020-07-31 2021-08-24 阿里巴巴集团控股有限公司 Data processing method, device and equipment
WO2023045325A1 (en) * 2021-09-26 2023-03-30 烟台杰瑞石油服务集团股份有限公司 Resource storage and acquisition method and apparatus

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103310325A (en) * 2013-06-26 2013-09-18 苏州奇可思信息科技有限公司 Novel stock checking system
CN106557482A (en) * 2015-09-25 2017-04-05 阿里巴巴集团控股有限公司 A kind of inventory system data-updating method and device
CN108897615A (en) * 2018-05-31 2018-11-27 康键信息技术(深圳)有限公司 Second kills request processing method, application server cluster and storage medium
CN109949135A (en) * 2019-03-20 2019-06-28 江苏满运软件科技有限公司 High concurrent transaction request processing method, system, equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103310325A (en) * 2013-06-26 2013-09-18 苏州奇可思信息科技有限公司 Novel stock checking system
CN106557482A (en) * 2015-09-25 2017-04-05 阿里巴巴集团控股有限公司 A kind of inventory system data-updating method and device
CN108897615A (en) * 2018-05-31 2018-11-27 康键信息技术(深圳)有限公司 Second kills request processing method, application server cluster and storage medium
CN109949135A (en) * 2019-03-20 2019-06-28 江苏满运软件科技有限公司 High concurrent transaction request processing method, system, equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113298596A (en) * 2020-07-31 2021-08-24 阿里巴巴集团控股有限公司 Data processing method, device and equipment
CN112015745A (en) * 2020-08-19 2020-12-01 北京达佳互联信息技术有限公司 Data management method and device
WO2023045325A1 (en) * 2021-09-26 2023-03-30 烟台杰瑞石油服务集团股份有限公司 Resource storage and acquisition method and apparatus

Similar Documents

Publication Publication Date Title
CN111091429B (en) Electronic bill identification distribution method and device and electronic bill generation system
CN107832126B (en) Thread adjusting method and terminal thereof
CN109660607B (en) Service request distribution method, service request receiving method, service request distribution device, service request receiving device and server cluster
US11146502B2 (en) Method and apparatus for allocating resource
CN108304554B (en) File splitting method and device, computer equipment and storage medium
CN110909978A (en) Resource processing method, device, server and computer readable storage medium
US10235047B2 (en) Memory management method, apparatus, and system
CN110519183B (en) Node speed limiting method and device, electronic equipment and storage medium
CN106790552B (en) A kind of content providing system based on content distributing network
CN111600957A (en) File transmission method, device and system and electronic equipment
CN111722918A (en) Service identification code generation method and device, storage medium and electronic equipment
WO2015085969A1 (en) Recommendation algorithm optimization method, device, and system
CN108667744B (en) Flow control method and device
CN113742135B (en) Data backup method, device and computer readable storage medium
WO2021114025A1 (en) Incremental data determination method, incremental data determination apparatus, server and terminal device
US10678192B1 (en) Optimization of production systems
KR101908377B1 (en) Meter data management system and computer readable recording medium to member deterioration
US20190372825A1 (en) Communication apparatus, communication method, and recording medium
CN112866985A (en) Flow control method, resource downloading method, device, equipment and storage medium
CN107203890B (en) Voucher data issuing method, device and system
CN112669160B (en) Data processing method and device, electronic equipment and storage medium
CN108572871B (en) Resource allocation method and device, electronic equipment and storage medium
JP2019528521A (en) Method and aggregate storage system for aggregating statistics
CN108683608B (en) Method and device for distributing flow
CN112948298A (en) Message processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Technology Holding Co.,Ltd.

Address before: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: Jingdong Digital Technology Holding Co.,Ltd.

Address after: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Digital Technology Holding Co.,Ltd.

Address before: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: JINGDONG DIGITAL TECHNOLOGY HOLDINGS Co.,Ltd.

CB02 Change of applicant information
RJ01 Rejection of invention patent application after publication

Application publication date: 20200324

RJ01 Rejection of invention patent application after publication