nginx-based flash sale control method, system and electronic device

By synchronizing the inventory of flash kill objects to nginx instances and controlling the inventory deduction logic based on flash kill requests, the existing flash kill system cannot fully utilize the advantages of nginx and high operation and maintenance costs, and achieves the flash kill effect of high concurrency, low cost and high user experience.

CN111461805BActive Publication Date: 2025-05-23BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201910054590.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-01-21
Publication Date
2025-05-23
Estimated Expiration
2039-01-21

AI Technical Summary

Technical Problem

The existing flash sale system cannot fully utilize the advantages of nginx, and the operation and maintenance costs are high and there are flash sale hot issues, resulting in poor user experience.

Method used

By synchronizing the inventory of flash kill objects to nginx instances and controlling the inventory deduction logic of nginx instances according to flash kill requests, high concurrency and high-performance inventory management is achieved. At the same time, by evenly distributing inventory and real-time scheduling, we eliminate flash-kill hot spots and reduce operation and maintenance costs.

Benefits of technology

Effectively utilize the advantages of nginx, reduce operation and maintenance costs, eliminate flash sales hotspots, improve user experience, and improve the overall throughput of flash sales services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111461805B_ABST
    Figure CN111461805B_ABST
Patent Text Reader

Abstract

The present invention discloses a flash sale control method, system and electronic device based on nginx. The flash sale control method comprises the following steps: reading the information of the published flash sale object, the information of the flash sale object including the inventory of the flash sale object; synchronizing the inventory to the nginx instance; receiving the flash sale request of the user for the flash sale object; controlling the nginx instance to execute the deduction logic of the inventory according to the flash sale request, wherein the deduction inventory quantity in the deduction logic corresponds to the quantity of the flash sale object in the flash sale request. The technical solution of the present invention can realize high concurrency and high performance inventory deduction logic only through nginx, which maximizes the advantages of nginx itself, and there is no redis access, which effectively saves operation and maintenance costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an nginx-based flash sale control method, system and electronic equipment. Background Art

[0002] In order to increase business growth and active users, e-commerce websites often need to launch flash sales to attract users to visit the website. When designing a flash sales system, the most important thing is to ensure that the system is stable when a large amount of traffic arrives, that the flash sales items are not oversold, and that the flash sales are fair.

[0003] The existing technology usually uses nginx+redis architecture to design the flash sale system, using nginx to achieve high concurrency to ensure that the flash sale system will not be overwhelmed by the sudden large flow; using redis (remote dictionary server) to achieve high performance and atomic inventory deduction. However, the number of flash sale objects in the same period is usually not large, and the inventory is small. The duration of the entire flash sale process is very short, and once the limited number of products are sold out, the entire flash sale activity is over.

[0004] Based on the architecture of the flash sale system in the prior art, on the one hand, nginx does very little front-end logic (for example, limiting traffic, controlling traffic, etc.), and does not bring the advantages of nginx to the extreme; on the other hand, when using redis, it is necessary to maintain the redis cluster. During the idle period of the flash sale, the redis server is wasted, increasing the operation and maintenance cost. In addition, there will be the problem of flash sale hotspots. If the inventory of the flash sale objects is unevenly scheduled, it is likely to cause the flash sale service to crash, seriously affecting the user experience.

[0005] How to make full use of the advantages of nginx itself to complete the flash sale process, effectively eliminate flash sale hotspots, and improve the overall throughput of the flash sale service is an urgent problem to be solved. Summary of the invention

[0006] The technical problem to be solved by the embodiments of the present invention is to overcome the defects in the prior art that the flash sale system cannot fully utilize the advantages of nginx itself and has high operation and maintenance costs, and to provide a flash sale control method, system and electronic device based on nginx.

[0007] The embodiment of the present invention solves the above technical problems through the following technical solutions:

[0008] A flash sale control method based on nginx, the flash sale control method comprising the following steps:

[0009] Reading information of a published flash sale object, wherein the information of the flash sale object includes the inventory of the flash sale object;

[0010] Synchronize the inventory to the nginx instance;

[0011] Receiving a flash sale request from a user for the flash sale object;

[0012] The nginx instance is controlled to execute the deduction logic of the inventory according to the flash sale request, wherein the deduction inventory quantity in the deduction logic corresponds to the quantity of the flash sale objects in the flash sale request.

[0013] Preferably, the number of the nginx instances is multiple;

[0014] The step of synchronizing the inventory to the nginx instance specifically includes:

[0015] Allocate the inventory to each of the nginx instances according to a preset ratio, so that each of the nginx instances has a distributed inventory;

[0016] The step of controlling the nginx instance to execute the inventory deduction logic according to the flash sale request specifically includes:

[0017] According to the flash sale request, one or more nginx instances are controlled to execute the deduction logic of the sub-inventory.

