CN111210270B - Service processing method, device, service cluster, computer equipment and storage medium - Google Patents

Service processing method, device, service cluster, computer equipment and storage medium Download PDF

Info

Publication number
CN111210270B
CN111210270B CN202010003289.8A CN202010003289A CN111210270B CN 111210270 B CN111210270 B CN 111210270B CN 202010003289 A CN202010003289 A CN 202010003289A CN 111210270 B CN111210270 B CN 111210270B
Authority
CN
China
Prior art keywords
service
distributed lock
user
business
condition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010003289.8A
Other languages
Chinese (zh)
Other versions
CN111210270A (en
Inventor
梁国武
郑冬云
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Huya Technology Co Ltd
Original Assignee
Guangzhou Huya Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Huya Technology Co Ltd filed Critical Guangzhou Huya Technology Co Ltd
Priority to CN202010003289.8A priority Critical patent/CN111210270B/en
Publication of CN111210270A publication Critical patent/CN111210270A/en
Application granted granted Critical
Publication of CN111210270B publication Critical patent/CN111210270B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0207Discounts or incentives, e.g. coupons or rebates
    • G06Q30/0212Chance discounts or incentives

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Development Economics (AREA)
  • Strategic Management (AREA)
  • Finance (AREA)
  • Game Theory and Decision Science (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The embodiment of the invention discloses a service processing method, a device, a service cluster, computer equipment and a storage medium, wherein the method comprises the following steps: determining a first target service from the at least two services; the first target service receives a service object selected by a user when participating in a service, and records the service object selected by the user into a database under the condition of a distributed lock; determining a second target service from the at least two services; and under the condition of the distributed lock, the second target service determines a service object which meets the preset service condition in the database and is used as a candidate service object, selects a target service object from the candidate service object, and performs service processing on the user selecting the target service object. Aiming at the service related to the extraction user, the distributed lock is realized, and the consistency of at least two services to the database read-write is ensured, so that the service processing of at least two services in parallel is realized, and the service processing speed is improved.

Description

Service processing method, device, service cluster, computer equipment and storage medium
Technical Field
Embodiments of the present invention relate to computer technologies, and in particular, to a service processing method, an apparatus, a service cluster, a computer device, and a storage medium.
Background
Currently, many websites on the internet provide a variety of services related to extracting users in order to enhance interactions with users and enhance user viscosity.
For example, the service is a lottery drawing, i.e., drawing one user from a plurality of users, to which rewards are issued.
For another example, the service is a link in live broadcast, i.e., one user is extracted from a plurality of users, and the user is linked with the host user.
As another example, the service may be game matching, i.e., one or more users may be drawn from a plurality of users to have the users compete with the game.
These services are simpler, and when pre-developed, a single thread lock is generally used to control and record users participating in the service, and the single thread lock is used for service interface management of a single server, so that the expandability of service is poor.
With the development of the service, the number of users participating in the service is increased, and in the case of a single server, when a large number of users participate in the service at the same time, requests of users participating in the service are queued and accumulated in the server, and once the accumulation speed of the requests participating in the service exceeds the processing speed of the single server, the users are likely to fail to participate in the service.
Disclosure of Invention
The embodiment of the invention provides a service processing method, a device, a service cluster, computer equipment and a storage medium, which are used for solving the problem that a single thread lock processing service related to a user is easy to cause failure of the user to participate in service processing.
In a first aspect, an embodiment of the present invention provides a service processing method, including:
determining a first target service from the at least two services;
the first target service receives a service object selected by a user when participating in a service, and records the service object selected by the user into a database under the condition of a distributed lock;
determining a second target service from the at least two services;
and under the condition of the distributed lock, the second target service determines a service object which meets the preset service condition in the database and is used as a candidate service object, selects a target service object from the candidate service object, and performs service processing on the user selecting the target service object.
In a second aspect, an embodiment of the present invention further provides a service processing apparatus, including:
a first target service determining module for determining a first target service from at least two services;
The service registration module is used for receiving a service object selected by a user when the user participates in a service by the first target service, and recording the service object selected by the user into a database under the condition of a distributed lock;
a second target service determining module for determining a second target service from the at least two services;
and the service execution module is used for determining the service object which meets the preset service condition in the database by the second target service under the condition of the distributed lock, selecting the target service object from the candidate service objects as a candidate service object, and carrying out service processing on the user which selects the target service object.
In a third aspect, an embodiment of the present invention further provides a service cluster, where the service cluster includes at least two services;
the service is used for receiving a service object selected by a user when participating in a service when determining to be a first target service, and recording the service object selected by the user into a database under the condition of a distributed lock;
and the service is further used for determining a service object which meets a preset service condition in the database under the condition of the distributed lock when the service is determined to be a second target service, selecting a target service object from the candidate service objects as a candidate service object, and performing service processing on the user selecting the target service object.
In a fourth aspect, an embodiment of the present invention further provides a computer apparatus, including:
one or more processors;
a memory for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the business processing method as described in the first aspect.
In a fifth aspect, an embodiment of the present invention further provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor implements the service processing method according to the first aspect.
In this embodiment, a first target service is determined from at least two services, the first target service receives a service object selected by a user when participating in a service, under the condition of a distributed lock, the service object selected by the user is recorded in a database, a second target service is determined from at least two services, the second target service determines a service object meeting a preset service condition in the database under the condition of the distributed lock, the second target service is used as a candidate service object, the target service object is selected from the candidate service objects, the service processing is performed on the user of the selected target service object, and for the service related to the extracted user, the distributed lock is realized, the consistency of the at least two services on the database is ensured, so that the service processing is performed in parallel for at least two services, the processing speed of the service is improved, and when a large number of users participate in the service simultaneously, the request accumulation speed of the participating in the service is within the processing speed of the service, so that the normal participation of the user in the service is ensured.
Drawings
Fig. 1 is a flowchart of a service processing method according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of a business process according to a first embodiment of the present invention;
FIGS. 3A and 3B are exemplary diagrams of a lottery drawing provided in accordance with a first embodiment of the present invention;
fig. 4 is a schematic structural diagram of a service processing device according to a second embodiment of the present invention;
fig. 5 is a schematic structural diagram of a service cluster according to a third embodiment of the present invention;
fig. 6 is a schematic structural diagram of a computer device according to a fourth embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
Example 1
Fig. 1 is a flowchart of a service processing method according to a first embodiment of the present invention, where the method is applicable to use of a distributed lock to process a service situation related to an extracting user, and the method may be performed by a service processing apparatus, where the service processing apparatus may be implemented by software and/or hardware, and may be configured in a computer device, for example, a server, a workstation, or the like, and the method specifically includes the following steps:
S101, determining a first target service from at least two services.
As shown in fig. 2, the computer device has at least two independent services (service) 202 and at least two independent databases (such as MySQL, MS SQL, etc.) 204, where the service 202 may process, in parallel, a request 201 sent by a client and used for participating in a service, and data of an account, a service, etc. of the user are stored in the database 204, and data of one user is specified to be stored in one of the databases by means of hashing, etc.
Further, when receiving a request sent by a client for a user to participate in a service, one service is selected from the services 202 as a first target service, and a distributed lock 203 is provided for the first target service, where the first target service processes the request 201 sent by the client for the user to participate in the service under the condition of the distributed lock 203.
In particular implementations, a computer device may employ a micro-service framework that is comprised of at least two services, one of which is typically a function or feature, but the completion of this function or feature is typically accomplished by a plurality of functions in concert, so that there are many functions within a service.
Under the micro-service framework, one service can be respectively deployed on a plurality of machines in the computer equipment, the corresponding upstream and downstream processing functions of one request can be completed on the same service on different machines, and the user participation business is an interface exposed to the front end in the service.
Under the micro-service framework, a request sent by a client for a user to participate in a service is obtained through a naming service or a service registration center in the micro-service framework, and then the request is sent to a corresponding service. The service can be that one machine in the computer equipment deploys one service and monitors one port, so that multi-machine deployment is performed, or a plurality of services can be deployed on one machine in the computer equipment, each service monitors different ports, of course, the latter is limited by the performance of the machine, single-point faults exist, and the production environment is less used.
In addition, the embodiment can also apply a non-micro service framework, under the non-micro service framework, a request sent by a client for users to participate in a service can be directly sent to a port on the computer device through an nmginx reverse proxy mechanism (such as polling, weighted polling, hash and the like), and a service monitors the corresponding port to receive the request.
S102, the first target service receives a service object selected by a user when the user participates in the service, and records the service object selected by the user into a database under the condition of a distributed lock.
In this embodiment, after the first target service is selected, the first target service receives a service object sent by the client and selected by the user when participating in the service.
For different services, there may be different service objects, i.e. objects with service features.
For example, for a lottery, the business object may be a ticket; for the link wheat in live broadcast, the service object can be the confirmation information for applying for the link wheat; for games, the business object may be a game pattern (e.g., one-player, two-player, five-player), and so on.
Business objects, while carrying different business characteristics, are still data in nature, e.g., text data, image data, audio data, video data, etc.
Under the condition of a distributed lock, the first target object records the business object selected by the user into a database, thereby realizing the registration of the user to participate in the business.
In one embodiment of the invention, S102 comprises the following steps (the following steps are not shown in the drawings of the specification):
s1201, obtain a distributed lock.
In this embodiment, the first target service application obtains a distributed lock.
The distributed locks may have mutual exclusion or may have shared (read-write locks), and in this embodiment, the distributed locks involved are used to control writing of user data, and the distributed locks with multiple writing and fewer reading are used.
The distributed lock mutex can be used for scheduling a plurality of services and preventing mutual interference among the plurality of services, namely when one service adds the mutex distributed lock successfully, other services cannot lock the same lock.
If the acquisition of the distributed lock is successful, execution continues with S1202 where the business value of the business object is deducted from the user' S account in the database.
If the acquisition of the distributed lock fails, generating information of failure of the user to participate in the service.
Further, the method of acquiring a distributed lock depends on the implementation of the distributed lock.
For example, when implementing a distributed lock with Redis, the lock function/method is to call setnx command to attempt to add the same key (i.e. the same handle lock) to the same Redis service request, if there is no such key in Redis, then the lock is returned to be successful, if there is such key in Redis, then the lock is returned to be failed, redis command execution is atomic, i.e. successful or failed, and no intermediate state occurs.
For another example, when implementing a distributed lock with a ZooKeeper, the locking function/method is to first create a temporary node to the same ZooKeeper cluster under the same path using an access () (the specific function name depends on the library used by the programming language), then the ZooKeeper determines whether the created temporary node sequence number is minimum, if so, the locking is successful, otherwise the locking fails. Likewise, only one node with the smallest sequence number is available at the same time. When the distributed lock is realized, in order to optimize user experience, the locking function still retries locking within a certain time after one locking failure, so that the background service can process the request of the user to the maximum extent.
In one embodiment of the present invention, before S1201, the user may be further verified with permission, that is, whether the user has permission to participate in the service, so as to ensure normal operation of the service.
And under the conditions of freezing the account number, logging in the account number, and the like, the authentication of the authority cannot be passed.
If the authentication authority is successful, S1201 may be continued.
If the verification authority fails, generating information that the user fails to participate in the service.
S1202, deducting the business value of the business object from the account of the user in a database under the condition of the distributed lock.
Under the condition that the first target service acquires the distributed lock, other services cannot acquire the same distributed lock, namely cannot operate the database, and at the moment, the operation of deducting the business value of the business object from the account of the user in the database by the first target service can avoid collision with other services.
In one example, the business object is a ticket, each ticket marks a business value, such as a virtual token, that the user can use to replace various value added services in the computer device, such as a membership service, a play object, a lottery ticket, and so on.
The first target service searches the account of the user in the database, the account records the business value owned by the user, and the business value of the business object is deducted from the account of the user, so that the business object is converted.
Further, for live broadcast, the audience user can use to select to exchange the virtual gift and give the virtual gift to the anchor user, when the virtual token of the virtual gift meets a certain value, the virtual gift can be exchanged for the corresponding lottery, and at this time, the value of the virtual gift can be regarded as the service value corresponding to the service object.
If the deduction of the business value is successful, the process may continue to S1203, where the business object selected by the user is written into the database.
And if the deduction of the service value fails, releasing the distributed lock to generate information of failure of the user to participate in the service.
And S1203, writing the business object selected by the user into the database under the condition of the distributed lock.
Under the condition that the first target service acquires the distributed lock, other services cannot acquire the same distributed lock, namely the database in which the first target service is operating cannot be operated, and of course, other services can also operate other databases, and at the moment, the first target service can avoid conflict with other services when writing a business object selected by a user in the database.
If the write to the business object fails, then the first target service releases the distributed lock in continuing to execute S1204.
If the writing of the business object fails, business values of the business object are added into the database and the account of the user, the distributed lock is released, and information of the user participating in the business failure is generated.
S1204, releasing the distributed lock.
In a specific implementation, the method of releasing the distributed lock depends on the implementation of the distributed lock.
For example, when a distributed lock is implemented with Redis, the function/method of releasing the distributed lock is to execute del instructions.
For another example, when a distributed lock is implemented with a ZooKeeper, the function/method of releasing the distributed lock is to delete the corresponding child node.
S103, determining a second target service from the at least two services.
In this embodiment, the execution interface of the service is an internal automatic timing call of the service, and in order to increase the versatility, the service may be exposed to the front end and manually executed by other roles.
For example, if the service is a lottery, a timed automatic lottery may be set, or the lottery may be manually performed by a host user or an operator user in the live broadcast.
When receiving a request for executing the service, selecting one service from the services as a second target service, and providing a distributed lock for the second target service, wherein the second target service executes the service under the condition of the distributed lock.
For the case of automatic timing execution of a service, a unique timing service can be set, the timer service makes cluster configuration for fault tolerance, if the timer service is applied in a ZooKeeper, the ZooKeeper ensures that only one timer service on one machine can initiate a timing request at the same time, and when the designated time is reached, the timing service calls an execution interface of the service, and because the timing service is unique, the timing service is executed by routing a frame (a micro service frame or a non-micro service frame) to the service on one machine when the timing service calls the execution interface of the service.
For the case where other roles manually execute the service, the request sent by the client to execute the service by other roles may be routed by the framework (micro-service framework or non-micro-service framework) to the service on one machine.
And S104, under the condition of the distributed lock, the second target service determines a service object which meets the preset service condition in the database and is used as a candidate service object, selects a target service object from the candidate service object, and performs service processing on the user selecting the target service object.
In this embodiment, after the second target service is selected, the second target service receives a request for executing a service, and determines, in response to the request, a service object in the database that satisfies a preset service condition under the condition of the distributed lock, as a candidate service object, as an optional scope.
The set business conditions are also different for different business objects.
For example, if the business object is a coupon, the business condition may be a desire for revenue; if the service object is the confirmation information for applying for the wheat connection, the service condition can be the time for confirming the wheat connection application and the grade of the user; if the business object is a game mode, the business condition may be the user's region, the user's level (or score), and so on.
The second target service selects a target service object from the candidate service objects by means of random, specified probability, etc., and performs service processing, such as, for example, redemption, connection, starting a game, etc., on the user of the selected target service object.
In one embodiment of the invention, for selecting a candidate business object, S104 includes the following steps (the following steps are not shown in the drawing of the specification):
s1041, acquiring a distributed lock.
In this embodiment, the second target service application obtains a distributed lock, where the distributed locks are mutually exclusive.
If the acquisition of the distributed lock is successful, S1042 is continued to read the service object in the service in the database.
If the acquisition of the distributed lock fails, generating information of service failure.
S1042, under the condition of the distributed lock, inquiring the service object in the service in the database.
Under the condition that the second target service acquires the distributed lock, other services cannot acquire the same distributed lock, namely cannot operate the database in which the second target service is operating, and of course, other services can also operate other databases, and at the moment, the second target service can avoid conflict with other services when reading the business object in the business.
If the query of the business object is successful, S1043 is continuously executed, and the sum of the business values of all the business objects in the business is read as the total income value.
And if the query service object fails, releasing the distributed lock to generate service failure information.
S1043, under the condition of the distributed lock, reading the sum of service values of all the service objects in the service in the database to obtain a total income value.
Under the condition that the second target service acquires the distributed lock, other services cannot acquire the same distributed lock, namely cannot operate the database in which the second target service is operating, and of course, other services can also operate other databases, and at this time, the operation that the second target service reads the sum of the service values of all the service objects participating in the same service in the database can avoid collision with other services.
Further, the business objects have written in business values when the database is stored, and the second target service can directly read the sum of the business values of all the business objects through the summation instruction of the database.
If the total income value is successfully read, S1044-S1046 may be continuously performed, the available income value is calculated, the total expenditure value of each type of business object is predicted, and the business object satisfying the preset business condition is determined.
And if the total income value is not read, releasing the distributed lock to generate information of service failure.
S1044, deducting the appointed proportion on the basis of the total business value to be used as the available income value.
In this embodiment, a ratio, such as 1%, may be preset as the cost of executing the service, and the second target service deducts the ratio on the basis of the total service value as the available income value (such as 99% of the total service value).
S1045, predicting the total expenditure value of each class of the business objects.
In this embodiment, the service object has multiple categories, and each category of service object is provided with a corresponding service value and a service coefficient, where the service coefficient is a positive number greater than 1.
For example, for a coupon, the business factor is the odds plus 1.
In general, the business coefficient of a business object is positively correlated with a business value, i.e., the larger the business value, the larger the business coefficient, and conversely, the smaller the business value, the more the business coefficient is.
The second target service may calculate a total payout value for each type of business object using the business data value and the business coefficient, i.e., the sum of the products of the business values and the business coefficients of the same type of business object as the total payout value.
S1046, if the available income value is larger than the total expenditure value, determining that the business object meets the preset business condition.
The second target service may compare the available revenue value with the total expense value, and if the available revenue value is greater than the total expense value, determine that the class of business objects satisfy the preset business condition; if the available revenue value is less than or equal to the total expense value, it is determined that the class of business objects do not meet the preset business conditions.
Further, if the second target service does not find the service object meeting the service condition, the distributed lock is released, and the service execution fails.
In one embodiment of the present invention, for business processing, S104 includes the steps of:
s1047, determining the single expenditure value of the target business object.
In this embodiment, the single payout value is the product of the business value of the target business object and the business coefficient.
S1048, writing the single payout value to an account of a user selecting the target business object in the database under the distributed lock condition.
In the case that the second target service acquires the distributed lock, other services cannot acquire the same distributed lock, that is, cannot operate the database in which the second target service is operating, and of course, other services may also operate other databases, where the operation that the second target service writes the single payout value into the account of the user of the selected target service object in the database may avoid a conflict with other services.
S1049, releasing the distributed lock.
The distributed lock may be released when the second target service completes the business while writing a single payout value to the account of the user of the selected target business object.
For a better understanding of the present embodiment by those skilled in the art, a lottery will be described as an example of a service.
In live broadcast, microblog, etc., in order to improve the interaction between a user and a host such as a host, a microblog host, etc., a lottery drawing service is generally provided.
In this example, the host issues a lottery drawing through the client and sets corresponding lottery tickets (Icon of the lottery ticket may be a box, a pouch, etc.), each of which is configured with price (business value), odds (convertible into business coefficient), odds of winning of the virtual token.
Further, the lottery ticket includes 3 kinds as follows:
the price of the one-star lottery is 1, the odds of the pays are 0.5 (namely, the service coefficient is 1.5), and the winning probability is 60%;
the price of the two-star lottery ticket is 2, the odds ratio of the two-star lottery ticket is 1.0 (namely, the service coefficient is 2.0), and the winning probability is 30%;
the three-star lottery had a price of 5, a odds of 3.0 (i.e., a business coefficient of 4.0), and a winning probability of 10%.
As shown in fig. 3A, the client of the user displays an interface, in which a one-star lottery, a two-star lottery, and a three-star lottery are displayed, and when the user selects to click on the "exchange" control corresponding to the one-star lottery and clicks on the "confirm" control, the client sends a request for participating in a service to the server (computer device).
The server is configured with at least two services and at least two databases, and after receiving a request for participating in a service, the server routes the request to one of the services for processing, wherein the service is the first target service.
After verifying that the user has the authority to participate in lottery drawing, the first target service applies for the distributed lock, deducts 1 virtual token from the database and the account of the user under the condition that the distributed lock is successfully obtained, registers that the user participates in the lottery drawing, and releases the distributed lock.
After a lottery is released for a period of time, the host determines the lottery drawing, at this time, the client displays a control for determining the lottery drawing, the host clicks the control, and the client sends a request for executing the service to the server.
After receiving the request for executing the service, the server routes the service to one of the services for processing, wherein the service is the second target service.
After verifying that the host has the authority of drawing the lottery, the second target service applies for the distributed lock, and under the condition that the distributed lock is successfully obtained, a list of users participating in the lottery is queried in a database, and the total income value of the local lottery is read.
In this lottery, it is assumed that 50 users participate in the lottery in total, 35 users select one-star lottery, 20 users select two-star lottery, and 5 users select three-star lottery.
Total income value=35×1+20×2+5×5=100
The available revenue value=100-100×1% =99
Total payout value of one-star lottery ticket=35×1.5=52.5 < 99
Total payout value of two-star lottery ticket=20×2=40 < 99
Total payout value of three-star lottery ticket= 5*4 =20 < 99
Therefore, the first-star lottery, the second-star lottery, and the third-star lottery each satisfy lottery conditions (service conditions) and can be candidate lottery (candidate service object), and in this case, the lottery can be drawn with a winning probability of 60% for the first-star lottery, 30% for the second-star lottery, and 10% for the third-star lottery.
Assuming that a two-star lottery (target business object) is drawn, on the one hand, the second target service calculates a single payout value of the two-star lottery=2×2=4.
The second target service, upon acquiring the distributed lock, writes 4 virtual tokens in the database, in the account of each user that chooses to redeem the two-star ticket, and releases the distributed lock.
On the other hand, as shown in fig. 3B, the user's client displays an interface in which the winning ticket is a two-star ticket, and a list of winning users is displayed.
In this embodiment, a first target service is determined from at least two services, the first target service receives a service object selected by a user when participating in a service, under the condition of a distributed lock, the service object selected by the user is recorded in a database, a second target service is determined from at least two services, the second target service determines a service object meeting a preset service condition in the database under the condition of the distributed lock, the second target service is used as a candidate service object, the target service object is selected from the candidate service objects, the service processing is performed on the user of the selected target service object, and for the service related to the extracted user, the distributed lock is realized, the consistency of the at least two services on the database is ensured, so that the service processing is performed in parallel for at least two services, the processing speed of the service is improved, and when a large number of users participate in the service simultaneously, the request accumulation speed of the participating in the service is within the processing speed of the service, so that the normal participation of the user in the service is ensured.
Example two
Fig. 4 is a schematic structural diagram of a service processing device according to a second embodiment of the present invention, where the device may specifically include the following modules:
a first target service determining module 401 for determining a first target service from at least two services;
a service registration module 402, configured to receive, by the first target service, a service object selected by a user when participating in a service, and record, under a distributed lock condition, the service object selected by the user into a database;
a second target service determining module 403, configured to determine a second target service from the at least two services;
and the service execution module 404 is configured to determine, by the second target service under the condition of a distributed lock, a service object in the database that meets a preset service condition, as a candidate service object, select a target service object from the candidate service objects, and perform service processing on a user that selects the target service object.
In one embodiment of the present invention, the service registration module 402 includes:
the first lock acquisition sub-module is used for acquiring the distributed locks, and the distributed locks are mutually exclusive;
a service value deduction sub-module, configured to deduct a service value of the service object from the account of the user in a database under the condition of the distributed lock;
A business object writing sub-module, configured to write, in the database, the business object selected by the user under the condition of the distributed lock;
and the first lock release submodule is used for releasing the distributed lock.
In one embodiment of the present invention, the service registration module 402 further includes:
the permission verification sub-module is used for verifying the permission of the user;
the first failure processing sub-module is used for generating information of the user participating in the service failure if the authority verification fails;
and/or the number of the groups of groups,
the second failure processing sub-module is used for generating information of failure of the user to participate in the service if the distributed lock is failed;
and/or the number of the groups of groups,
the third failure processing sub-module is used for releasing the distributed lock if deducting the service value failure, and generating information of the user participating in the service failure;
and/or the number of the groups of groups,
and the fourth failure processing sub-module is used for adding the business value of the business object to the account of the user in the database if the writing of the business object fails, releasing the distributed lock and generating the information of the user participating in the business failure.
In one embodiment of the present invention, the service execution module 404 includes:
The second lock acquisition sub-module is used for acquiring the distributed locks, and the distributed locks are mutually exclusive;
a service object inquiring sub-module, configured to inquire a service object in the service in the database under the condition of the distributed lock;
the total income value reading submodule is used for reading the sum of service values of all service objects in the service in the database under the condition of the distributed lock to obtain a total income value;
the available income value calculation sub-module is used for deducting the appointed proportion on the basis of the total business value to be used as the available income value;
a total expense value calculation sub-module, configured to predict a total expense value of each type of the service objects, where the total expense value is the sum of products of service values and service coefficients of the service objects in the same type;
and the satisfaction determining submodule is used for determining that the business objects meet preset business conditions if the available income numerical value is larger than the total expenditure numerical value.
In one embodiment of the present invention, the service execution module 404 further includes:
a fifth failure processing sub-module, configured to generate information of the service failure if the acquisition of the distributed lock fails;
And/or the number of the groups of groups,
a sixth failure processing sub-module, configured to release the distributed lock if the query of the service object fails, and generate information of the service failure;
and/or the number of the groups of groups,
a seventh failure processing sub-module, configured to release the distributed lock if the reading of the total income value fails, and generate information of the service failure;
and/or the number of the groups of groups,
and the eighth failure processing sub-module is used for releasing the distributed lock if the service object meeting the service condition is not found.
In one embodiment of the present invention, the service execution module 404 includes:
a single expense value calculation sub-module, configured to determine a single expense value of the target service object, where the single expense value is a product of a service value of the target service object and a service coefficient;
a single payout value writing sub-module for writing the single payout value in the database to an account of a user who selected the target business object under the distributed lock condition;
and the second lock release sub-module is used for releasing the distributed lock.
The service processing device provided by the embodiment of the invention can execute the service processing method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example III
Fig. 5 is a schematic structural diagram of a service cluster 500 according to a third embodiment of the present invention, where the service cluster 500 includes at least two services 510;
the service 510 is configured to, when determining that the service is the first target service, receive a service object selected by a user when participating in a service, and record the service object selected by the user into a database under a condition of a distributed lock;
the service 510 is further configured to determine, when determining that the service is the second target service, under the condition of the distributed lock, a service object in the database that meets a preset service condition, and select, as a candidate service object, a target service object from the candidate service objects, and perform service processing on a user that selects the target service object.
In one embodiment of the present invention, the service 510 is further configured to:
acquiring a distributed lock, wherein the distributed lock is mutually exclusive;
deducting a business value of the business object from an account of the user in a database under the condition of the distributed lock;
writing the business object selected by the user into the database under the condition of the distributed lock;
releasing the distributed lock.
In one embodiment of the present invention, the service 510 is further configured to:
Verifying the authority of the user;
if the authority verification fails, generating information that the user fails to participate in the service;
and/or the number of the groups of groups,
if the distributed lock fails to be acquired, generating information of failure of the user to participate in the service;
and/or the number of the groups of groups,
if deducting the service value fails, releasing the distributed lock, and generating information of the failure of the user to participate in the service;
and/or the number of the groups of groups,
if the writing of the business object fails, business values of the business object are added to the account of the user in the database, the distributed lock is released, and information of the user participating in the business failure is generated.
In one embodiment of the present invention, the service 510 is further configured to:
acquiring a distributed lock, wherein the distributed lock is mutually exclusive;
under the condition of the distributed lock, querying a service object in the service in the database;
under the condition of the distributed lock, reading the sum of service values of all service objects in the service in the database to obtain a total income value;
deducting a specified proportion on the basis of the total business value to be used as an available income value;
predicting the total expenditure value of each class of the business objects, wherein the total expenditure value is the sum of products of the business values and the business coefficients of the same class of the business objects;
And if the available income numerical value is larger than the total expenditure numerical value, determining that the service object meets the preset service condition.
In one embodiment of the present invention, the service 510 is further configured to:
if the distributed lock fails to be acquired, generating information of the service failure;
and/or the number of the groups of groups,
if the query of the service object fails, releasing the distributed lock to generate information of the service failure;
and/or the number of the groups of groups,
if the total income numerical value is read to be failed, releasing the distributed lock to generate information of the service failure;
and/or the number of the groups of groups,
and if the service object meeting the service condition is not found, releasing the distributed lock.
In one embodiment of the present invention, the service 510 is further configured to:
determining a single payout value of the target business object, wherein the single payout value is a product of a business value of the target business object and a business coefficient;
writing the single payout value in the database to an account of a user selecting the target business object under the distributed lock condition;
releasing the distributed lock.
The computer equipment provided by the embodiment of the invention can execute the service processing method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 6 is a schematic structural diagram of a computer device according to a fourth embodiment of the present invention. As shown in fig. 6, the computer apparatus includes a processor 600, a memory 601, a communication module 602, an input device 603, and an output device 604; the number of processors 600 in the computer device may be one or more, one processor 600 being taken as an example in fig. 6; the processor 600, the memory 601, the communication module 602, the input means 603 and the output means 604 in the computer device may be connected by a bus or other means, in fig. 6 by way of example.
The memory 601, as a computer-readable storage medium, may be used to store a software program, a computer-executable program, and modules such as modules corresponding to the service processing method in the present embodiment (e.g., a first target service determination module 401, a service registration module 402, a second target service determination module 403, and a service execution module 404 in the service processing apparatus shown in fig. 4, or a service 510 in the computer device shown in fig. 5). The processor 600 executes various functional applications of the computer device and data processing, i.e., implements the above-described connection method, by running software programs, instructions, and modules stored in the memory 601.
The memory 601 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for functions; the storage data area may store data created according to the use of the computer device, etc. In addition, the memory 601 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 601 may further include memory located remotely from processor 600, which may be connected to a computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
And the communication module 602 is used for establishing connection with the display screen and realizing data interaction with the display screen.
The input means 603 may be used for receiving input numeric or character information and generating key signal inputs related to user settings and function control of the computer device, as well as a camera for capturing images and a sound pickup device for capturing audio data.
The output means 604 may comprise an audio device such as a speaker.
The specific composition of the input device 603 and the output device 604 may be set according to the actual situation.
The processor 600 executes various functional applications of the device and data processing by running software programs, instructions and modules stored in the memory 601, i.e., implements the above-described connection node control method of the electronic whiteboard.
The computer device provided in this embodiment may execute the service processing method provided in any one of the embodiments of the present invention, and specifically, the corresponding functions and beneficial effects.
Example five
A fifth embodiment of the present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a service processing method, the method comprising:
determining a first target service from the at least two services;
the first target service receives a service object selected by a user when participating in a service, and records the service object selected by the user into a database under the condition of a distributed lock;
determining a second target service from the at least two services;
and under the condition of the distributed lock, the second target service determines a service object which meets the preset service condition in the database and is used as a candidate service object, selects a target service object from the candidate service object, and performs service processing on the user selecting the target service object.
Of course, the computer readable storage medium provided by the embodiments of the present invention, the computer program thereof is not limited to the method operations described above, and may also perform the related operations in the service processing method provided by any embodiment of the present invention.
From the above description of embodiments, it will be clear to a person skilled in the art that the present invention may be implemented by means of software and necessary general purpose hardware, but of course also by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, etc., and include several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments of the present invention.
It should be noted that, in the embodiment of the service processing apparatus, each unit and module included are only divided according to the functional logic, but are not limited to the above-mentioned division, so long as the corresponding functions can be implemented; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present invention.
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.

Claims (10)

1. A method for processing a service, comprising:
determining a first target service from the at least two services;
the first target service receives a service object selected by a user when participating in a service, and records the service object selected by the user into a database under the condition of a distributed lock;
determining a second target service from the at least two services;
and under the condition of the distributed lock, the second target service determines a service object which meets the preset service condition in the database and is used as a candidate service object, selects a target service object from the candidate service object, and performs service processing on the user selecting the target service object.
2. The method of claim 1, wherein said recording said user-selected business object into a database under distributed lock conditions comprises:
acquiring a distributed lock, wherein the distributed lock is mutually exclusive;
deducting a business value of the business object from an account of the user in a database under the condition of the distributed lock;
writing the business object selected by the user into the database under the condition of the distributed lock;
releasing the distributed lock.
3. The method of claim 2, wherein the recording the user-selected business object in a database under distributed lock conditions further comprises:
verifying the authority of the user;
if the authority verification fails, generating information that the user fails to participate in the service;
and/or the number of the groups of groups,
if the distributed lock fails to be acquired, generating information of failure of the user to participate in the service;
and/or the number of the groups of groups,
if deducting the service value fails, releasing the distributed lock, and generating information of the failure of the user to participate in the service;
and/or the number of the groups of groups,
if the writing of the business object fails, business values of the business object are added to the account of the user in the database, the distributed lock is released, and information of the user participating in the business failure is generated.
4. The method according to claim 1, wherein the determining, in the distributed lock condition, the service object in the database that satisfies the preset service condition includes:
acquiring a distributed lock, wherein the distributed lock is mutually exclusive;
under the condition of the distributed lock, querying a service object in the service in the database;
under the condition of the distributed lock, reading the sum of service values of all service objects in the service in the database to obtain a total income value;
deducting a specified proportion on the basis of the total income value to be used as an available income value;
predicting the total expenditure value of each class of the business objects, wherein the total expenditure value is the sum of products of the business values and the business coefficients of the same class of the business objects;
and if the available income numerical value is larger than the total expenditure numerical value, determining that the service object meets the preset service condition.
5. The method of claim 4, wherein the determining, in the distributed lock condition, the business object in the database that satisfies the preset business condition further comprises:
if the distributed lock fails to be acquired, generating information of the service failure;
And/or the number of the groups of groups,
if the query of the service object fails, releasing the distributed lock to generate information of the service failure;
and/or the number of the groups of groups,
if the total income numerical value is read to be failed, releasing the distributed lock to generate information of the service failure;
and/or the number of the groups of groups,
and if the service object meeting the service condition is not found, releasing the distributed lock.
6. The method according to any one of claims 1-5, wherein said performing a business process on a user selecting said target business object comprises:
determining a single payout value of the target business object, wherein the single payout value is a product of a business value of the target business object and a business coefficient;
writing the single payout value in the database to an account of a user selecting the target business object under the distributed lock condition;
releasing the distributed lock.
7. A service processing apparatus, comprising:
a first target service determining module for determining a first target service from at least two services;
the service registration module is used for receiving a service object selected by a user when the user participates in a service by the first target service, and recording the service object selected by the user into a database under the condition of a distributed lock;
A second target service determining module for determining a second target service from the at least two services;
and the service execution module is used for determining the service object which meets the preset service condition in the database by the second target service under the condition of the distributed lock, selecting the target service object from the candidate service objects as a candidate service object, and carrying out service processing on the user which selects the target service object.
8. A service cluster, characterized in that the service cluster comprises at least two services;
the service is used for receiving a service object selected by a user when participating in a service when determining to be a first target service, and recording the service object selected by the user into a database under the condition of a distributed lock;
and the service is further used for determining a service object which meets a preset service condition in the database under the condition of the distributed lock when the service is determined to be a second target service, selecting a target service object from the candidate service objects as a candidate service object, and performing service processing on the user selecting the target service object.
9. A computer device, the computer device comprising:
One or more processors;
a memory for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the traffic processing method of any of claims 1-6.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the service processing method according to any of claims 1-6.
CN202010003289.8A 2020-01-02 2020-01-02 Service processing method, device, service cluster, computer equipment and storage medium Active CN111210270B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010003289.8A CN111210270B (en) 2020-01-02 2020-01-02 Service processing method, device, service cluster, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010003289.8A CN111210270B (en) 2020-01-02 2020-01-02 Service processing method, device, service cluster, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111210270A CN111210270A (en) 2020-05-29
CN111210270B true CN111210270B (en) 2023-06-20

Family

ID=70786598

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010003289.8A Active CN111210270B (en) 2020-01-02 2020-01-02 Service processing method, device, service cluster, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111210270B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112231330A (en) * 2020-10-15 2021-01-15 中体彩科技发展有限公司 Control method and system for preventing lottery game from being repeated and rewarded
CN112463318B (en) * 2020-11-17 2024-05-17 深圳市优必选科技股份有限公司 Timing task processing method, device and system
CN113535762B (en) * 2021-07-14 2024-01-26 北京数码视讯支付技术有限公司 Secure account payment method and device
CN114996031B (en) * 2022-08-03 2022-12-27 飞狐信息技术(天津)有限公司 Lottery drawing method and related device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109656724A (en) * 2018-09-27 2019-04-19 深圳壹账通智能科技有限公司 Method for processing business, device, equipment and computer readable storage medium
CN110032424B (en) * 2019-01-28 2023-10-20 创新先进技术有限公司 Method and device for realizing distributed lock
CN110231979A (en) * 2019-05-07 2019-09-13 深圳壹账通智能科技有限公司 Transaction methods, device, equipment and storage medium based on block chain
CN110502523A (en) * 2019-08-01 2019-11-26 广东浪潮大数据研究有限公司 Business datum storage method, device, server and computer readable storage medium

Also Published As

Publication number Publication date
CN111210270A (en) 2020-05-29

Similar Documents

Publication Publication Date Title
CN111210270B (en) Service processing method, device, service cluster, computer equipment and storage medium
CN111405304B (en) Anchor interaction method and device, computer equipment and storage medium
CN108235102B (en) Service processing method, device and storage medium
CN104967607B (en) A kind of information processing method, terminal and server
CN110830735B (en) Video generation method and device, computer equipment and storage medium
WO2020082892A1 (en) Blockchain-based transaction processing method and apparatus, and electronic device
WO2017109140A1 (en) Decentralized, tamper-resistant, asset-oriented database system and method of recording a transaction
CN104168271A (en) Interactive system, server, clients and interactive method
CN106157071A (en) A kind of method and system of public&#39;s account prize drawing
CN109428910B (en) Data processing method, device and system
CN106358065A (en) Multimedia information processing method and system
CN110517145A (en) Data trade method and relevant device based on multi-tiling interchain
CN114245149A (en) Virtual resource allocation method, device and system, electronic equipment and storage medium
CN112651836A (en) Copyright distribution method and device based on block chain
CN106022009A (en) Media information sharing processing method and device
CN110139114A (en) Processing method, device, computer equipment and the storage medium of fictitious assets data
CN110210922B (en) Information display resource allocation method and device, computer equipment and storage medium
CN107408164B (en) Digital management of content assets in the cloud
CN110490590A (en) Activation record querying method, device, equipment and storage medium based on block chain
CN111222885B (en) Data processing request endorsement method and device, computer equipment and storage medium
JP2023115165A (en) Information processing device and program
CN107734396B (en) A kind of multimedia resource playback method, device and storage medium
CN110262892A (en) A kind of ticketing service dissemination method based on distributed storage data-link, device and data-link node
WO2019026327A1 (en) Game system, computer program for use with same, and server device
CN106776947A (en) Resource acquiring method, device and terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant