CN108133399A - The second of high concurrent fast-response kills the method, apparatus and system that inventory precisely reduces - Google Patents

The second of high concurrent fast-response kills the method, apparatus and system that inventory precisely reduces Download PDF

Info

Publication number
CN108133399A
CN108133399A CN201611085964.6A CN201611085964A CN108133399A CN 108133399 A CN108133399 A CN 108133399A CN 201611085964 A CN201611085964 A CN 201611085964A CN 108133399 A CN108133399 A CN 108133399A
Authority
CN
China
Prior art keywords
token
inventory
user
reduces
buffer queues
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.)
Granted
Application number
CN201611085964.6A
Other languages
Chinese (zh)
Other versions
CN108133399B (en
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201611085964.6A priority Critical patent/CN108133399B/en
Publication of CN108133399A publication Critical patent/CN108133399A/en
Application granted granted Critical
Publication of CN108133399B publication Critical patent/CN108133399B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • G06Q30/0605Supply or demand aggregation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • General Engineering & Computer Science (AREA)
  • Economics (AREA)
  • General Business, Economics & Management (AREA)
  • Strategic Management (AREA)
  • Marketing (AREA)
  • Development Economics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

A kind of present invention offer second of high concurrent fast-response kills method, apparatus and system that inventory precisely reduces, and the inventory that can solve the problems, such as to occur under user's panic buying scene of high concurrent big flow detains less or more buttons.This method includes:According to the stockpile number of the second activity of killing, the token with unique sign value of initialization generation corresponding number, and the token is stored in Redis buffer queues;If according to user purchase request, token is got from Redis buffer queues, then user information is inserted into order database, inventory reduces success if being inserted into successfully, and the user information includes user identity information and user's order placement information;If being inserted into failure, inventory reduces unsuccessfully, the token of acquisition is retracted to Redis buffer queues.

Description

The second of high concurrent fast-response kills the method, apparatus and system that inventory precisely reduces
Technical field
It is accurate that inventory is killed the present invention relates to computer technology and software field more particularly to a kind of second of high concurrent fast-response The method, apparatus and system reduced.
Background technology
Second, which kills panic buying advertising campaign, has become the important hand that electric business company attracts user's registration and promotion user activity Section.Wherein, the second kill inventory and whether accurately reduce be weigh the second kill system whether the key index of reliability service.The second activity of killing starts Before, it will usually killing advertising campaign according to commodity ID (hereinafter referred to as " SKUID ") one second of establishment, (second kills advertising campaign and corresponds to One promotion ID, hereinafter referred to as " PromoID "), the setting second kills and starts over the time, haggling lattice, second second kills the information such as inventory.
In the prior art, the second kill inventory (hereinafter referred to as " stock ") initialization storage and the mode of reducing be broadly divided into Under it is several:
Mode 1:Before second activity of killing starts, the second is killed into inventory and initializes and is stored in inventory database.When the second activity of killing starts, Inventory's reduces step:The first step, the corresponding inventory stock of inquiry PromoID;Second step, as inventory stock > 0, Update stock=stock-1, otherwise panic buying failure;Third walks, and order database generation user's sequence information is inserted into, if inserting Enter failure, then retract inventory update stock=stock+1, otherwise rushes to purchase successfully.Idiographic flow is as shown in Figure 1.
Mode 2:Before second activity of killing starts, the second is killed into inventory and initializes and is stored in inventory's buffer queue, the second activity of killing starts When, inventory's reduces step:The first step obtains the corresponding inventory stock of PromoID;Second step, as inventory stock > 0, Set stock=stock-1, otherwise panic buying failure;Third walks, as inventory stock < 0, panic buying failure, otherwise into the 4th Step is inserted into order database generation user's sequence information, if being inserted into failure, retract inventory set stock=stock+1, no Then rush to purchase success.Idiographic flow is as shown in Figure 2.
But the above-mentioned second kills inventory storage and the mode reduced more or less comes with some shortcomings part, especially in height The user of concurrent big flow is rushed to purchase under request, and inventory few button will occurs or detain phenomenon more, and the second activity of killing is caused oversold or few occur The result sold.It is specific as follows:
In mode 1:Second kills inventory stock and is stored in relevant database, is limited by the limit of connection number and database itself System, under high concurrent request, database performance, which will drastically decline, even there is exception, causes to inquire and updates inventory's failure.Separately Outside, the inventory of mode 1 reduces logic will lead to the risk detained inventory more under high concurrent, causes the reason of detaining referring to Fig. 3 more:If Between the T1-T2 moment, concurrent request A, B, C inquiry inventory stock==1 i.e. in stock, carry out inventory and reduce respectively at this time, by Reducing operation in inventory needs to lock row, i.e. synchronization, and only there are one requests to obtain row lock, and then ask A, B, C will in order Inventory is reduced in a serial fashion, most inventory reduces as negative and rushes to purchase success at last, it is clear that inventory occur and detain i.e. more Oversold phenomenon.
In mode 2:For mode 1, by the second kill inventory storage brought in the buffer queue of key-value it is bright Aobvious benefit is:Under high concurrent scene, inquire and reduce inventory and hardly caching performance is had an impact, and then can be strong The ground support second kills the normal operation of system.Meanwhile in order to solve the problems, such as that inventory detains more, on the basis of mode 1, increase inventory Updated decision logic is reduced, and then avoids and the phenomenon that oversold occurs, as shown in Figure 4.But there is also apparent for mode 2 Shortcoming:If user reduces warehousing success but user information is inserted into order database failure, can retract inventory, at this time library It deposits stock+1 and remains as negative later, if next request D judges that stockpile number is less than 0 when coming in, then rush to purchase and fail, that is, go out Show and sold phenomenon less.As shown in Figure 5.
Invention content
In view of this, the present invention provides a kind of second of high concurrent fast-response and kills the method, apparatus and be that inventory precisely reduces System, the inventory that can solve the problems, such as to occur under user's panic buying scene of high concurrent big flow detains less or more buttons.
To achieve the above object, according to an aspect of the invention, there is provided a kind of second of high concurrent fast-response kills inventory The method precisely reduced.
A kind of second of high concurrent fast-response of the present invention kills the method that inventory precisely reduces and includes:According to the library of the second activity of killing Quantity, the token with unique sign value of initialization generation corresponding number are deposited, and the token is stored in Redis cachings In queue;If according to user purchase request, token is got from Redis buffer queues, then user information is inserted into order Database, inventory reduces success if being inserted into successfully, and the user information includes user identity information and user's order placement information; If being inserted into failure, inventory reduces unsuccessfully, the token of acquisition is retracted to Redis buffer queues.
Optionally, the method further includes:After getting token from Redis buffer queues, user is obtained and is recorded It is stored in token distributing lists, the user obtains record and includes user identity information and the token of acquisition.
Optionally, the method further includes:If being inserted into failure, remove and the token got retracts to Redis cachings team Except row, corresponding user is also obtained into record and is deleted from token distributing lists.
Optionally, the method further includes:Before user is obtained in record deposit token distributing lists, verification user's mark Know information, if the user identity information is present in token distributing lists, prompt to reduce unsuccessfully, and not described in preservation User obtains record, and the token got is retracted into Redis buffer queues.
Optionally, the token distributing lists are Redis Hash tables.
Optionally, the method further includes:Using optimistic lock mechanism, synchronization only handles one and caches team from Redis The operation of token is obtained in row;And when the token got is retracted into Redis buffer queues, if there is multiple times simultaneously Operation requests are moved back, then block waiting, to ensure that all token retract successfully.
To achieve the above object, according to another aspect of the present invention, providing a kind of second of high concurrent fast-response kills inventory The device precisely reduced.
A kind of second of high concurrent fast-response of the present invention kills the device that inventory precisely reduces and includes:Inventory's initialization module, For the stockpile number according to the second activity of killing, the token of initialization generation corresponding number, and the token is stored in Redis In buffer queue;Inventory reduces module, if for according to user purchase request, is got from Redis buffer queues User information is then inserted into order database by token, and inventory reduces success if being inserted into successfully, and the user information includes using Family identification information and user's order placement information;Inventory's rollback module, if failing for being inserted into, inventory reduces unsuccessfully, will obtain Token retract to Redis buffer queues.
Optionally, the inventory reduces module and is additionally operable to:After getting token from Redis buffer queues, by user It obtains in record deposit token distributing lists, the user obtains record and includes user identity information and the token of acquisition.
Optionally, described device is additionally operable to:If being inserted into failure, in addition to inventory's rollback module is by the token got times It retreats to except Redis buffer queues, the inventory reduces module and also deletes corresponding user acquisition record from token distributing lists It removes.
Optionally, described device further includes:Module is purchased with threshold, deposits user's acquisition record for reducing module in inventory Before entering in token distributing lists, user identity information is verified, if the user identity information is present in token distributing lists, Then prompting is reduced unsuccessfully, and the inventory reduces module and not preserves user's acquisition record, and will be obtained by inventory's rollback module The token got retracts into Redis buffer queues.
Optionally, the token distributing lists are Redis Hash tables.
Optionally, described device is additionally operable to:The inventory reduces module using optimistic lock mechanism, and synchronization only handles one The operation of token is obtained in a buffer queue from Redis;And inventory's rollback module by the token got retract to When in Redis buffer queues, if there is multiple rollback operations to ask simultaneously, block waitings, with ensure all token rollbacks into Work(.
To achieve the above object, in accordance with a further aspect of the present invention, providing a kind of second of high concurrent fast-response kills inventory The system precisely reduced.
A kind of second of high concurrent fast-response of the present invention kills the system that inventory precisely reduces and includes:Memory and processor, Wherein, the memory is for storing instruction;The processor is configured as performing following action according to described instruction:According to the second The stockpile number for the activity of killing, the token with unique sign value of initialization generation corresponding number, and the token is preserved In Redis buffer queues;If according to user purchase request, token is got from Redis buffer queues, then by user Information is inserted into order database, and inventory reduces success if being inserted into successfully, the user information including user identity information and User's order placement information;If being inserted into failure, inventory reduces unsuccessfully, the token of acquisition is retracted to Redis buffer queues.
According to the technique and scheme of the present invention, under by rushing to purchase scene in the user of high concurrent big flow, buffer queue is utilized And the token technologies with unique sign value realize that the second of quick response kills inventory and accurately reduces, it is few so as to effectively solve It sells or oversold problem;Token is stored by using Hash table, strategy is purchased with threshold so as to realize, same user is avoided to purchase Buy the phenomenon that multiple;By the way that when user information is inserted into order database and fails, token is retracted into buffer queue, so as to It is possible to prevente effectively from the generation of phenomenon is sold less;By using optimism lock and obstruction waiting mechanism, it thereby may be ensured that token is obtained Take the accuracy to retract with token.
Description of the drawings
Attached drawing does not form inappropriate limitation of the present invention for more fully understanding the present invention.Wherein:
Fig. 1 is that the inventory of the prior art reduces the inventory of mode 1 and reduces schematic diagram;
Fig. 2 is that the inventory of the prior art reduces the inventory of mode 2 and reduces schematic diagram;
Fig. 3 is that the inventory of the prior art reduces the oversold analyzing chart for reason of mode 1;
Fig. 4 is that the inventory of the prior art reduces the anti-oversold analysis chart of mode 2;
Fig. 5 is that the inventory of the prior art reduces lacking for mode 2 and sells analyzing chart for reason;
Fig. 6 is to kill the key step for the method that inventory precisely reduces the second of high concurrent fast-response according to embodiments of the present invention Schematic diagram;
Fig. 7 is to kill the flow chart element for the method that inventory precisely reduces the second of high concurrent fast-response according to embodiments of the present invention Figure;
Fig. 8 is to kill the inventory for the method that inventory precisely reduces the second of high concurrent fast-response according to embodiments of the present invention Token creates schematic diagram;
Fig. 9 is the second of high concurrent fast-response according to embodiments of the present invention to kill the inventory of the method that inventory precisely reduces to reduce Schematic diagram;
Figure 10 is to kill the inventory time for the method that inventory precisely reduces the second of high concurrent fast-response according to embodiments of the present invention Move back schematic diagram;
Figure 11 be the second of high concurrent fast-response according to embodiments of the present invention kill the method that inventory precisely reduces use threshold Purchase schematic diagram;
Figure 12 is to kill the main mould for the device that inventory precisely reduces the second of high concurrent fast-response according to embodiments of the present invention The schematic diagram of block;
Figure 13 is the main portion for the system that inventory precisely reduces that kills the second of high concurrent fast-response according to embodiments of the present invention The schematic diagram divided.
Specific embodiment
It explains below in conjunction with attached drawing to the exemplary embodiment of the present invention, including the various of the embodiment of the present invention Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize It arrives, various changes and modifications can be made to the embodiments described herein, without departing from scope and spirit of the present invention.Together For clarity and conciseness, the description to known function and structure is omitted in sample in following description.
The technical solution of the embodiment of the present invention is mainly the library occurred under the user's panic buying scene for solving high concurrent big flow Deposit few button or more button problems.
Fig. 6 is to kill the key step for the method that inventory precisely reduces the second of high concurrent fast-response according to embodiments of the present invention Schematic diagram.
Mainly include as shown in fig. 6, the second of the high concurrent fast-response of the embodiment of the present invention kills the method that inventory precisely reduces Following steps:
Step S61:According to the stockpile number of the second activity of killing, initialization generation corresponding number has unique sign value Token (token, a kind of authority have unique marked effect), and the token is stored in Redis buffer queues.This step Rapid purpose is to complete the initialization of inventory.
After the inventory of step S61 initializes completion, come into effect and reduce from step S62.
Step S62:If according to user purchase request, token is got from Redis buffer queues, then is believed user Breath is inserted into order database, and inventory reduces success if being inserted into successfully, and the user information includes user identity information and use Family order placement information.This step is to be asked to realize according to the purchase of user, and the real-time and precise of inventory is reduced.Wherein, from After getting token in Redis buffer queues, user can also be obtained in record deposit token distributing lists, the user It obtains record and includes user identity information and the token of acquisition, situation is reduced to record inventory in real time.
According to the second kill activity usually have with threshold purchase it is specific, the second of the high concurrent fast-response of the embodiment of the present invention kills library It deposits in the method precisely reduced, before can also including obtaining user in record deposit token distributing lists, verifies user identifier Information if the user identity information is present in token distributing lists, is prompted to reduce unsuccessfully, and not preserve the use Family obtains record, and the token got is retracted into Redis buffer queues.
Step S63:If being inserted into order database failure in step S62, inventory reduces unsuccessfully, the token of acquisition is returned Retreat to Redis buffer queues.
It, will also be corresponding other than the token got is retracted to Redis buffer queues if failing in addition, being inserted into User obtains record and is deleted from token distributing lists.
In the foregoing description, token distributing lists can be Redis Hash tables.
Wherein, in foregoing description, when needing to obtain token from buffer queue, optimistic lock mechanism usually may be used, Synchronization only handles an operation that token is obtained from Redis buffer queues, to ensure that token is reduced accurate, avoids The generation of commodity oversold phenomenon;And when needing to retract the token got into Redis buffer queues, if having simultaneously Multiple rollback operation requests, then block waiting, to ensure that all token retract successfully, to avoid the appearance of commodity steamed dumplings phenomenon.
In the embodiment of the present invention, the second of high concurrent fast-response kills the method that inventory precisely reduces and mainly utilizes high concurrent fast The second of response kills the device that inventory precisely reduces and carries out.The second of high concurrent fast-response kills device that inventory precisely reduces mainly can be with Including three modules:Inventory's initialization module, inventory reduce module and inventory's rollback module, in addition, it can include user Limit purchase module.
First according to stockpile number stock, the token of corresponding number is generated, and is stored in Redis buffer queues so as to complete The initialization of inventory.When second kills beginning, reducing for stockpile number stock is converted into reducing for token.If it has not been obtained Token is then rushed to purchase and is failed;If successfully obtaining token representatives obtains panic buying qualification, user information is inserted into order data Library represents if being put in storage successfully and rushes to purchase successfully, if storage failure, rush to purchase and fail, at the same by the token got retract to Redis buffer queues.But kill the movable identity usually having according to user, such as pin (personal using the second Identification number, person identfication number), the characteristics of limit pin limits purchase 1 is carried out, after token is got, Limit purchase checking treatment would generally be done to the panic buying user of same PromoID, if user had bought, by rollback token simultaneously User is prompted to rush to purchase failure.The general frame is as shown in Figure 7.
Each module role for the device that inventory precisely reduces is killed below in conjunction with the second of high concurrent fast-response, to this hair The main flow that the second of the high concurrent fast-response of bright embodiment kills the method that inventory precisely reduces describes in detail.
Inventory's initialization module:The second of record operation personnel's setting kills stockpile number stock, the general unique knowledge of recursive call Unique sign value generating algorithm such as other code UUID (Universally Unique Identifier), generation have general unique The token (token is convenient for log analysis) of numerical value is indicated, and is deposited into Redis buffer queues.Meanwhile day is written into token Will file token_log is checked when killing activity end convenient for the second.So as to complete the mapping one by one of stockpile number stock to token, So that the quantity and stock of token are consistent.As shown in Figure 8.
Inventory reduces module:Bottom data structural support carries out high concurrent to token used by Redis buffer queues Take out operation.It is asked according to the high concurrent of user, using LPOP, (Left POP remove an element, also referred to as from the queue left side To remove and returning first element in queue) instruction, token is taken out from queue, since LPOP is using optimistic lock security system Cheng Anquan, i.e. synchronization only allow a thread to obtain token, other thread queuings wait for, and avoid multiple threads with for the moment Quarter obtains same token, and then effectively evades oversold problem.It is detailed that reduce step as follows:When the second activity of killing starts, use LPOP mechanism takes out token from Redis buffer queues, if NIL (no value, for sky), then rushes to purchase and fails, be otherwise It is no to have bought decision logic, if passing through, during user information is inserted into order database, such as can preserve to sequence information Table userInfo_table if being inserted into userInfo_table successes, rushes to purchase success.As shown in Figure 9.
Inventory's rollback module:If user obtains token successes but is inserted into sequence information table userInfo_table failures, It deletes corresponding user token in token distributing lists and gets record, while token need to be retracted to Redis buffer queues.It adopts With RPUSH (Right PUSH are inserted into an element that is, on the right of the queue, are also referred to as inserted into an element from tail of the queue) by token It retracts, since RPUSH instructions are in a manner that obstruction accesses, when multiple threads simultaneously retract token to Redis buffer queues When, waiting can be blocked and just returned after being inserted into successfully.This mode simulates inventory's rollback mode of reality scene completely, can solve The inventory's rollback failure problem certainly occurred in the mode 2 of the prior art using the stockpile number mode of reducing, has effectively been evaded and sold less Phenomenon.Process is as shown in Figure 10.
Module is purchased with threshold:Since the second activity of killing usually requires limit pin limit purchases, i.e., activity killed for the same second, one User can only buy one.In the embodiment of the present invention, can it be used by the use of Redis Hash tables as token distributing lists The data structure of promoID-pin-token_value does limit pin limit purchase processing.Using promoID-pin as Hash keys key, A record deposit token distributing list can be generated after user obtains token, when same user attempts to be inserted into for the second time to be somebody's turn to do During table, since the corresponding value token_value of promoID-pin Hash keys key have existed, represent that user had rushed to purchase one It is secondary, then the failure of token distributing lists is inserted into, and then effectively evade the problem of same pin purchases are multiple.Process is as shown in figure 11.
The second of high concurrent fast-response according to embodiments of the present invention kill the method that inventory precisely reduces can be seen that by The user of high concurrent big flow is rushed to purchase under scene, and using buffer queue and the token technologies with unique sign value are realized quickly The second of response kills inventory and accurately reduces, so as to effectively solve the problems, such as to sell less or oversold;It is stored by using Hash table Token purchases strategy with threshold so as to realize, same user is avoided to buy the phenomenon that multiple;By being inserted into user information When order database fails, token is retracted into buffer queue, so as to effectively avoid selling the generation of phenomenon less;Pass through Using optimism lock and obstruction waiting mechanism, the accuracy that token is obtained and token retracts thereby may be ensured that.
Figure 12 is to kill the main mould for the device that inventory precisely reduces the second of high concurrent fast-response according to embodiments of the present invention The schematic diagram of block.
As shown in figure 12, the second of the high concurrent fast-response of the embodiment of the present invention, it is main to kill the device 120 that inventory precisely reduces Including following module:Inventory's initialization module 121, inventory reduce module 122 and inventory's rollback module 123, wherein, inventory Initialization module 121 is used for the stockpile number according to the second activity of killing, and initialization generates the token of corresponding number, and by described in Token is stored in Redis buffer queues;If inventory reduces module 122 for according to user purchase request, delaying from Redis It deposits and token is got in queue, then user information is inserted into order database, inventory reduces success if being inserted into successfully, described User information includes user identity information and user's order placement information;If inventory's rollback module 123 fails for being inserted into, inventory It reduces unsuccessfully, the token of acquisition is retracted to Redis buffer queues.
Wherein, inventory reduces module 122 and can be additionally used in:After getting token from Redis buffer queues, by user It obtains in record deposit token distributing lists, the user obtains record and includes user identity information and the token of acquisition.Institute Token distributing lists are stated to can be, but not limited to as Redis Hash tables.
Device 120 can be additionally used in:If be inserted into failure, in addition to inventory's rollback module by the token got retract to Except Redis buffer queues, the inventory reduces module and also deletes corresponding user acquisition record from token distributing lists.
In addition, device 120 may also include:Module (not shown) is purchased with threshold, will be used for reducing module in inventory Before family is obtained in record deposit token distributing lists, user identity information is verified, if the user identity information is present in In token distributing lists, then prompting is reduced unsuccessfully, and the inventory reduces module and not preserves user's acquisition record, and by library It deposits rollback module the token got retracts into Redis buffer queues.
Device 120 can be additionally used in:The inventory reduces module using optimistic lock mechanism, synchronization only handle one from The operation of token is obtained in Redis buffer queues;And inventory's rollback module retracts the token got to Redis When in buffer queue, if there are multiple rollback operations to ask simultaneously, block waiting, to ensure that all token retract successfully.
Figure 13 is the main portion for the system that inventory precisely reduces that kills the second of high concurrent fast-response according to embodiments of the present invention The schematic diagram divided.
As shown in figure 13, the second of the high concurrent fast-response of the embodiment of the present invention, it is main to kill the system 130 that inventory precisely reduces Including:Memory 131 and processor 132, wherein, memory 131 is for storing instruction;Processor 132 is configured as according to institute It states instruction and performs following action:According to the stockpile number of the second activity of killing, initialization generation corresponding number has unique sign value Token, and the token is stored in Redis buffer queues;If according to user purchase request, team is cached from Redis Token is got in row, then user information is inserted into order database, inventory reduces success, the user if being inserted into successfully Information includes user identity information and user's order placement information;If being inserted into failure, inventory reduces unsuccessfully, by the token of acquisition It retracts to Redis buffer queues.
From the above, it can be seen that under by rushing to purchase scene in the user of high concurrent big flow, using buffer queue and Token technologies with unique sign value realize that the second of quick response kills inventory and accurately reduces, so as to effectively solve to sell less Or oversold problem;Token is stored by using Hash table, strategy is purchased with threshold so as to realize, same user is avoided to buy The phenomenon that multiple;By the way that when user information is inserted into order database and fails, token is retracted into buffer queue, so as to Effectively to avoid selling the generation of phenomenon less;By using optimism lock and obstruction waiting mechanism, it thereby may be ensured that token is obtained The accuracy to retract with token.
Above-mentioned specific embodiment, does not form limiting the scope of the invention.Those skilled in the art should be bright It is white, depending on design requirement and other factors, various modifications, combination, sub-portfolio and replacement can occur.It is any Modifications, equivalent substitutions and improvements made within the spirit and principles in the present invention etc., should be included in the scope of the present invention Within.

Claims (13)

1. a kind of second of high concurrent fast-response kills the method that inventory precisely reduces, which is characterized in that including:
According to the stockpile number of the second activity of killing, initialization generates the token with unique sign value of corresponding number, and by described in Token is stored in Redis buffer queues;
If according to user purchase request, token is got from Redis buffer queues, then user information is inserted into order numbers According to library, inventory reduces success if being inserted into successfully, and the user information includes user identity information and user's order placement information;
If being inserted into failure, inventory reduces unsuccessfully, the token of acquisition is retracted to Redis buffer queues.
2. according to the method described in claim 1, it is characterized in that, the method further includes:It is obtained from Redis buffer queues To after token, user is obtained in record deposit token distributing lists, the user obtains record and includes user identity information And the token obtained.
3. according to the method described in claim 2, it is characterized in that, the method further includes:If being inserted into failure, removing will obtain To token retract to except Redis buffer queues, corresponding user also is obtained record deletes from token distributing lists.
4. according to the method described in claim 2, it is characterized in that, the method further includes:User is obtained into record deposit Before in token distributing lists, user identity information is verified, if the user identity information is present in token distributing lists, Prompting is reduced unsuccessfully, and is not preserved the user and obtained record, and the token got is retracted to Redis buffer queues In.
5. according to the method described in claim 2, it is characterized in that, the token distributing lists are Redis Hash tables.
6. according to claim 1-5 any one of them methods, which is characterized in that the method further includes:
Using optimistic lock mechanism, synchronization only handles an operation that token is obtained from Redis buffer queues;And
When the token got is retracted into Redis buffer queues, if there is multiple rollback operations to ask simultaneously, obstruction etc. It treats, to ensure that all token retract successfully.
7. a kind of second of high concurrent fast-response kills the device that inventory precisely reduces, which is characterized in that including:
Inventory's initialization module, for the stockpile number according to the second activity of killing, initialization generates the token of corresponding number, and will The token is stored in Redis buffer queues;
Inventory reduces module, if for according to user purchase request, token is got from Redis buffer queues, then will be used Family information is inserted into order database, and inventory reduces success if being inserted into successfully, the user information including user identity information with And user's order placement information;
Inventory's rollback module, if failing for being inserted into, inventory reduces unsuccessfully, and the token of acquisition is retracted and caches team to Redis Row.
8. device according to claim 7, which is characterized in that the inventory reduces module and is additionally operable to:Team is cached from Redis After getting token in row, user is obtained in record deposit token distributing lists, the user obtains record and includes user Identification information and the token of acquisition.
9. device according to claim 8, which is characterized in that described device is additionally operable to:
It is described other than inventory's rollback module retracts the token got to Redis buffer queues if being inserted into failure Inventory reduces module and also deletes corresponding user acquisition record from token distributing lists.
10. device according to claim 8, which is characterized in that described device further includes:With threshold purchase module, for Inventory reduce module by user obtain record deposit token distributing lists in before, verify user identity information, if the user mark Know information to be present in token distributing lists, then prompting is reduced unsuccessfully, and the inventory reduces module and not preserves the user and obtain Record is taken, and the token got is retracted into Redis buffer queues by inventory's rollback module.
11. device according to claim 8, which is characterized in that the token distributing lists are Redis Hash tables.
12. according to claim 7-11 any one of them devices, which is characterized in that described device is additionally operable to:
The inventory reduces module using optimistic lock mechanism, and synchronization only handles one and obtained from Redis buffer queues The operation of token;And
When inventory's rollback module retracts the token got into Redis buffer queues, if there is multiple behaviour that retract simultaneously It asks, then blocks waiting, to ensure that all token retract successfully.
13. a kind of second of high concurrent fast-response kills the system that inventory precisely reduces, which is characterized in that including:Memory and processing Device, wherein,
The memory is for storing instruction;
The processor is configured as performing following action according to described instruction:
According to the stockpile number of the second activity of killing, initialization generates the token with unique sign value of corresponding number, and by described in Token is stored in Redis buffer queues;
If according to user purchase request, token is got from Redis buffer queues, then user information is inserted into order numbers According to library, inventory reduces success if being inserted into successfully, and the user information includes user identity information and user's order placement information;
If being inserted into failure, inventory reduces unsuccessfully, the token of acquisition is retracted to Redis buffer queues.
CN201611085964.6A 2016-11-30 2016-11-30 High-concurrency quick-response method, device and system for accurately deducting second-killing inventory Active CN108133399B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611085964.6A CN108133399B (en) 2016-11-30 2016-11-30 High-concurrency quick-response method, device and system for accurately deducting second-killing inventory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611085964.6A CN108133399B (en) 2016-11-30 2016-11-30 High-concurrency quick-response method, device and system for accurately deducting second-killing inventory

Publications (2)

Publication Number Publication Date
CN108133399A true CN108133399A (en) 2018-06-08
CN108133399B CN108133399B (en) 2021-01-26

Family

ID=62387935

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611085964.6A Active CN108133399B (en) 2016-11-30 2016-11-30 High-concurrency quick-response method, device and system for accurately deducting second-killing inventory

Country Status (1)

Country Link
CN (1) CN108133399B (en)

Cited By (37)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109191233A (en) * 2018-07-31 2019-01-11 上海哔哩哔哩科技有限公司 A kind of second kills lower single request processing method, device and storage medium
CN109582738A (en) * 2018-12-03 2019-04-05 广东鸭梨科技集团股份有限公司 A kind of processing high concurrent second kills movable method
CN110189158A (en) * 2019-04-16 2019-08-30 德邦物流股份有限公司 A kind of logistics billing method and system based on charging regulation engine
CN110333951A (en) * 2019-07-09 2019-10-15 北京首汽智行科技有限公司 A kind of commodity panic buying request distribution method
CN110347692A (en) * 2019-06-03 2019-10-18 阿里巴巴集团控股有限公司 Inventory management method and device based on caching
CN110489694A (en) * 2019-07-30 2019-11-22 阿里巴巴集团控股有限公司 For handling the method and system of high concurrent request
CN110599277A (en) * 2018-06-12 2019-12-20 北京京东尚科信息技术有限公司 Inventory deduction method and device
CN110738507A (en) * 2018-07-18 2020-01-31 北京京东金融科技控股有限公司 exchange code acquisition method and device
CN110796401A (en) * 2018-08-03 2020-02-14 京东数字科技控股有限公司 Inventory deduction method, system and server
CN111176824A (en) * 2018-11-12 2020-05-19 商派软件有限公司 Method for processing high-concurrency activity registration
CN111177233A (en) * 2018-11-09 2020-05-19 商派软件有限公司 CAS inventory control method
CN111178998A (en) * 2018-11-09 2020-05-19 商派软件有限公司 Second killing platform and method for high access volume
CN111292028A (en) * 2018-12-06 2020-06-16 北京京东尚科信息技术有限公司 Inventory information processing method and system, computer system and readable storage medium
CN111309746A (en) * 2020-02-13 2020-06-19 贝壳技术有限公司 Asynchronous parallel data synchronization method and device
CN111324622A (en) * 2020-02-20 2020-06-23 中国建设银行股份有限公司 Resource first-aid-purchase processing method, device, equipment and storage medium
CN111506445A (en) * 2020-04-21 2020-08-07 北京思特奇信息技术股份有限公司 Method and system for preventing repeated malicious ordering of commodities based on REDIS cache
CN111582780A (en) * 2020-04-20 2020-08-25 重庆锐云科技有限公司 Commodity purchase waiting channel construction method and device, server and storage medium
CN112102044A (en) * 2020-11-10 2020-12-18 成都四方伟业软件股份有限公司 Method, system and device for processing high-concurrency second-killing commodities by message queue
CN112132662A (en) * 2020-09-28 2020-12-25 广州立白企业集团有限公司 Commodity second killing method and device, computer equipment and storage medium
CN112184326A (en) * 2020-10-14 2021-01-05 深圳市欢太科技有限公司 Method for processing high-concurrency killing activity, high-concurrency system, terminal and computer-readable storage medium
CN112347111A (en) * 2019-12-05 2021-02-09 北京沃东天骏信息技术有限公司 Data updating method and device
CN112416314A (en) * 2020-01-21 2021-02-26 上海哔哩哔哩科技有限公司 Dynamic inventory management method and system
CN112801753A (en) * 2021-02-09 2021-05-14 深圳市富途网络科技有限公司 Page display method, device and medium
CN112860746A (en) * 2021-02-01 2021-05-28 上海悦易网络信息技术有限公司 Cache reduction-based method, equipment and system
CN112988812A (en) * 2021-03-10 2021-06-18 京东数字科技控股股份有限公司 Inventory data processing method, device, equipment and storage medium
CN113034247A (en) * 2021-04-30 2021-06-25 中国工商银行股份有限公司 E-commerce platform inventory processing method and device
CN113077220A (en) * 2021-04-16 2021-07-06 北京京东拓先科技有限公司 User request processing method and device
CN113360570A (en) * 2021-05-31 2021-09-07 紫光云技术有限公司 High-concurrency system inventory module implementation method
CN113537852A (en) * 2020-04-14 2021-10-22 成都鼎桥通信技术有限公司 Second killing processing method and system
CN113742355A (en) * 2020-06-29 2021-12-03 北京沃东天骏信息技术有限公司 Method, device, equipment and computer readable medium for updating inventory
CN113760883A (en) * 2020-06-15 2021-12-07 北京沃东天骏信息技术有限公司 Method and device for sending shared variables and computer readable medium
CN113807760A (en) * 2021-01-07 2021-12-17 北京沃东天骏信息技术有限公司 Inventory information processing method and device, readable storage medium and electronic equipment
CN113836158A (en) * 2021-09-22 2021-12-24 上海哔哩哔哩科技有限公司 Commodity inventory deduction method and device
CN113887935A (en) * 2021-09-29 2022-01-04 中通服科信信息技术有限公司 High-concurrency service scene processing method, system and storage medium
CN114064722A (en) * 2021-11-15 2022-02-18 京东科技信息技术有限公司 Intelligent customer service flow processing method and device, electronic equipment and storage medium
CN114331576A (en) * 2021-12-30 2022-04-12 福建博思软件股份有限公司 Electronic ticket number rapid ticket taking method based on high concurrency scene and storage medium
CN112134808B (en) * 2020-07-21 2024-02-02 上海寻梦信息技术有限公司 Method and device for issuing bin allocation service speed control, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103426072A (en) * 2013-07-16 2013-12-04 无限极(中国)有限公司 Order processing system of high concurrency competitive inventory and processing method thereof
CN105139191A (en) * 2015-09-15 2015-12-09 联动优势电子商务有限公司 Method and device for obtaining order information
CN105303431A (en) * 2015-11-17 2016-02-03 张斌 Panic buying method of online shopping
CN106126673A (en) * 2016-06-29 2016-11-16 上海浦东发展银行股份有限公司信用卡中心 A kind of based on Redis and HBase point of locking method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103426072A (en) * 2013-07-16 2013-12-04 无限极(中国)有限公司 Order processing system of high concurrency competitive inventory and processing method thereof
CN103426072B (en) * 2013-07-16 2016-02-17 无限极(中国)有限公司 The order processing system of a kind of high concurrent competition stock and disposal route thereof
CN105139191A (en) * 2015-09-15 2015-12-09 联动优势电子商务有限公司 Method and device for obtaining order information
CN105303431A (en) * 2015-11-17 2016-02-03 张斌 Panic buying method of online shopping
CN106126673A (en) * 2016-06-29 2016-11-16 上海浦东发展银行股份有限公司信用卡中心 A kind of based on Redis and HBase point of locking method

Cited By (47)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110599277A (en) * 2018-06-12 2019-12-20 北京京东尚科信息技术有限公司 Inventory deduction method and device
CN110738507A (en) * 2018-07-18 2020-01-31 北京京东金融科技控股有限公司 exchange code acquisition method and device
CN109191233A (en) * 2018-07-31 2019-01-11 上海哔哩哔哩科技有限公司 A kind of second kills lower single request processing method, device and storage medium
CN109191233B (en) * 2018-07-31 2022-09-02 上海幻电信息科技有限公司 Second order-killing request processing method and device and storage medium
CN110796401A (en) * 2018-08-03 2020-02-14 京东数字科技控股有限公司 Inventory deduction method, system and server
CN111177233A (en) * 2018-11-09 2020-05-19 商派软件有限公司 CAS inventory control method
CN111178998A (en) * 2018-11-09 2020-05-19 商派软件有限公司 Second killing platform and method for high access volume
CN111176824B (en) * 2018-11-12 2021-04-20 商派软件有限公司 Method for processing high-concurrency activity registration
CN111176824A (en) * 2018-11-12 2020-05-19 商派软件有限公司 Method for processing high-concurrency activity registration
CN109582738A (en) * 2018-12-03 2019-04-05 广东鸭梨科技集团股份有限公司 A kind of processing high concurrent second kills movable method
CN111292028A (en) * 2018-12-06 2020-06-16 北京京东尚科信息技术有限公司 Inventory information processing method and system, computer system and readable storage medium
CN110189158A (en) * 2019-04-16 2019-08-30 德邦物流股份有限公司 A kind of logistics billing method and system based on charging regulation engine
CN110347692A (en) * 2019-06-03 2019-10-18 阿里巴巴集团控股有限公司 Inventory management method and device based on caching
CN110347692B (en) * 2019-06-03 2023-05-26 创新先进技术有限公司 Inventory management method and device based on cache
CN110333951B (en) * 2019-07-09 2023-08-01 北京首汽智行科技有限公司 Commodity purchase request distribution method
CN110333951A (en) * 2019-07-09 2019-10-15 北京首汽智行科技有限公司 A kind of commodity panic buying request distribution method
CN110489694A (en) * 2019-07-30 2019-11-22 阿里巴巴集团控股有限公司 For handling the method and system of high concurrent request
CN112347111A (en) * 2019-12-05 2021-02-09 北京沃东天骏信息技术有限公司 Data updating method and device
CN112416314A (en) * 2020-01-21 2021-02-26 上海哔哩哔哩科技有限公司 Dynamic inventory management method and system
CN111309746A (en) * 2020-02-13 2020-06-19 贝壳技术有限公司 Asynchronous parallel data synchronization method and device
CN111324622A (en) * 2020-02-20 2020-06-23 中国建设银行股份有限公司 Resource first-aid-purchase processing method, device, equipment and storage medium
CN113537852A (en) * 2020-04-14 2021-10-22 成都鼎桥通信技术有限公司 Second killing processing method and system
CN111582780A (en) * 2020-04-20 2020-08-25 重庆锐云科技有限公司 Commodity purchase waiting channel construction method and device, server and storage medium
CN111582780B (en) * 2020-04-20 2023-06-09 重庆锐云科技有限公司 Commodity purchase waiting channel construction method, device, server and storage medium
CN111506445A (en) * 2020-04-21 2020-08-07 北京思特奇信息技术股份有限公司 Method and system for preventing repeated malicious ordering of commodities based on REDIS cache
CN113760883A (en) * 2020-06-15 2021-12-07 北京沃东天骏信息技术有限公司 Method and device for sending shared variables and computer readable medium
CN113742355A (en) * 2020-06-29 2021-12-03 北京沃东天骏信息技术有限公司 Method, device, equipment and computer readable medium for updating inventory
CN112134808B (en) * 2020-07-21 2024-02-02 上海寻梦信息技术有限公司 Method and device for issuing bin allocation service speed control, electronic equipment and storage medium
CN112132662A (en) * 2020-09-28 2020-12-25 广州立白企业集团有限公司 Commodity second killing method and device, computer equipment and storage medium
CN112132662B (en) * 2020-09-28 2023-06-20 广州立白企业集团有限公司 Commodity second killing method and device, computer equipment and storage medium
CN112184326A (en) * 2020-10-14 2021-01-05 深圳市欢太科技有限公司 Method for processing high-concurrency killing activity, high-concurrency system, terminal and computer-readable storage medium
CN112102044B (en) * 2020-11-10 2021-03-09 成都四方伟业软件股份有限公司 Method, system and device for processing high-concurrency second-killing commodities by message queue
CN112102044A (en) * 2020-11-10 2020-12-18 成都四方伟业软件股份有限公司 Method, system and device for processing high-concurrency second-killing commodities by message queue
CN113807760A (en) * 2021-01-07 2021-12-17 北京沃东天骏信息技术有限公司 Inventory information processing method and device, readable storage medium and electronic equipment
CN112860746A (en) * 2021-02-01 2021-05-28 上海悦易网络信息技术有限公司 Cache reduction-based method, equipment and system
CN112860746B (en) * 2021-02-01 2023-04-07 上海万物新生环保科技集团有限公司 Cache reduction-based method, equipment and system
CN112801753B (en) * 2021-02-09 2024-04-23 深圳市富途网络科技有限公司 Page display method, device and medium
CN112801753A (en) * 2021-02-09 2021-05-14 深圳市富途网络科技有限公司 Page display method, device and medium
CN112988812A (en) * 2021-03-10 2021-06-18 京东数字科技控股股份有限公司 Inventory data processing method, device, equipment and storage medium
CN112988812B (en) * 2021-03-10 2024-02-06 京东科技控股股份有限公司 Inventory data processing method, device, equipment and storage medium
CN113077220A (en) * 2021-04-16 2021-07-06 北京京东拓先科技有限公司 User request processing method and device
CN113034247A (en) * 2021-04-30 2021-06-25 中国工商银行股份有限公司 E-commerce platform inventory processing method and device
CN113360570A (en) * 2021-05-31 2021-09-07 紫光云技术有限公司 High-concurrency system inventory module implementation method
CN113836158A (en) * 2021-09-22 2021-12-24 上海哔哩哔哩科技有限公司 Commodity inventory deduction method and device
CN113887935A (en) * 2021-09-29 2022-01-04 中通服科信信息技术有限公司 High-concurrency service scene processing method, system and storage medium
CN114064722A (en) * 2021-11-15 2022-02-18 京东科技信息技术有限公司 Intelligent customer service flow processing method and device, electronic equipment and storage medium
CN114331576A (en) * 2021-12-30 2022-04-12 福建博思软件股份有限公司 Electronic ticket number rapid ticket taking method based on high concurrency scene and storage medium

Also Published As

Publication number Publication date
CN108133399B (en) 2021-01-26

Similar Documents

Publication Publication Date Title
CN108133399A (en) The second of high concurrent fast-response kills the method, apparatus and system that inventory precisely reduces
CN106030533B (en) It is executed by split process and retries affairs automatically
CN103748555B (en) Multi-dimensional user request pattern fast supply virtual machine is based in cloud
CN107688487A (en) For the method and system for the state for recovering database session
CN105468293B (en) Pass through the method and system of m- pages of raising flash memory utilization rate of prediction damage
US9727600B2 (en) Data consistency management
CN105144158B (en) The recovery processing method and system of detection are write using demolition
EP3173945A1 (en) Transactional cache invalidation for inter-node caching
US20160212206A1 (en) Deterministic database system and data transferring method thereof
US20110276550A1 (en) Fine grain synchronization for database replay
JPH04229344A (en) Method for supporting sequential batch application using continuous restartable cursor
JP6877435B2 (en) Database operation method and equipment
DE112019000143T5 (en) VERSIONING VALIDATION FOR DATA TRANSFER BETWEEN HETEROGENIC DATA MEMORIES
US20200012779A1 (en) System and method for tracking and authenticating code transition during phases of development and deployment
US11157247B2 (en) Cryptographic digital twin segregation system for development operations
ES2805755T3 (en) System and method for session synchronization with independent external systems
KR101690288B1 (en) Method and system of storing and retrieving data
US20070136277A1 (en) System for and method of extracting and clustering information
WO2020060629A1 (en) Techniques for updating big data tables using snapshot isolation
US7752399B2 (en) Exclusion control method and information processing apparatus
Turcu et al. On open nesting in distributed transactional memory
CN107277022A (en) Processes Tag method and device
KR20160130489A (en) Cube reconstruction method and apparatus in multidimensional online analytical processing system
CN104391845B (en) A kind of method and device generating database script
CN106021597A (en) Data sheet updating method and system for account transactions

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
GR01 Patent grant
GR01 Patent grant