[0018] Preferably, the step of allocating the inventory to each of the nginx instances according to a preset ratio specifically includes:

[0019] The inventory is evenly distributed to each of the nginx instances so that each of the nginx instances has an equal amount of the sub-inventory.

[0020] Preferably, the evenly distributing the inventory to each of the nginx instances further includes the steps of:

[0021] The sub-inventory in the nginx instance is scheduled at preset time intervals to keep the sub-inventory equal in each of the nginx instances, wherein the scheduling includes increasing the sub-inventory, decreasing the sub-inventory, or maintaining the sub-inventory unchanged.

[0022] Preferably, after the step of scheduling the sub-inventory in the nginx instance at preset intervals, the step further includes:

[0023] A scheduling log for scheduling the sub-inventory is generated.

[0024] Preferably, the flash sale control method further includes:

[0025] Determine whether the flash sale duration of the flash sale object is greater than a preset expiration time;

[0026] If the judgment is yes, the nginx instance is controlled to delete the information of the flash sale object.

[0027] Preferably, the step of controlling the nginx instance to execute the inventory deduction logic according to the flash sale request specifically includes:

[0028] Determine whether the difference between the time when the flash sale request occurs and the preset flash sale time is greater than a preset threshold;

[0029] If the judgment is no, delaying the preset flash sale time by a preset adjustment value to obtain the time for executing the flash sale operation;

[0030] Determine whether the current time reaches the time for executing the flash sale operation;

[0031] If the judgment is yes, the nginx instance is controlled to execute the deduction logic of the inventory.

[0032] Preferably, the flash sale control method further comprises:

[0033] Receiving an order cancellation instruction, wherein the order cancellation instruction includes the quantity of the flash sale objects in the order to be cancelled;

[0034] The inventory is adjusted according to the quantity of the flash sale object in the cancelled order.

[0035] In order to solve the above technical problems, an embodiment of the present invention further provides a second sale control system based on nginx, and the second sale control system includes:

[0036] An information reading module, used to read information of a published flash sale object, wherein the information of the flash sale object includes the inventory of the flash sale object;

[0037] An inventory synchronization module, used to synchronize the inventory to an nginx instance;

[0038] A flash sale request receiving module, used to receive a flash sale request from a user for the flash sale object;

[0039] The inventory deduction module is used to control the nginx instance to execute the inventory deduction logic according to the flash sale request, wherein the deduction inventory quantity in the deduction logic corresponds to the quantity of the flash sale objects in the flash sale request.

[0040] Preferably, the number of the nginx instances is multiple;

[0041] The inventory synchronization module includes an inventory allocation submodule, and the inventory allocation submodule is used to allocate the inventory to each of the nginx instances according to a preset ratio, so that each of the nginx instances has a sub-inventory;

[0042] The inventory deduction module includes a deduction control submodule, and the deduction control submodule is used to control one or more nginx instances to execute the deduction logic of the sub-inventory according to the flash sale request.

[0043] Preferably, the inventory allocation submodule comprises an inventory allocation unit, and the inventory allocation unit is used to evenly allocate the inventory to each of the nginx instances so that each of the nginx instances has equal sub-inventory.

[0044] Preferably, the second sale control system further comprises:

[0045] The inventory scheduling module is used to schedule the sub-inventory in the nginx instance at preset intervals so that the sub-inventory is kept equal in each nginx instance, wherein the scheduling includes increasing the sub-inventory, decreasing the sub-inventory or maintaining the sub-inventory unchanged.

[0046] Preferably, the second sale control system further includes:

[0047] The scheduling log generation module is used to generate a scheduling log for scheduling the sub-inventory.

[0048] Preferably, the second sale control system further includes:

[0049] An expiration judgment module, used to judge whether the flash sale duration of the flash sale object is greater than a preset expiration time;

[0050] If the judgment is yes, then the information deletion module is called, and the information deletion module is used to control the nginx instance to delete the information of the flash sale object.

[0051] Preferably, the inventory deduction module includes:

[0052] The first judgment submodule is used to judge whether the difference between the time when the flash sale request occurs and the preset flash sale time is greater than a preset threshold;

[0053] If the judgment is no, then calling the delay submodule, the delay submodule is used to delay the preset flash sale time by a preset adjustment value to obtain the time for executing the flash sale operation;

[0054] The second judgment submodule is used to judge whether the current time reaches the time for executing the flash sale operation;

[0055] If the judgment is yes, the deduction execution submodule is called, and the deduction execution submodule is used to control the nginx instance to execute the deduction logic of the inventory.

[0056] Preferably, the second sale control system further includes:

[0057] An instruction receiving module, configured to receive an order cancellation instruction, wherein the order cancellation instruction includes the quantity of the flash sale objects in the order to be cancelled;

