Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 2, a flowchart of embodiment 1 of the information processing method of the present application is shown, which may include the following steps:
step 101, generating a hotspot account corresponding to an activity, wherein the hotspot account comprises a preset number of detail records, and each detail record comprises an identifier of the activity, an identifier of the detail record, a state of the detail record and a subject matter parameter.
According to the scheme of the embodiment of the application, the detail record without difference of the preset strip can be generated according to the activity requirement, and the detail record can comprise the identification of the activity, the identification of the detail record, the state of the detail record and the object parameter. In particular, the identity of the activity may be an activity name and/or an activity ID; the identification of the detail record can be a detail record name and/or a detail record ID; the detail record state can be idle or occupied, wherein if the detail record is allocated to the user, the state is represented as occupied, otherwise, the state is represented as idle, and the initial state of the detail record is generally the idle state; the subject matter parameter may be the number of subject matter, which may typically be presented in different forms for different activities, for example, if the activity is a robbed red envelope, the subject matter parameter may be the amount of the red envelope, e.g., 5 dollars, 10 dollars, etc.; if the activity is robbing goods, the target object parameter can be the limited purchase quantity of the goods, and if the goods are mobile phones, the target object parameter can be 1 station, 2 stations and the like. In practical applications, the embodiment of the present application may not specifically limit the specific representation form of each item of information included in the detail record. As an example, the detail record may be embodied as a schematic diagram as shown in FIG. 3.
It should be noted that the application server may set the object parameters according to a default configuration, or the application server may set the object parameters according to a manual configuration of an operator, which is not specifically limited in this embodiment of the application, and generally the application server does not set the object parameters in real time according to information input by a user at the client. For example, the application server may set the red packet amount of all detail records to 5 yuan, or may set the red packet amount of all detail records to 10 yuan; or the red packet amount of one part of detail record can be set to be 5 yuan, and the red packet amount of the other part of detail record can be set to be 10 yuan; however, the application server does not generally respond to the client user in real time, and sets the amount of the red envelope according to the value input by the user.
In addition, it should be noted that the identifier of the activity is used to indicate which specific activity the detail record corresponds to, and when the application server routes the user to the hotspot account and allocates the detail record to the user in the subsequent processing process, the accuracy of routing of the application server can be further checked through the identifier of the activity. As an example, if the requirement on the routing accuracy is not high, or only the only activity is currently performed, the detail record may not include the identifier of the activity, and of course, in order to ensure the routing accuracy of the application server, it is optimal to use the detail record including the identifier of the activity.
The generation of the detail records with no difference in the preset pieces in the embodiment of the application means that the detail records are not distinguished from one another, and can be allocated to the user as long as the detail records are in an idle state. The preset number can be a preset specified number, for example, 1 ten thousand detail records are specified to be generated; alternatively, the preset number may be a calculated number obtained from the total distribution number, the generation factor, and the target object parameter, for example, if the total distribution number is 100 ten thousand-dollar red packets, the generation factor is 0.8, and the target object parameter is 5-dollar, then the calculation knows that 100 × 0.8/5 is 16 ten thousand detail records are to be generated. It should be noted that the generation factor may be randomly set, or may also be set according to experience of other related activities, and furthermore, the generation factor may also be set according to historical data of the past year of the activity, which is not specifically limited in the embodiment of the present application.
In summary, in the account configuration stage before the start of the activity, the embodiment of the application does not need to split the account by the application server, does not need to configure the activity information for each sub-account, does not need to check the correctness among the sub-accounts, and only needs to generate the detail record with no difference in the preset strips, so that the generation process is simple and easy to implement, and the processing resource of the application server can be saved. Therefore, the technical problem that in the prior art, a large amount of processing resources of the application server are consumed for reducing the second-level concurrency of the hot spot account is solved.
Step 102, in response to an access request sent by a user for the activity, searching a corresponding current detail record for each user from the hotspot account, wherein the state of the current detail record is idle.
Step 101 is mainly directed to the account configuration stage before the start of the activity, and once the account configuration is completed and the activity is started, the application server may directly execute step 102 to respond to the access request of the user.
For example, a client user views an activity page, and may send an access request to an application server by clicking or touch, and the application server receives the access request sent by the user, and may perform information processing according to the scheme of the embodiment of the present application. Taking a scene of double-11 red packet issuing as an example, the activity page may display a 5-yuan red packet getting button and a 10-yuan red packet getting button, and when the user a clicks the 10-yuan red packet getting button, the user a sends an access request to the application server, where the access request is used to indicate that the user a requests to get the 10-yuan red packet of the double-11 activity.
Optionally, after receiving the access request, the application server may authenticate the identity of the user a, the behavior of the user a to receive the red envelope, the amount of money for which the user a requests to receive the red envelope, and the like, and after the authentication is passed, the application server performs information processing according to the scheme of the embodiment of the present application.
Specifically, in this embodiment of the present application, an information processing process of the application server may be embodied as: determining hot spot accounts corresponding to activities in which users participate, and searching a detail record in an idle state for each user from the hot spot accounts to serve as a current detail record distributed to the users.
As an example, if only one user currently sends an access request to the application server, the application server may determine a current detail record for the user from all detail records of which the hotspot account is in an idle state.
For example, the application server may randomly determine the current detail record from all detail records in the idle state, e.g., the detail records with IDs 10 to 20 are all in the idle state, and the application server may randomly determine the detail record with ID 12 as the current detail record. Or, the application server may determine, as the current detail record, the detail record with the largest ID or the smallest ID among all the detail records in the idle state, for example, the detail records with IDs of 10 to 20 are all in the idle state, and the application server may determine the detail record with the smallest ID of 10 as the current detail record. Or, the application server may determine, according to a preset matching rule, a current detail record matching the user ID from all detail records in the idle state, for example, the user ID is 123456, and the detail records with IDs of 10 to 20 are all in the idle state, and if the matching rule is that the last digit of the ID of the detail record is the same as the last digit of the ID of the user, the application server may determine the detail record with ID 16 as the current detail record. Specifically, the embodiment of the present application may not be limited to the manner in which the application server determines the current detail record, the specific implementation means of each manner, and the like.
As an example, if there are multiple users currently sending access requests to the application server concurrently, the application server may determine a current detail record for each user from all detail records of the hotspot account in the idle state in at least three ways described below. The three ways of determining the current detail record by the application server are not explained here for a while, and refer to the following description.
And 103, distributing the current detail record to a corresponding user, and updating the state of the current detail record to be occupied.
Whether single-user access or multi-user concurrent access is adopted, the application server can allocate a corresponding current detail record to each user. It is to be understood that assigning the current detail record to the corresponding user means establishing a correspondence between the current detail record and the corresponding user. For example, detail records 10, 11, 12 are sequentially assigned to user A, B, C, and if detail records 10, 11, 12 are shown in fig. 3, step 103 assigns the current detail record to the corresponding user representation, user a gets a 5-membered red envelope, user B gets a 5-membered red envelope, and user C gets a 10-membered red envelope; if the detail records 10, 11, 12 are represented in fig. 4, step 103 assigns the current detail record to the corresponding user representation, and users A, B and C respectively purchase 1 handset.
In the embodiment of the application, each detail record can only be uniquely allocated to one user, so that after the corresponding relationship between the current detail record and the corresponding user is established, the state of the current detail record can be updated, and the idle state is modified into the occupied state, thereby indicating that the detail record is allocated to the user.
In summary, the embodiment of the application converts the behavior of the user getting the red envelope or the goods for the first time into the processing process of matching the detail records, does not need to modify the account balance or the number of the remaining goods in real time, can ensure the thread safety of concurrent access, and is beneficial to improving the capability of the application server for responding the concurrent access.
It should be noted that, although the solution of the embodiment of the present application mainly aims at the marketing service, the technical problem existing in the service implementation process is substantially solved by using technical means.
As mentioned in relation to step 102, three ways for the application server to determine the current detail record are explained below.
Implementation mode one
If the identification of the detail record included in the hotspot account adopts a self-increment design, the application server can determine the current detail record in the following way: obtaining a detail record identifier distributed by a cache server for each user, wherein the detail record identifier is distributed by the cache server according to a self-increment design according to the time stamp sequence of each user sending an access request; and searching the corresponding current detail record for each user according to the identification of the detail record.
In order to avoid that multiple concurrent users preempt the same detail record and achieve lock-free processing, in the embodiment of the present application, an identifier of a detail record may be allocated to each user according to the sequence of timestamps of access requests sent by the users by using the cache server. For example, a current value of a detail record ID may be maintained in a distributed cache server, when users a and B access concurrently, if user a arrives earlier than user B, (current value +1) may be assigned to user a, and at the same time, the cache server maintains (current value +1), and when user B arrives, (current value +2) is assigned to user B, and continues to maintain (current value + 2). By analogy, when other users send access requests to the application server, the cache server can allocate a corresponding detail record ID to each user, and the specific process is not described herein. As an example, the cache server may assign a corresponding detail record ID to each user through an incr operation of redis: redis- > incr ('prerecordidnum _ activity 001'). It should be noted that, in the above example, the argument value is represented as 1, and in a specific application, the argument value may be set as needed, which may not be specifically limited in the embodiment of the present application.
For example, the cache server allocates the detail record ID to the user a to be 10, and allocates the detail record ID to the user B to be 11, and the application server can accordingly establish the corresponding relationship between the user a and the detail record with the ID of 10, and establish the corresponding relationship between the user B and the detail record with the ID of 11, as can be known from the schematic diagram shown in fig. 3, the user a can receive the 5-dimensional red packet, and the user B can receive the 5-dimensional red packet.
Implementation mode two
The application server may determine the current detail record in the following manner: and sequentially searching a corresponding current detail record for each user from all detail records of the hot spot account in the idle state according to the time stamp sequence of the access request sent by each user.
In order to avoid that multiple concurrent users occupy the same detail record and achieve lock-free processing, in the embodiment of the present application, a corresponding current detail record may be sequentially allocated to each user according to the sequence of the timestamps of the access requests sent by the users. For example, the detail records with the IDs of 10 to 20 are all in an idle state, the users a and B access concurrently, and the user a arrives earlier than the user B, the application server may randomly determine one current detail record for each of the users a and B in sequence from all the detail records in the idle state, for example, the ID of the current detail record determined for the user a is 10, and the ID of the current detail record determined for the user B is 12. Or, the application server may determine a current detail record for each of the users a and B in turn according to the sorting of the size of the detail record IDs, for example, the detail records are sorted in ascending order according to the IDs, the ID of the current detail record determined for the user a is 10, and the ID of the current detail record determined for the user B is 11; alternatively, the detail records are sorted in descending ID order, with the ID of the current detail record determined for user A being 20 and the ID of the current detail record determined for user B being 19.
Optionally, the second implementation manner may further cooperate with the first implementation manner to determine a corresponding current detail record for the user, which may be embodied as: the application server may determine the current detail record for the user by using the cache server in the first implementation manner, and determine the current detail record for the user in the second implementation manner when the cache server fails. For example, the application server may determine whether the cache server fails by monitoring the heartbeat of the cache server.
Implementation mode three
The application server may determine the current detail record in the following manner: obtaining the specified number of detail records from all detail records of the hotspot account in the idle state; and determining a corresponding current detail record for each user from the specified number of detail records by using the identity of each user.
In order to avoid that multiple concurrent users occupy the same detail record and achieve lock-free processing, in the embodiment of the application, a specified number of detail records can be captured from all detail records in an idle state, and then a corresponding current detail record is determined for each user from the specified number of detail records according to a certain matching rule by combining user IDs. For example, the specified number is 10, all detail records with IDs 001 to 100 are in an idle state, the IDs of the detail records captured by the application server are 001 to 010, if the ID of the user a is 123456, the ID of the user B is 654321, and the matching rule is: and determining the position of the current detail record corresponding to the user in the captured detail record by taking the designated bit of the user ID as a basis. For example, if the specified position is the penultimate position of the user ID, the position of the current detail record corresponding to the user a in the captured detail record is 5, that is, the detail record with the ID of 005; the position of the current detail record corresponding to the user B in the grasped detail record is 2, that is, the detail record with the ID of 002.
It should be noted that, in the embodiment of the present application, multiple matching rules may be sequentially set, and if a detail record cannot be determined for a user through a current matching rule, a next matching rule may be sequentially used to perform detail record matching until a corresponding current detail record is determined for the user. Alternatively, if multiple detail records are determined for the user by the current matching rule, the current detail record may be randomly determined from the determined multiple detail records, or the corresponding current detail record may be determined for the user by combining other matching rules. This may not be specifically limited in the embodiment of the present application, as long as one current detail record is determined for each user.
For example, the matching rule in the embodiment of the present application may also be: the user ID and the specification record ID are matched to make the two identical or have a preset corresponding relationship, which is not specifically limited in the present application.
Referring to fig. 5, a flowchart of embodiment 2 of the information processing method of the present application is shown, which may include the following steps:
step 201, generating a hotspot account corresponding to the activity, where the hotspot account includes a preset number of detail records, and the detail records include an identifier of the activity, an identifier of the detail record, a state of the detail record, and a subject matter parameter.
The implementation process of step 201 can refer to step 101 shown in fig. 2 above, and is not described here again.
Step 202, responding to an access request sent by the user for the activity, judging whether the number of detail records of the hotspot account in the idle state is lower than a preset value, and if not, executing step 203.
The embodiment of the application mainly aims at scenes with high second-level concurrency, in order to avoid the phenomenon of insufficient distribution of detail records, namely, the number of detail records in an idle state is smaller than the number of concurrently-accessed users, before distributing corresponding current detail records to each user, the application server can firstly judge whether the number of detail records in the idle state at present is lower than a preset value, and if the number of detail records in the idle state is not lower than the preset value, the step of determining the current detail records for the users can be continuously executed.
For example, the preset value may be a preset specified value, for example, the specified value is 100, that is, when the number of detail records of the hotspot account in the idle state is greater than 100, the step of determining the current detail record for the user may be continuously performed. Alternatively, the preset value may be a preset ratio, for example, the ratio is 20%, that is, when the number of detail records of the hotspot account in the idle state is greater than 20% of the preset number, the step of determining the current detail record for the user may be continuously performed. Alternatively, the preset value may be the number of users concurrently accessing, for example, the number of users concurrently accessing is 100, that is, when the number of detail records of the hotspot account in the idle state is greater than 100, the step of determining the current detail record for the user may be continuously performed.
Step 203, searching a corresponding current detail record for each user from the hotspot account, wherein the state of the current detail record is idle.
And 204, distributing the current detail record to a corresponding user, and updating the state of the current detail record to be occupied.
The implementation process of steps 203 and 204 can refer to steps 102 and 103 shown in fig. 2, and are not described herein again.
Optionally, the hotspot account further includes a pre-allocation number and/or an unallocated number, and when it is determined in step 202 that the number of detail records of the hotspot account in the idle state is lower than the preset value, the application server may further perform the following steps: and judging whether the unallocated number is greater than zero, if so, generating a new detail record by using the unallocated number, and searching for a corresponding current detail record for each user.
In the embodiment of the application, the pre-distribution number refers to the sum of target parameters of detailed records of a preset number, and the unallocated number refers to the difference between the total distribution number and the pre-distribution number. Taking the above-mentioned rob-of-red-packet activity as an example, if the total distribution number is 100 ten thousand yuan red packet, the generation factor is 0.8, and the money amount of the red packet is 5 yuan, the pre-distribution number corresponding to 16 ten thousand detail records is 16 × 5-80 ten thousand yuan, and the unallocated number is 100-80-20 ten thousand yuan.
If the unallocated number is greater than zero, it indicates that there is a surplus in the red packet or the commodity, and a new detail record can be continuously generated by combining the unallocated number for distribution by the application server. It should be noted that, the application server may determine the current detail record for the user from the remaining detail records (i.e., the detail records in the idle state in the preset number of detail records), and determine the current detail record for the user from the new detail records when the current detail record is insufficient. Alternatively, the application server may determine the current detail record for the user from the new detail record and determine the current detail record for the user from the remaining detail records when insufficient. Alternatively, the application server may not distinguish between the remaining detail records and the new detail records, and directly determine the current detail record for the user therefrom.
Optionally, as an example, the application server may also determine whether the pre-allocation number is smaller than the total allocation number, if so, generate a new detail record by using the unallocated number, and then perform the step of searching for a corresponding current detail record for each user. The specific process may refer to the scheme described above with respect to the unallocated number, and is not described herein again.
Alternatively, if the unallocated number is determined to be equal to zero or the pre-allocated number is determined to be equal to the total allocated number, in order to increase the speed of processing the user request, the application server may further calculate a difference value between the number of detail records in the idle state and the number of concurrently accessed users, sort the detail records according to the timestamp of the concurrently accessed users sending the access requests, and directly feed back the activity end page to the users which are consistent with the difference value and are ranked later (i.e., the users which are not allocated to the detail records). For example, there are remaining 3 detail records in an idle state in the red envelope account, 5 users currently send access requests to the application server concurrently, and the 5 users are sequentially 1, 2, 3, 4, and 5 according to the time stamp sorting, and accordingly, the application server may allocate one current detail record to each of the users 1, 2, and 3, that is, each of the users 1, 2, and 3 takes one red envelope, and simultaneously, the application server may return a red envelope robbing activity end page to the users 4 and 5. In this way, the time for the application server to respond to the users 4 and 5 can be shortened, and the user experience of the users 4 and 5 can be improved.
In summary, when the allocation is insufficient, a new detail record can be generated according to the actual situation, and data migration is not involved in the process, and the corresponding relation between the ongoing activity, the existing detail record, the established detail record and the user is not affected.
Optionally, the embodiment of the present application may further include a settlement step after the activity is ended. For example, for a red envelope robbing activity, the settlement step refers to calculating the balance of the red envelope; for the goods robbing activity, the settlement step refers to calculating the number of the remaining goods. Specifically, the embodiment of the present application provides the following two settlement implementation manners:
in a first implementation manner, the application server releases all detail records in the hotspot account in the idle state, and updates the detail records as follows: the pre-distribution number is zero, and the unallocated number is the total distribution number, and the sum of the target parameters of all detail records in the occupied state. Wherein the unallocated number is the calculated value.
In the second implementation manner, the application server calculates the sum of the target object parameters of the unallocated number + the number of all detail records in the idle state.
In correspondence with the method provided by embodiment 1 of the information processing method of the present application, referring to fig. 6, the present application also provides embodiment 1 of an information processing apparatus, and in this embodiment, the apparatus may include:
a generating unit 301, configured to generate a hotspot account corresponding to an activity, where the hotspot account includes a preset number of detail records, and each detail record includes an identifier of the activity, an identifier of the detail record, a state of the detail record, and a subject parameter;
a searching unit 302, configured to search, in response to an access request sent by a user for the activity, a corresponding current detail record from the hotspot account for each user, where a state of the current detail record is idle;
the allocating unit 303 is configured to allocate the current detail record searched by the searching unit to a corresponding user, and update the state of the current detail record to occupied.
The searching unit may determine a corresponding current detail record for each user according to the scheme described in the method embodiment, which is not described herein again.
For multi-user concurrent access, the lookup unit in the embodiment of the present application can be embodied in the following three implementation manners:
in a first implementation manner, if multiple users send access requests concurrently and the identifier of the detail record adopts a self-increment design, the search unit includes:
the first obtaining unit is used for obtaining a detail record identifier distributed by a cache server for each user, wherein the detail record identifier is distributed by the cache server according to a self-increment design according to the time stamp sequence of an access request sent by each user;
and the first searching subunit is used for searching the corresponding current detail record for each user according to the identifier of the detail record.
In a second implementation manner, if multiple users concurrently send access requests, the search unit includes:
and the second searching subunit is used for sequentially searching a corresponding current detail record for each user from all the detail records of the hot spot account in the idle state according to the time stamp sequence of the access request sent by each user.
In a third implementation manner, if multiple users concurrently send access requests, the search unit includes:
a second obtaining unit, configured to obtain a specified number of detail records from all the detail records of the hotspot account in an idle state;
and the third searching subunit is used for determining a corresponding current detail record for each user from the specified number of detail records by using the identity of each user.
Optionally, on the basis of the above scheme, the apparatus further includes:
the first judging unit is used for judging whether the number of the detail records of the hot spot account in the idle state is lower than a preset value before the searching unit searches the current detail record, and if not, the searching unit is informed to search the current detail record.
Optionally, if the number of detail records of which the hotspot account is in an idle state is lower than the preset value, and the hotspot account further includes a pre-allocation number and/or an unallocated number, where the pre-allocation number is a sum of object parameters of the detail records of the preset number, and the unallocated number is a difference between a total allocation number and the pre-allocation number, the apparatus further includes:
a second judging unit, configured to, when the number of detail records of the hotspot account in an idle state is lower than the preset value, judge whether the unallocated number is greater than zero, if yes, generate a new detail record by using the unallocated number, and notify the searching unit to search for the current detail record; or,
and the third judging unit is used for judging whether the pre-distribution number is smaller than the total distribution number when the number of the detail records of the hot spot account in the idle state is smaller than the preset value, if so, generating a new detail record by using the unallocated number, and informing the searching unit to search the current detail record.
The application also provides the intelligent equipment, and the processor of the intelligent equipment is integrated with the information processing device.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the system-class embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The information pushing method and device provided by the present application are introduced in detail above, and a specific example is applied in the text to explain the principle and the implementation of the present application, and the description of the above embodiment is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.