problem description
because the company has the demand for answering questions and handing out red envelopes, the activities are equivalent to giving red envelopes, and there is no concept of grabbing red envelopes. That is, there is a daily limit of, say, 10,000. For the business of sending red packets, it is more appropriate to use transactions plus locks, but looking at the online solutions, most of them recommend optimistic locks, but optimistic locks are rejected. Since our demand is to give out red packets as long as they are answered correctly, and the topic is basically to send sub-questions, it leads to a large amount of red packets
the environmental background of the problems and what methods you have tried
if you do not use the lock mechanism at the earliest, you will find that you will often overissue a few yuan, followed by an exclusive lock, and you will find that the execution of the database will be long, and a large amount of concurrent delivery will lead to blocking.