[0058] The inventory adjustment module is used to adjust the inventory according to the quantity of the flash sale object in the cancelled order.

[0059] To solve the above technical problems, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the nginx-based flash sale control method when executing the computer program.

[0060] To solve the above technical problems, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the nginx-based flash sale control method are implemented.

[0061] The positive improvement effects of the embodiments of the present invention are:

[0062] The embodiment of the present invention synchronizes the inventory of the flash sale object to the nginx instance, and after receiving the flash sale request of the user for the flash sale object, controls the nginx instance to execute the deduction logic of the inventory according to the flash sale request. Therefore, high concurrency and high performance inventory deduction logic can be implemented only through nginx, which maximizes the advantages of nginx itself, and there is no redis access, which effectively saves operation and maintenance costs.

[0063] Furthermore, the embodiment of the present invention can evenly distribute the inventory of the flash sale object to each nginx instance, so that each of the nginx instances has an equal sub-inventory; then, one or more of the nginx instances can be controlled to execute the deduction logic of the sub-inventory according to the flash sale request. Thus, the flash sale hotspots can be eliminated by deducting the inventory of multiple nginx instances, avoiding the downtime of the flash sale service caused by uneven inventory scheduling of the flash sale object, and improving the user experience.

[0064] Furthermore, the embodiment of the present invention schedules the sub-inventory in the nginx instance at preset intervals to keep the sub-inventory equal in each nginx instance. Thus, the real-time inventory scheduling mechanism ensures that the inventory of each nginx instance is uniform during the flash sale activity, further reducing the risk of flash sale service downtime.

[0065] Furthermore, the embodiment of the present invention determines whether the difference between the time when the flash sale request occurs and the preset flash sale time is greater than a preset threshold; if the judgment is not, the preset flash sale time is delayed by a preset adjustment value to obtain the time when the flash sale operation is executed; then, when the current time reaches the time when the flash sale operation is executed, the nginx instance is controlled to execute the inventory deduction logic. Therefore, by delaying the flash sale time, it is ensured that users with slower networks also have the opportunity to buy products in flash sales, which effectively improves the randomness and fairness of flash sales. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] Figure 1 This is a flow chart of a flash sale control method based on nginx in Example 1 of the present invention;

[0067] Figure 2 It is a flowchart of a non-limiting specific implementation method of a flash sale control method based on nginx in Example 1 of the present invention;

[0068] Figure 3 is a flowchart of another non-limiting specific implementation method of a flash sale control method based on nginx in Example 1 of the present invention;

[0069] Figure 4 This is a flow chart of a flash sale control method based on nginx according to Embodiment 2 of the present invention;

[0070] Figure 5 This is a flow chart of a flash sale control method based on nginx according to Embodiment 3 of the present invention;

[0071] Figure 6 This is a structural block diagram of a seckilling control system based on nginx according to Embodiment 4 of the present invention;

[0072] Figure 7 This is a structural block diagram of a seckilling control system based on nginx according to Embodiment 5 of the present invention;

[0073] Figure 8 This is a structural block diagram of a seckilling control system based on nginx according to Embodiment 6 of the present invention;

[0074] Fig. 9 It is a structural diagram of an electronic device for implementing an nginx-based flash sale control method according to embodiment 7 of the present invention. DETAILED DESCRIPTION

[0075] The present invention is further described below by way of examples, but the present invention is not limited to the scope of the examples.

[0076] Example 1

[0077] A method for controlling spikes based on nginx, such as Figure 1-3 As shown, the flash sale control method may include the following steps:

[0078] Step S11: reading the information of the published flash sale object, wherein the information of the flash sale object includes the inventory of the flash sale object;

[0079] Step S12: Synchronize the inventory to the nginx instance;

[0080] Step S13: receiving a flash sale request from a user for the flash sale object;

[0081] Step S14: controlling the nginx instance to execute the inventory deduction logic according to the flash sale request, wherein the inventory deduction quantity in the deduction logic corresponds to the quantity of the flash sale objects in the flash sale request.

[0082] The nginx is a lightweight, high-performance server that can support reverse proxy and email proxy, etc., and supports high concurrent data traffic.

[0083] The so-called flash sale refers to a sales method in which when an online seller releases some low-priced goods, all buyers rush to buy them online at the same time.

[0084] In this embodiment, the flash sale objects may be flash sale products released by online sellers, and the flash sale products may involve various categories, such as clothes, food, household appliances, etc.

[0085] Specifically, after the online merchant edits and publishes the information of the flash sale products, the flash sale product information is added to the flash sale product message queue, and the flash sale product message queue can store the information of the flash sale products. The information of the flash sale products may include the total inventory of the flash sale products and the newly added inventory of the flash sale products. The inventory of the flash sale products refers to the number of flash sale products that can be effectively flash sold.

