Detailed Description
With the continuous development of computers and the internet, resources in accounts become very rich, for example, the resources can be virtual resources, such as coupons, points and the like, and can also be substance resources such as funds, gold and the like, and the concrete expression forms of the resources are more and more diversified with the continuous development of computers and the internet.
As described in the background, in a scenario similar to that of issuing coupons by an enterprise (or a scenario similar to that of issuing coupons by an enterprise, and the like, embodiments of the present specification will not be described in detail herein), a large number of users participate in the activity of issuing coupons by an enterprise, and for a user who obtains coupons, it is necessary to obtain coupons of corresponding amount from an enterprise account and issue them to the user account of the user. Meanwhile, in order to prevent the occurrence of overdrawing of coupons in the enterprise account (overdrawing means that the number of coupons issued by the enterprise is greater than the number of coupons in the enterprise account), the enterprise account needs to be locked in the process of acquiring coupons with corresponding amounts from the enterprise account, so that the locking rights of the enterprise account need to be contended for processing any coupon acquisition request.
Since the enterprise account needs to be locked in the process of acquiring coupons with corresponding amounts from the enterprise account, any coupon acquisition request needs to compete for the locking rights of the enterprise account, and particularly in the case of processing a large number of coupon acquisition requests, the competition phenomenon is more prominent (the competition phenomenon is called an account hotspot), so that the efficiency of acquiring coupons with corresponding amounts from the enterprise account is reduced, and the impact of the large number of coupon acquisition requests cannot be met.
In view of the above technical problems, an embodiment of the present disclosure provides a resource obtaining technical solution, by splitting an account into a plurality of sub-accounts, distributing resources in the account to the plurality of sub-accounts according to a preset distribution rule, forming an account pool by the plurality of sub-accounts, subsequently determining an account pool corresponding to the resource obtaining request when receiving the resource obtaining request, obtaining an unlocked target sub-account from the account pool, and obtaining resources corresponding to the resource obtaining request from the target sub-account. Therefore, the account is expanded, the efficiency of acquiring the resources from the account is improved, and the impact of a large number of resource acquisition requests can be effectively coped with.
Specifically, the technical scheme provided in the embodiment of the present specification is as follows:
when a resource acquisition request is received, determining an account pool corresponding to the resource acquisition request; obtaining unlocked sub-accounts from an account pool corresponding to the resource obtaining request; determining a target sub-account from the acquired sub-accounts; locking the target sub-account; and under the condition that the target sub-account is locked, acquiring the resource corresponding to the resource acquisition request from the target sub-account.
In order for those skilled in the art to better understand the technical solutions in the embodiments of the present specification, the technical solutions in the embodiments of the present specification will be described in detail below with reference to the drawings in the embodiments of the present specification, and it is apparent that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification shall fall within the scope of protection.
As shown in fig. 1, a schematic implementation flow chart of a resource obtaining method provided in an embodiment of the present disclosure is shown, and the method specifically may include the following steps:
s101, when a resource acquisition request is received, determining an account pool corresponding to the resource acquisition request;
in the present embodiment, in order to cope with the impact of a large-volume resource acquisition request, an account is split into a plurality of sub-accounts, which may be referred to as a main account. For example, for the account a, the account a may be split into sub-account A1, sub-account A2, sub-account A3 … …, and for the account a, the lateral expansion may be performed, and the account a may be split into multiple sub-accounts, where the number of the sub-accounts that are split may be determined according to the actual situation.
On the other hand, for the resources in the account, the resources can be distributed to a plurality of sub-accounts according to preset distribution rules, and the embodiment of the specification performs distance description on three distribution rules:
one of the allocation rules may be: and (5) average distribution. For example, for the resources in account a, it may be equally allocated to sub-accounts A1, A2, A3, … ….
Another allocation rule may be: and (5) distributing according to the requirement, and distributing resources according to the preset weight of each sub-account. For example, for the resources in the account a, the resources in the account a may be allocated according to the weights of the sub-account A1, the sub-account A2, the sub-account A3 … …, and the like, for example, one tenth of the resources in the account a is allocated to the sub-account A1, and one tenth of the resources in the account a is allocated to the sub-account A2.
Another allocation rule may be: and dynamically distributing part of the resources in the account to a plurality of sub-accounts, monitoring whether the number of the resources in each sub-account is smaller than a preset threshold value according to a preset monitoring period, and if the number of the resources in the sub-account is smaller than the preset threshold value, acquiring a certain resource from the rest of the resources in the account and distributing the certain resource to the sub-account.
For example, for some resources in the account a, the resources may be allocated to the sub-accounts A1, A2 and A3 and … …, and then, according to a preset monitoring period, whether the resources in each sub-account are smaller than a certain preset threshold value is monitored, if the number of the resources in the sub-account is smaller than the preset threshold value, a certain resource is obtained from the remaining resources in the account a and allocated to the sub-account until the resources in the sub-account exceed a certain preset threshold value.
It should be noted that the allocation rule is an exemplary description of the embodiment of the present specification, and may be other allocation rules, which is not limited in the embodiment of the present specification.
After splitting an account into multiple sub-accounts, an account pool can be composed of the multiple sub-accounts, wherein the account pool is external to the account or the account, and the account pool can be processed in any sub-account when the resource acquisition request is actually processed.
For example, the account a can be split into a sub-account A1, a sub-account A2 and a sub-account A3 … …, and an account pool is formed by the sub-account A1, the sub-account A2 and the sub-account A3 … …, and when the account pool is the account a, the sub-account A1, the sub-account A2, the sub-account A3 … … and the like can be processed in any sub-account when the resource acquisition request is actually processed.
And subsequently, when a resource acquisition request is received, determining an account pool corresponding to the resource acquisition request, wherein the resource acquisition request carries an account identifier, and determining the account pool corresponding to the resource acquisition request according to the account identifier carried in the resource acquisition request. For example, for an account identifier a carried by a resource acquisition request, an account pool a corresponding to the resource acquisition request may be determined, where the account pool a is external to the account a.
S102, obtaining an unlocked sub-account from an account pool corresponding to the resource obtaining request;
and (3) acquiring an unlocked sub-account from the account pool corresponding to the resource acquisition request determined in the step S101, wherein the unlocked sub-account is a sub-account with unlocked sub-account state. For example, the account pool comprises 10 sub-accounts, wherein 4 sub-accounts are currently in a locked state, and the remaining 6 sub-accounts in an unlocked state can be acquired.
S103, determining a target sub-account from the acquired sub-accounts;
for the sub-account acquired in step S102, a target sub-account whose state is unlocked may be determined therefrom. Before determining the target sub-account, the sub-accounts which do not meet the requirements can be preferentially rejected, and the specific implementation mode is as follows:
and eliminating sub-accounts of which the resources do not exceed the resources corresponding to the resource acquisition request from the acquired sub-accounts, and determining target sub-accounts from the acquired residual sub-accounts. Meaning that for the obtained sub-account, if the resources in the sub-account do not exceed the resources corresponding to the resource obtaining request, the resources are removed, and the target sub-account is determined in the rest sub-accounts. In this embodiment of the present specification, an implementation manner of determining a target sub-account is described as an example:
one implementation of determining the target sub-account is: and randomly determining a target sub-account from the acquired remaining sub-accounts. For the sub-account which is removed, one sub-account can be randomly determined as a target sub-account, for example, the sub-account A1 is randomly determined as the target sub-account from three sub-accounts of the sub-account A1, the sub-account A2 and the sub-account A3, and the state of the target sub-account is unlocked.
Another implementation way of determining the target sub-account is: and determining the sub-account with the maximum sub-account preset weight as a target sub-account from the obtained remaining sub-accounts. The sub-account preset weight or preset priority may be regarded as a preset sorting rule, and the target sub-account may be determined from the obtained remaining sub-accounts according to the preset sorting rule, which is exemplified in the embodiment of the present disclosure, but may also be other sorting rules, which is not limited in the embodiment of the present disclosure.
Another implementation way of determining the target sub-account is: and determining the sub-account with the largest sub-account resource quantity as a target sub-account from the acquired remaining sub-accounts. For the sub-accounts which are removed, determining the quantity of resources in each sub-account, and determining the sub-account with the largest resource data as a target sub-account, for example, determining sub-account A1 as the target sub-account.
It should be noted that the above implementation is an exemplary illustration of several implementations of the embodiments of the present specification, and other implementations are also possible, which the embodiments of the present specification do not limit.
S104, locking the target sub-account;
for the target sub-account determined in S103, the target sub-account may be locked, specifically, the resource in the target sub-account may be locked. The implementation manner of locking the resource in the target account can be any current implementation manner, and the embodiment of the present specification is not limited to this.
S105, acquiring the resource corresponding to the resource acquisition request from the target sub-account under the condition that the target sub-account is locked.
And locking the target sub-account, and locking resources in the target sub-account to prevent a plurality of resource acquisition requests from being processed in the target sub-account simultaneously.
Under the condition of locking the resources in the target sub-account, the resources corresponding to the resource acquisition request can be acquired from the target sub-account, and after the resources corresponding to the resource acquisition request are acquired from the target sub-account, the target sub-account is released so as to enable the target sub-account to return to the account pool.
Through the description of the technical scheme provided by the embodiment of the specification, the account is split into a plurality of sub-accounts, the resources in the account are distributed into the plurality of sub-accounts according to the preset distribution rule, an account pool is formed by the plurality of sub-accounts, then when the resource acquisition request is received, the account pool corresponding to the resource acquisition request is determined, the unlocked target sub-account is acquired from the account pool, and the resources corresponding to the resource acquisition request are acquired from the target sub-account. Therefore, the account is expanded, the efficiency of acquiring the resources from the account is improved, and the impact of a large number of resource acquisition requests can be effectively coped with.
Corresponding to the above method embodiment, the embodiment of the present disclosure further provides a resource obtaining device, as shown in fig. 2, where the device may include: an account splitting module 210, a resource allocation module 220, an account pool composition module 230, an account pool determination module 240, a sub-account acquisition module 250, a sub-account determination module 260, a sub-account locking module 270, and a resource acquisition module 280.
An account splitting module 210, configured to split an account into a plurality of sub-accounts;
the resource allocation module 220 is configured to allocate resources in the account to the plurality of sub-accounts according to a preset allocation rule;
an account pool composition module 230, configured to compose an account pool from the plurality of sub-accounts;
an account pool determining module 240, configured to determine, when a resource acquisition request is received, an account pool corresponding to the resource acquisition request;
a sub-account obtaining module 250, configured to obtain an unlocked sub-account from an account pool corresponding to the resource obtaining request;
a sub-account determination module 260, configured to determine a target sub-account from the acquired sub-accounts;
a sub-account locking module 270, configured to lock the target sub-account;
and the resource obtaining module 280 is configured to obtain, in the case of locking the target sub-account, a resource corresponding to the resource obtaining request from the target sub-account.
In one specific implementation of the embodiment of the present disclosure, the sub-account determining module 260 includes:
a sub-account rejection module 261, configured to reject, from the acquired sub-accounts, sub-accounts whose resources do not exceed the resources corresponding to the resource acquisition request;
the sub-account determination sub-module 262 is configured to determine a target sub-account from the acquired remaining sub-accounts.
In one specific implementation of the embodiment of the present disclosure, the sub-account determination sub-module 262 is specifically configured to:
and randomly determining a target sub-account from the acquired remaining sub-accounts.
In one specific implementation of the embodiment of the present disclosure, the sub-account determination sub-module 262 is specifically configured to:
and determining the sub-account with the maximum sub-account preset weight as a target sub-account from the obtained remaining sub-accounts.
In one specific implementation of the embodiment of the present disclosure, the sub-account determination sub-module 262 is specifically configured to:
and determining the sub-account with the largest sub-account resource quantity as a target sub-account from the acquired remaining sub-accounts.
In a specific implementation of the embodiments of the present specification, the apparatus further includes:
and the sub-account releasing module 290 is configured to release the target sub-account after acquiring the resource corresponding to the resource acquiring request from the target sub-account, so that the target sub-account returns to the account pool.
The implementation process of the functions and roles of each module in the above device is specifically shown in the implementation process of the corresponding steps in the above method, and will not be described herein again.
Through the description of the technical scheme provided by the embodiment of the specification, the account is split into a plurality of sub-accounts, the resources in the account are distributed into the plurality of sub-accounts according to the preset distribution rule, an account pool is formed by the plurality of sub-accounts, then when the resource acquisition request is received, the account pool corresponding to the resource acquisition request is determined, the unlocked target sub-account is acquired from the account pool, and the resources corresponding to the resource acquisition request are acquired from the target sub-account. Therefore, the account is expanded, the efficiency of acquiring the resources from the account is improved, and the impact of a large number of resource acquisition requests can be effectively coped with.
The embodiments of the present disclosure also provide a computer device, which at least includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the foregoing resource obtaining method when executing the program, and the method at least includes:
splitting an account into a plurality of sub-accounts, distributing resources in the account to the plurality of sub-accounts according to a preset distribution rule, and forming an account pool by the plurality of sub-accounts;
when a resource acquisition request is received, determining an account pool corresponding to the resource acquisition request;
obtaining unlocked sub-accounts from an account pool corresponding to the resource obtaining request;
determining a target sub-account from the acquired sub-accounts;
locking the target sub-account;
and under the condition that the target sub-account is locked, acquiring the resource corresponding to the resource acquisition request from the target sub-account.
FIG. 3 illustrates a more specific hardware architecture diagram of a computing device provided by embodiments of the present description, which may include: a processor 310, a memory 320, an input/output interface 330, a communication interface 340, and a bus 350. Wherein the processor 310, the memory 320, the input/output interface 330 and the communication interface 340 are communicatively coupled to each other within the device via a bus 350.
The processor 310 may be implemented by a general-purpose CPU (Central Processing Unit ), a microprocessor, an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc. for executing relevant programs to implement the technical solutions provided in the embodiments of the present disclosure.
The Memory 320 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory ), static storage device, dynamic storage device, or the like. Memory 320 may store an operating system and other application programs, and when implementing the techniques provided by the embodiments of the present disclosure via software or firmware, the associated program code is stored in memory 320 and invoked for execution by processor 310.
The input/output interface 330 is used for connecting with an input/output module to realize information input and output. The input/output module may be configured as a component in a device (not shown) or may be external to the device to provide corresponding functionality. Wherein the input devices may include a keyboard, mouse, touch screen, microphone, various types of sensors, etc., and the output devices may include a display, speaker, vibrator, indicator lights, etc.
The communication interface 340 is used to connect to a communication module (not shown in the figure) to enable communication interaction between the present device and other devices. The communication module may implement communication through a wired manner (such as USB, network cable, etc.), or may implement communication through a wireless manner (such as mobile network, WIFI, bluetooth, etc.).
Bus 350 includes a path to transfer information between components of the device (e.g., processor 310, memory 320, input/output interface 330, and communication interface 340).
It should be noted that although the above device only shows the processor 310, the memory 320, the input/output interface 330, the communication interface 340, and the bus 350, in the implementation, the device may further include other components necessary to achieve normal operation. Furthermore, it will be understood by those skilled in the art that the above-described apparatus may include only the components necessary to implement the embodiments of the present description, and not all the components shown in the drawings.
The embodiments of the present specification also provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the foregoing resource acquisition method, the method at least comprising:
splitting an account into a plurality of sub-accounts, distributing resources in the account to the plurality of sub-accounts according to a preset distribution rule, and forming an account pool by the plurality of sub-accounts;
when a resource acquisition request is received, determining an account pool corresponding to the resource acquisition request;
obtaining unlocked sub-accounts from an account pool corresponding to the resource obtaining request;
determining a target sub-account from the acquired sub-accounts;
locking the target sub-account;
and under the condition that the target sub-account is locked, acquiring the resource corresponding to the resource acquisition request from the target sub-account.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
From the foregoing description of embodiments, it will be apparent to those skilled in the art that the present embodiments may be implemented in software plus a necessary general purpose hardware platform. Based on such understanding, the technical solutions of the embodiments of the present specification may be embodied in essence or what contributes to the prior art in the form of a software product, which may be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the embodiments or some parts of the embodiments of the present specification.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points. The apparatus embodiments described above are merely illustrative, in which the modules illustrated as separate components may or may not be physically separate, and the functions of the modules may be implemented in the same piece or pieces of software and/or hardware when implementing the embodiments of the present disclosure. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
The foregoing is merely a specific implementation of the embodiments of this disclosure, and it should be noted that, for a person skilled in the art, several improvements and modifications may be made without departing from the principles of the embodiments of this disclosure, and these improvements and modifications should also be considered as protective scope of the embodiments of this disclosure.