The current idea of seckilling program design is as follows: & nbsp; after a user participates in the seckilling process & nbsp; insert all users into the database, and then Poll & nbsp; by time until the timer is zero & nbsp; which one will be poll? this is the seckill, & nbsp; & nbsp about seckilling program design
The current idea is as follows:
After a user participates in the second kill, all users are inserted into the database, and then polling by time until the timer is zero. this is the second kill,
The polling time is one second. The problem is that if another user kills the task in seconds at the last second, when the counter is added, the polling continues,
I don't know why !!!
For the sake of attention! Thank you for sharing:
------ Solution --------------------
No, it's time to LOCK the database. What else can I ask!
------ Solution --------------------
Yes. when the time is up, the lock table cannot be inserted.
Then the stack thought, the last one inserted is the winner.
If there are more than one winner at the last moment, Round Robin
(In fact, I personally think that round inquiry is not required, and order by desc is directly handed over to mysql for query processing)
------ Solution --------------------
Listen to your second Kill. does it look like only one second?
In this case, I decided to have a countdown to the start time. when the time was reached, I allowed to purchase the product. when I bought the product, I checked whether someone had bought it, then the purchase is stopped.
Isn't that true?
------ Solution --------------------
Reference:
Wow, it makes sense, but I don't think it's reasonable.
Fairness and justice
The last-minute purchase is free of concurrency, and only one person wins the bid, which is the most fair.
If there are concurrent people who win the bidding, you can't say it's fair. Who did you say it's a good bet? It is not a random rand. it is unfair to others. This adds an rand process. it is better to directly order by for mysql to decide.
------ Solution --------------------
And set the insert time to microseconds (1 second = 1 million microseconds). I don't believe there is concurrency.
If there is still concurrency, your website is already very NB-intensive and it is no longer possible to come here to ask. There are already a large number of engineers around you.
------ Solution --------------------
Reference:
And set the insert time to microseconds (1 second = 1 million microseconds). I don't believe there is concurrency.
If there is still concurrency, your website is already very NB-intensive and it is no longer possible to come here to ask. There are already a large number of engineers around you.
Haha...