[0086] Furthermore, the newly added inventory may be a positive number, a negative number or 0.

[0087] Specifically, when the newly added inventory is a positive number, the total inventory is increased based on the original total inventory; when the newly added inventory is a negative number, the total inventory is decreased based on the original total inventory; and when the newly added inventory is 0, the total inventory is equal to the original total inventory.

[0088] Next, the inventory of the flash sale product may be synchronized to the nginx instance, that is, the inventory information of the flash sale product may be stored in the nginx instance.

[0089] Furthermore, the nginx instance may be one or more.

[0090] Preferably, the number of nginx instances can be set to multiple, and the multiple nginx instances form an nginx cluster to jointly complete the flash sale task.

[0091] As a non-limiting implementation in this embodiment, the step S12 may specifically include step S121: allocating the inventory to each of the nginx instances according to a preset ratio, so that each of the nginx instances has a distributed inventory.

[0092] Inventories can be allocated to different nginx instances based on their operating performance (e.g., the number of messages processed per unit time, data processing speed, etc.). In other words, a larger proportion of sub-inventory can be allocated to nginx instances with good operating performance, and a smaller proportion of sub-inventory can be allocated to nginx instances with poor operating performance.

[0093] In addition, to facilitate operation, maintenance and control, you can also select multiple nginx instances with the same operating performance to form an nginx cluster.

[0094] As another non-limiting implementation in this embodiment, preferably, the step S12 may specifically include step S122: evenly distributing the inventory to each of the nginx instances, so that each of the nginx instances has equal sub-inventory.

[0095] It is understandable that those skilled in the art can adaptively set the number of nginx instances constituting the nginx cluster according to the specific operation and maintenance costs and the requirements of the application scenarios, and the embodiments of the present invention do not limit this.

[0096] When storing data, each nginx instance can store the inventory information of a specific product according to the data structure of [product ID, total inventory, total inventory of the current instance, deducted inventory], and can adjust the inventory information in the data structure according to the newly added inventory in the flash sale product message queue.

[0097] Preferably, the inventory information may be stored in a shared dictionary in an nginx instance, where the shared dictionary is a component in the nginx instance that may store memory data.

[0098] It should be noted that the content and order of the data structure in which the nginx instance stores inventory information can be adjusted according to specific needs, and the embodiment of the present invention does not limit this.

[0099] Next, when the user clicks on the flash sale object, for example, when the user clicks on the "buy" button corresponding to the flash sale product in the webpage or APP, it indicates that the user has issued a flash sale request for the flash sale object.

[0100] According to the flash sale request, the nginx instance is controlled to execute the deduction logic of the inventory. When there are multiple nginx instances, one or more nginx instances can be controlled to execute the deduction logic of the sub-inventory according to the flash sale request. The deduction inventory quantity in the deduction logic corresponds to the quantity of the flash sale objects in the flash sale request.

[0101] When the deduction logic is successfully executed, an inventory deduction log will be generated. The log structure can be: [time, user ID, inventory ID, total inventory, current instance inventory, current deduction inventory]. By recording the log, the inventory deduction can be traced back, so that when a problem occurs, it can be traced back according to the log.

[0102] Next, step S15 may be executed: generating an order. Specifically, an order may be generated by using parameters [time, user ID, product ID, inventory ID, deduction of inventory]. After the order is generated, the user may be waited to complete payment for the order within a preset payment time.

[0103] If the user fails to complete the payment within the preset payment time or issues a cancellation instruction for the order, it indicates that the order has failed. Specifically, the data structure of the cancellation instruction may be [order number, canceled inventory quantity].

[0104] If the order is cancelled, the inventory can be adjusted according to the quantity of the flash sale objects in the cancelled order, and the inventory can be rolled back to the nginx cluster again.

[0105] Specifically, inventory rollback can be achieved by using the instruction incr_N written in the scripting language lua embedded in nginx.

[0106] Furthermore, the flash sale control method may also include the following steps:

[0107] Step S16: Determine whether the flash sale duration of the flash sale object is greater than a preset expiration time;

[0108] If the judgment is yes, execute step S17: control the nginx instance to delete the information of the flash sale object.

[0109] Those skilled in the art can flexibly set the length of the preset expiration time according to different types of flash sale activities and different types of goods, and can adaptively adjust the preset expiration time of the next flash sale activity according to the effect of this activity, and the embodiments of the present invention are not limited to this.

