Limit traffic

Static resource
  • Static resources how to need a CDN, or buy a server also have to spend money, but also configuration, more trouble
  • With the CDN, the URL of the seckill page can be bound to a domain name, nothing else needs to be configured
interface
  • Gateway total limited flow function, according to the demand of 80% of the traffic directly back to snap up the failure message, 20% of the traffic normally into seckill strategy
At this point, most of the traffic has been diluted, following the normal seckill strategy.

Seconds kill strategy

This paper uses concurrent lock, concurrent lock better support business

Concurrent lock
  • redis setnx
  • Distributed concurrent locking
variable
  • Limit – Number of seconds killed
  • Product – A unique label for a product
  • Project – Kills the unique tag of the project
  • Book – Real-time generated order table (UUID, status)
  • InervalBook – Monitor the book timer, real-time update book, you can view the current order number through the book, and whether the user already exists
  • InervalOver – Monitors the book timer to check whether all the orders in the book have been paid in real time. When the limit is reached, the end tag is set and the activity ends
  • If you need to update inventory in real time, you can set a timer
interface
  • CheckOrder – Single interface
  • GetOrderStatuss – Interface for querying orders. This interface returns the order status list according to the UUIDS list to update books in real time
process

The redis concurrency lock is insufficient

conclusion

Generally, the payment order is valid for 15 minutes. If a user does not pay in 15 minutes or does not pay until it expires, an inventory will be wasted; If the inventory is full, but the actual purchase volume is not full, let’s say we set the new user to grab it and return the message “all of it”, then the user will not grab it and waste a quota. Let’s say we have a rule to return “please continue”, so the user continues to fight for 15 minutes, and the experience is poor. In view of the above problems, we can appropriately expand the inventory according to our experience. For example, it is expected that 100 units will be killed by seconds, so the inventory can be increased to 105 units. In this way, when 105 orders are generated, we can directly return to “snatched up”, so as to ensure that the expected sales can still be achieved even when some customer orders fail.