Soon to double 11, to talk about how to design a second kill system architecture




Technical challenges

1. Impact on existing businesses

The second kill activity is only an additional activity of website marketing, which is characterized by short time and large concurrent visits. If it is deployed with the original application of the website, it will inevitably impact the existing business.

Solution: Deploy the seckill system independently, even using a separate domain name, so that it is completely isolated from the website.

2. Database and application load under high concurrency

Users make sure they don’t miss the seconds kill by refreshing the browser page before the seconds kill starts, and these requests are accessed according to the normal website application architecture

Application server, connect database,

This puts a load on the application server and database server.

Solution: redesign the second kill product page, do not use the site’s original product details page, page content static, user requests do not need to go through

Application service

3. Sudden increase in server and network bandwidth

Assuming the product page size is 200K, the bandwidth for 10,000 requests is 2G.

Solution: The new network bandwidth must be purchased or leased from the carrier. To take the strain off the site’s servers,

You need to cache the kill item page to the CDN

4. Avoid placing orders before seconds kill

The rules of the game is to kill seconds to start the purchase of goods, before this time point, can only browse the information of goods, can not place an order. And the order page is also a common URL, if you get this URL, do not have to wait until the second kill can be ordered.

Solution: In order to prevent users from directly accessing the ordering page URL, the change URL needs to be dynamic, so that even the developers of the seckill system cannot access the ordering page URL before seckill starts. The method is to add a random number generated by the server as a parameter in the order page URL, which can be obtained at the beginning of the second kill.

Coping strategies

1. Independent deployment

And the original business deployed on a different server, to prevent high concurrency down the entire site

2. Make the page static

Static product details and descriptions to the page

3. Lease the bandwidth

Lease bandwidth from the carrier

4. Dynamically generate random order page URL

Unable to access the order page URL before the seckill: add a random number generated by the server as a parameter, which can only be obtained before the seckill starts

Architecture design

1. Control the lighting of the second kill purchase page

The purchase button will only be lit at the start of the campaign and will be grey until then. This can be easily solved if the page is dynamic, but to reduce the server-side load,

Better use of CDN, reverse proxy and other performance optimization means,

The page is designed to be static, cached on the CDN, reverse proxy server, and even on the user’s browser. When a seckill starts, the user refreshes the page and the request never reaches the application server at all.

Solution: Add a javascript reference to the seckill page, which adds the flag of whether the seckill has started and the random number parameter of the order page URL. This javascript uses a random version number and cannot be cached by the browser

When seckill starts, a new javascript file is generated and loaded by the user’s browser




2. Allow the first order to be submitted

Since only one user can successfully kill the product in the end, it is necessary to check whether the order has been submitted before the user submits the order.

Solution: In order to reduce the load pressure of the ordering page server, we can control the entrance to the ordering page. Only a few users who submit first can enter the page, and the following users directly enter the end of the second kill page







The order server checks the number of order requests processed by the machine

* If there are more than 10, directly return the ended page to the user;

* If there are no more than 10 items, the user can enter the page of order filling and confirmation;

Check the number of submitted orders globally

* Return the ended page to the user if the total number of goods has exceeded;

* No more than the total number of seconds to kill goods, submitted to the sub-order system.

This greatly reduces the load on the database.

So how do you learn to get into a first-tier Internet company?

Welcome to work one to five years of Java engineer friends to join the Java architecture development: 685167672

This group provides free study guidance framework materials and free solutions

If you don’t know any questions, you can ask them in this group. There will also be career planning and interview guidance

Finally, be a thinking, thinking, thinking programmer.