[0110] The embodiment of the present invention can realize high-concurrency and high-performance inventory deduction logic only through nginx, which maximizes the advantages of nginx itself, and there is no access to redis, which effectively saves operation and maintenance costs; in addition, by evenly distributing the inventory of the flash sale object to each nginx instance, each of the nginx instances has an equal inventory. Therefore, the flash sale hotspots can be eliminated through the inventory deductions of multiple nginx instances, avoiding the downtime of the flash sale service caused by uneven inventory scheduling of the flash sale objects, and improving the user experience. Furthermore, this embodiment can delete expired flash sale product information in a timely manner, saving storage space, and reducing the interference of redundant product information on the operating performance of nginx.

[0111] Example 2

[0112] A method for controlling spikes based on nginx, such as Figure 4 As shown, the flash sale control method in this embodiment is a further improvement based on embodiment 1.

[0113] Furthermore, step S122 may also include step S123: scheduling the sub-inventory in the nginx instance at preset time intervals so that the sub-inventory is maintained equal in each of the nginx instances, wherein the scheduling includes increasing the sub-inventory, decreasing the sub-inventory, or maintaining the sub-inventory unchanged.

[0114] In this embodiment, the preset time can be set to 30-200ms, preferably, the preset time is 100ms.

[0115] Furthermore, in order to ensure that the execution process of each scheduling is traceable, the step S123 may further include a step S124: generating a scheduling log for scheduling the sub-inventory.

[0116] When the scheduling is specifically performed, atomic deduction scheduling can be performed in units of m inventories, and the scheduling inventory deduction logic of all nginx instances is executed at the same time, where m is a positive integer. Preferably, the value of m is 10.

[0117] In this embodiment, the number of schedulable inventory is counted based on the schedulable inventory of each nginx instance and the inventory information of the current instance. For an nginx instance, the schedulable inventory refers to the inventory that can be adjusted to other nginx instances. The scheduling process can be completed only in the local intranet, and the logic is very simple. Each scheduling can be completed within milliseconds to ensure fast and timely scheduling.

[0118] Furthermore, the total amount of the inventory may be verified at preset verification time intervals to ensure that there is no problem that a product is successfully sold out but the inventory is not deducted accordingly due to network failure or other reasons.

[0119] In this embodiment, the preset verification time may be 50-200 ms, and preferably, the preset verification time is 100 ms.

[0120] When the verification process finds an inventory deduction error, the local log of each nginx instance and the scheduling log are checked. If the test result shows that the inventory in a certain nginx instance has been deducted but has not been correctly identified as deducted, the next round of scheduling process can be used to replenish the inventory in the nginx instance that has been deducted but has not been correctly identified as deducted, to ensure that each nginx instance has equal inventory and that the remaining inventory in the nginx instance meets the inventory reserve requirements for the flash sale.

[0121] This embodiment ensures that the inventory of each nginx instance is uniform and sufficient during the flash sale activity through real-time inventory scheduling and inventory verification, further reducing the risk of flash sale service downtime.

[0122] Example 3

[0123] A method for controlling spikes based on nginx, such as Figure 5 As shown, the flash sale control method in this embodiment is a further improvement based on embodiment 1 or embodiment 2.

[0124] In order to further improve the randomness and fairness of the flash sale, the step S14 may be improved. The step S14 may be performed according to the following specific steps:

[0125] Step S141: Determine whether the difference between the time when the flash sale request occurs and the preset flash sale time is greater than a preset threshold;

[0126] If the judgment is no, then executing step S142: delaying the preset flash sale time by a preset adjustment value to obtain the time for executing the flash sale operation;

[0127] Step S143: determining whether the current time has reached the time for executing the flash sale operation;

[0128] If the judgment is yes, execute step S144: control the nginx instance to execute the deduction logic of the inventory.

[0129] In specific implementation, if the current time has not reached the preset flash sale time, it will return that the flash sale time has not yet arrived. If it is close to the preset flash sale time or has reached the preset flash sale time, the above-mentioned delay process can be performed.

[0130] As a non-limiting implementation in this embodiment, for example, the preset threshold value can be set to 2s. When the difference is less than or equal to 2s, the preset flash sale time can be delayed by the delay instruction ngx.sleep written in the script language lua embedded in nginx to obtain the execution time of the flash sale operation. In other words, after adding the delay, the inventory deduction logic is not executed at the preset flash sale time, but is executed at the time when the flash sale operation is executed.

[0131] Preferably, the execution time of the flash sale operation can be set to: preset flash sale time - current time + a random number within 1000ms.

[0132] It is understandable that the preset threshold value can be dynamically adjusted to meet the needs of different flash sale occasions, for example, the flash sale threshold value can also be set to 1s, 3s, 4.5s, 6s, etc. The embodiment of the present invention is not limited to this.

[0133] In this embodiment, after the preset flash sale time is delayed, it can be ensured that users with slower networks or users who are far away from the server also have the opportunity to buy products in flash sales, which effectively improves the randomness and fairness of flash sales and improves user experience.

[0134] Example 4

