Ask a typical question about time control.

Source: Internet
Author: User
Ask a typical question about time control business about a preemptive speech. suppose there are 1000 users who can speak first in five seconds, and only one person can speak; no one can speak in five seconds. due to customer requirements, the session cannot be used. in this case, I create a statement table tableWords in the database, if the first user asks a typical question about time control
For example, if 1000 users speak first within five seconds, and only one user can speak first, no one can speak in five seconds.
The session cannot be used due to customer requirements.

I handled it like this.
Create a statement table tableWords in the database. if the first user wants to speak first, add a record, and other users are scrambling to speak. if there is a record in the table, do not allow the user to speak;

This does not seem to be a problem, but considering the concurrency, it is very likely that many of the 1000 users performed the insert operation in the same millisecond. how can we only let one user insert?


------ Solution --------------------
Your worries are superfluous.
Even if these 1000 users send requests in the same microsecond, only one user's request is responded at the first time. Others are only waiting in the queue.
------ Solution --------------------
Transaction File lock semaphore lock, used to determine the user's qualification to speak


You can also rely on the unique index of the database. Can the field be determined by the topic id? And so on. In short, it must be unique. Obviously, this will meet your needs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.