Spike thinking: yii2 add Redis to achieve spike

Finishing some ideas  

  • PHP7, yii2 add Redis how to achieve spike
  1. A list of list of goods stored spike
  2. A list a list of customer information stored spike

First read spike commodity to commodity list, and then wait for customers to spike. 

    1. Every customer requests,
      1. Check the list of users and quantity is greater than equal to. If it has been suggested to grab finished. Next time. (Here the user can select a single program or reducing payments further reduced)
      2. The remaining quantity inspection of goods is greater than 0, it is decremented by one, and added to the list of customers inside. No tips have been robbed on the finish. Next time. (Here the user can select a single program or reducing payments further reduced)
      3. Every customer requests, adding to the list of customers inside. Wait for payment. Payment check ?? inspection of goods remaining number is greater than zero, it is decremented by one, whether it has been suggested to grab finished. Next time.
      4. (Focus on the above method is problematic, high concurrency conflict situations if there will still be possible to read and write at the same time, consider locking, plus the transaction, especially when the number of updates minus one wants to bring out the last query the number of stocks, but at the same time requested operation could not be locked, then high concurrency.)
      5. Another program, is directly in the database with the data release, plus a version field, as a condition of every write. If the wrong version, you can use while re-control operation several times requested, also allows users to submit again.

 

Guess you like

Origin www.cnblogs.com/stillstep/p/11056479.html