[0135] A seckill control system based on nginx, please refer to Figure 6 , the second sale control system 1 may include:

[0136] An information reading module 2 is used to read the information of the published flash sale object, wherein the information of the flash sale object includes the inventory of the flash sale object;

[0137] An inventory synchronization module 3, used to synchronize the inventory to the nginx instance;

[0138] A flash sale request receiving module 4, configured to receive a flash sale request from a user for the flash sale object;

[0139] The inventory deduction module 5 is used to control the nginx instance to execute the inventory deduction logic according to the flash sale request, wherein the deduction inventory quantity in the deduction logic corresponds to the quantity of the flash sale objects in the flash sale request.

[0140] Furthermore, the number of the nginx instances may be multiple;

[0141] The inventory synchronization module 3 may include an inventory allocation submodule 31, and the inventory allocation submodule 31 is used to allocate the inventory to each of the nginx instances according to a preset ratio, so that each of the nginx instances has a sub-inventory;

[0142] The inventory deduction module 5 may include a deduction control submodule 51, and the deduction control submodule 51 is used to control one or more nginx instances to execute the deduction logic of the sub-inventory according to the flash sale request.

[0143] Furthermore, the inventory allocation submodule 31 may include an inventory allocation unit 311, and the inventory allocation unit 311 is used to evenly allocate the inventory to each of the nginx instances, so that each of the nginx instances has equal sub-inventory.

[0144] Furthermore, the second sale control system 1 may also include:

[0145] An instruction receiving module 8 is used to receive an order cancellation instruction, wherein the cancellation instruction includes the number of the flash sale objects in the canceled order;

[0146] The inventory adjustment module 9 is used to adjust the inventory according to the quantity of the flash sale objects in the cancelled order.

[0147] Furthermore, the second sale control system 1 may also include:

[0148] An expiration judgment module 6 is used to judge whether the flash sale duration of the flash sale object is greater than a preset expiration time;

[0149] If the judgment is yes, the information deletion module 7 is called, and the information deletion module 7 is used to control the nginx instance to delete the information of the flash sale object.

[0150] For more details about the working principle and working mode of the control system in Example 4, please refer to the relevant description of the control method in Example 1, which will not be repeated here.

[0151] The control system in the embodiment of the present invention can realize high-concurrency and high-performance inventory deduction logic only through nginx during operation, which can not only maximize the advantages of nginx itself, but also effectively save operation and maintenance costs without redis access; in addition, by evenly distributing the inventory of the flash sale object to each nginx instance, so that each of the nginx instances has equal sub-inventory. Thus, the flash sale hotspots can be eliminated through the inventory deductions of multiple nginx instances, avoiding the downtime of the flash sale service caused by uneven inventory scheduling of the flash sale objects, and improving the user experience. Furthermore, this embodiment can delete expired flash sale product information in a timely manner, saving storage space, and reducing the interference of redundant product information on the operating performance of nginx.

[0152] Example 5

[0153] A seckill control system based on nginx, please refer to Figure 7 This embodiment 5 is a further improvement on the basis of embodiment 4. The second-sale control system 1 may also include:

[0154] The inventory scheduling module 10 is used to schedule the sub-inventory in the nginx instance at preset intervals so as to maintain equal sub-inventory in each nginx instance, wherein the scheduling includes increasing the sub-inventory, decreasing the sub-inventory or maintaining the sub-inventory unchanged.

[0155] Furthermore, the second sale control system 1 may also include:

[0156] The scheduling log generating module 11 is used to generate a scheduling log for scheduling the sub-inventory.

[0157] For more details about the working principle and working mode of the control system in Example 5, please refer to the relevant description of the control method in Example 2, which will not be repeated here.

[0158] When the control system in the embodiment of the present invention is running, it can ensure that the inventory of each nginx instance is uniform during the flash sale activity through a real-time inventory scheduling mechanism, further reducing the risk of flash sale service downtime.

[0159] Example 6

[0160] A seckill control system based on nginx, please refer to Figure 8 , this embodiment 6 is a further improvement based on embodiment 4 or embodiment 5.

[0161] Specifically, the inventory deduction module 5 may include:

[0162] The first judgment submodule 52 is used to judge whether the difference between the time when the flash sale request occurs and the preset flash sale time is greater than a preset threshold;

[0163] If the judgment is no, then the delay submodule 53 is called, and the delay submodule 53 is used to delay the preset flash sale time by a preset adjustment value to obtain the time for executing the flash sale operation;

[0164] The second judgment submodule 54 is used to judge whether the current time reaches the time for executing the flash sale operation;

[0165] If the judgment is yes, the deduction execution submodule 55 is called, and the deduction execution submodule 55 is used to control the nginx instance to execute the deduction logic of the inventory.

[0166] For more details about the working principle and working mode of the control system in Example 6, please refer to the relevant description of the control method in Example 3, which will not be repeated here.

[0167] When the control system in the embodiment of the present invention is running, it can ensure that users with slower networks or users far away from the server also have the opportunity to buy products at a flash sale, which effectively improves the randomness and fairness of the flash sale and improves the user experience.

[0168] Example 7

[0169] Fig. 9 A schematic diagram of the structure of an electronic device provided in Embodiment 7 of the present invention. The electronic device may include a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the nginx-based flash sale control method in any one of Embodiments 1 to 3 when executing the computer program.

[0170] Understandably, Fig. 9 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0171] like Fig. 9 As shown, the electronic device 12 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 12 may include, but are not limited to, the at least one processor 13, the at least one memory 14, and a bus 15 connecting different system components (including the memory 14 and the processor 13).

[0172] The bus 15 may include a data bus, an address bus and a control bus.

[0173] The memory 14 may include a volatile memory, such as a random access memory (RAM) 141 and / or a cache memory 142 , and may further include a read-only memory (ROM) 143 .

[0174] The memory 14 may also include a program tool 145 (or utility) having a set (at least one) of program modules 144, such program modules 144 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.

[0175] The processor 13 executes various functional applications and data processing by running the computer program stored in the memory 14, such as the nginx-based flash sale control method provided in any one of Embodiments 1 to 3 of the present invention.

[0176] The electronic device 12 may also communicate with one or more external devices 16 (e.g., keyboard, pointing device, etc.). Such communication may be performed via an input / output (I / O) interface 17. Furthermore, the model generating electronic device 12 may also communicate with one or more networks (e.g., a local area network LAN, a wide area network WAN, and / or a public network) via a network adapter 18.

[0177] like Fig. 9 As shown, the network adapter 18 can communicate with other modules of the model-generated electronic device 12 via the bus 15. It should be understood by those skilled in the art that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the model-generated electronic device 12, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.

[0178] It should be noted that, although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more units / modules described above may be embodied in one unit / module. Conversely, the features and functions of one unit / module described above may be further divided into multiple units / modules for embodiment.

[0179] Example 8

[0180] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the nginx-based flash sale control method in any one of Embodiments 1 to 3 are implemented.

[0181] Among them, more specific forms in which computer-readable storage media can be used include but are not limited to: portable disks, hard disks, random access memories, read-only memories, erasable programmable read-only memories, optical storage devices, magnetic storage devices, or any suitable combination of the above.

[0182] In a possible implementation, the present invention can also be implemented in the form of a program product, which includes program code. When the program product runs on a terminal device, the program code is used to enable the terminal device to execute the steps of the nginx-based flash sale control method in any one of Examples 1 to 3.

[0183] Among them, the program code for executing the present invention can be written in any combination of one or more programming languages, and the program code can be executed completely on the user device, partially on the user device, as an independent software package, partially on the user device and partially on a remote device, or completely on the remote device.

[0184] Although the specific embodiments of the present invention are described above, it should be understood by those skilled in the art that this is only for illustration and the protection scope of the present invention is defined by the appended claims. Those skilled in the art may make various changes or modifications to these embodiments without departing from the principles and essence of the present invention, but these changes and modifications all fall within the protection scope of the present invention.

Claims

1. A flash sale control method based on nginx, It is characterized in that The flash sale control method comprises the following steps: Reading information of a published flash sale object, wherein the information of the flash sale object includes the inventory of the flash sale object; Synchronize the inventory to an nginx instance; the number of the nginx instances is multiple; The step of synchronizing the inventory to the nginx instance specifically includes: allocating the inventory to each of the nginx instances according to a preset ratio, so that each of the nginx instances has a sub-inventory; Receiving a flash sale request from a user for the flash sale object; The nginx instance is controlled to execute the deduction logic of the inventory according to the flash sale request, wherein the deduction inventory quantity in the deduction logic corresponds to the quantity of the flash sale objects in the flash sale request.

2. The nginx-based flash sale control method according to claim 1, It is characterized in that The step of controlling the nginx instance to execute the inventory deduction logic according to the flash sale request specifically includes: According to the flash sale request, one or more nginx instances are controlled to execute the deduction logic of the sub-inventory.

3. The nginx-based flash sale control method according to claim 2, It is characterized in that The step of allocating the inventory to each of the nginx instances according to a preset ratio specifically includes: The inventory is evenly distributed to each of the nginx instances so that each of the nginx instances has an equal amount of the sub-inventory.

4. The nginx-based flash sale control method according to claim 3, It is characterized in that After the inventory is evenly distributed to each of the nginx instances, the following further includes: The sub-inventory in the nginx instance is scheduled at preset time intervals to keep the sub-inventory equal in each of the nginx instances, wherein the scheduling includes increasing the sub-inventory, decreasing the sub-inventory, or maintaining the sub-inventory unchanged.

5. The nginx-based flash sale control method according to claim 4, It is characterized in that After the step of scheduling the sub-inventory in the nginx instance at preset intervals, the following step is further included: A scheduling log for scheduling the sub-inventory is generated.

6. The nginx-based flash sale control method according to claim 1, It is characterized in that The second sale control method further includes: Determine whether the flash sale duration of the flash sale object is greater than a preset expiration time; If the judgment is yes, the nginx instance is controlled to delete the information of the flash sale object.

7. The nginx-based flash sale control method according to claim 1, It is characterized in that The step of controlling the nginx instance to execute the inventory deduction logic according to the flash sale request specifically includes: Determine whether the difference between the time when the flash sale request occurs and the preset flash sale time is greater than a preset threshold; If the judgment is no, delaying the preset flash sale time by a preset adjustment value to obtain the time for executing the flash sale operation; Determine whether the current time reaches the time for executing the flash sale operation; If the judgment is yes, the nginx instance is controlled to execute the deduction logic of the inventory.

8. The nginx-based flash sale control method according to claim 1, It is characterized in that The second sale control method further includes: Receiving an order cancellation instruction, wherein the order cancellation instruction includes the quantity of the flash sale objects in the order to be cancelled; The inventory is adjusted according to the quantity of the flash sale object in the cancelled order.

9. A second kill control system based on nginx, It is characterized in that The second kill control system comprises: An information reading module, used to read information of a published flash sale object, wherein the information of the flash sale object includes the inventory of the flash sale object; An inventory synchronization module, used for synchronizing the inventory to an nginx instance; the number of the nginx instances is multiple; The inventory synchronization module includes an inventory allocation submodule, and the inventory allocation submodule is used to allocate the inventory to each of the nginx instances according to a preset ratio, so that each of the nginx instances has a sub-inventory; A flash sale request receiving module, used to receive a flash sale request from a user for the flash sale object; The inventory deduction module is used to control the nginx instance to execute the inventory deduction logic according to the flash sale request, wherein the deduction inventory quantity in the deduction logic corresponds to the quantity of the flash sale objects in the flash sale request.

10. The nginx-based second-hit control system according to claim 9, It is characterized in that The inventory deduction module includes a deduction control submodule, and the deduction control submodule is used to control one or more nginx instances to execute the deduction logic of the sub-inventory according to the flash sale request.

11. The nginx-based second-hit control system according to claim 10, It is characterized in that The inventory allocation submodule includes an inventory allocation unit, and the inventory allocation unit is used to evenly allocate the inventory to each of the nginx instances so that each of the nginx instances has equal sub-inventory.

12. The nginx-based second-hit control system according to claim 11, It is characterized in that The second kill control system also includes: The inventory scheduling module is used to schedule the sub-inventory in the nginx instance at preset intervals so that the sub-inventory is kept equal in each nginx instance, wherein the scheduling includes increasing the sub-inventory, decreasing the sub-inventory or maintaining the sub-inventory unchanged.

13. The nginx-based second-sale control system according to claim 12, It is characterized in that The second kill control system also includes: The scheduling log generation module is used to generate a scheduling log for scheduling the sub-inventory.

14. The nginx-based second-sale control system according to claim 9, It is characterized in that The second kill control system also includes: An expiration judgment module, used to judge whether the flash sale duration of the flash sale object is greater than a preset expiration time; If the judgment is yes, then the information deletion module is called, and the information deletion module is used to control the nginx instance to delete the information of the flash sale object.

15. The nginx-based second-sale control system according to claim 9, It is characterized in that The inventory deduction module includes: The first judgment submodule is used to judge whether the difference between the time when the flash sale request occurs and the preset flash sale time is greater than a preset threshold; If the judgment is no, then calling the delay submodule, the delay submodule is used to delay the preset flash sale time by a preset adjustment value to obtain the time for executing the flash sale operation; The second judgment submodule is used to judge whether the current time reaches the time for executing the flash sale operation; If the judgment is yes, the deduction execution submodule is called, and the deduction execution submodule is used to control the nginx instance to execute the deduction logic of the inventory.

16. The nginx-based second-sale control system according to claim 9, It is characterized in that The second kill control system also includes: An instruction receiving module, configured to receive an order cancellation instruction, wherein the order cancellation instruction includes the quantity of the flash sale objects in the order to be cancelled; The inventory adjustment module is used to adjust the inventory according to the quantity of the flash sale object in the cancelled order.

17. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the nginx-based flash sale control method described in any one of claims 1-8 are implemented.

18. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the nginx-based flash sale control method described in any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Internet high concurrency seckilling system

    CN103825835A

  • Device and method for controlling order to generate, and seckilling system

    CN105160572A