Two-eleven spike combat system architecture design solutions

concept

Spike

       What is a spike? Popular thing about online retailers is the purpose of the organization for the promotion of limit buy other online activities

       For example, Jingdong spike, spike is a kind of rationing, within a specified period of time, regardless of whether the goods spike completed the screening of spike activity will end. This spike is not particularly time-critical, as long as the quick start, the probability of seconds is quite large.

       Taobao ago did one yuan to buy, usually a limited commodity, while low prices to "cause hair teeth." This spike in start time is generally within 1-3 seconds had been robbed, to participate in the general spike is a matter of luck, do not insist too

Business Features

 

Concurrent large transient

       There will be a large number of users at the same time when the spike rush, instantaneous concurrent access to the sudden increase in the amount of 10 times, even 100 times more than have.

Less inventory

       General merchandise spike activity amounts are small, which leads to only a very small number of users able to successfully purchase merchandise.

Simple business

       The process is relatively simple, usually under orders, inventory deduction, pay orders

Technical Difficulties

 

The impact of existing business

       Spike is a marketing activities, and other marketing activities if the applications deployed on the same server, will certainly impact other existing activities, in extreme cases can cause the entire electricity supplier system service downtime

Direct orders

       Single page is a normal URL address, the need to control before the start of the spike, not an order, can only view information corresponding activities goods. In simple terms, the order requires Disable button

The sudden increase in traffic page

       Around the beginning of spike activity, there will be many users request the corresponding product page will cause the sudden increase in traffic back-end servers, while the corresponding increase in network bandwidth, the need to control the flow of product pages will not cause too much of the back-end server, DB, Redis and other components pressure

Architecture design

 

Limiting

       Since the spike activity stocks generally have little correspondence, it was only a small part of the user to spike success. It is possible to limit the most user traffic, only a small number of users allowed to flow into the back-end server

Clipping

       That moment began to spike, there will be the impact of a large number of users come in, so in the beginning when there will be a momentary spike in traffic. How to peak instantaneous flow becomes more gentle, it is a key factor in the success of good design spike system. To achieve traffic load shifting, and generally use the cache MQ middleware to solve

asynchronous

       In fact, you can spike as high concurrency system to handle at this time, can be considered compatible from doing business, the business will be synchronized, asynchronous processing tasks designed to improve the overall usability of the site

Cache

       Bottleneck spike system is mainly reflected lower orders, inventory deduction process. In these processes mainly used OLTP database, similar to MySQL, SQLServer, Oracle. Since the underlying database storage structures using B + tree, corresponding to the efficiency of our random write and read relatively low. If we move to the part of the business logic in the memory cache or Redis, will greatly improve the efficiency of concurrency

Overall structure

 

Client optimization

       There are two main client optimization problem

Page spike

       Before the start of spike activity, in fact, there are many users visit the page up. If some of the resources on this page, such as CSS, JS, images, product details, etc., have access to back-end servers, DB even if the service is not available will certainly appear. So in general we will put this whole page static and distribute static page after page to the CDN edge nodes, play a role in dispersing pressure

To prevent the advance orders

       To prevent the advance orders mainly joined a JS file referenced in the static page, the JS file that contains the marks activities are starting and dynamic URL parameters in single page at the beginning. At the same time, the JS file is not cached in the CDN system, it would have been requested back-end services, so the JS file must be very small. When the quick start of activities (such as advance), so by back-end interface to modify this file JS

Optimization access layer API

       The client is optimized for computer users not to engage in aspects of living can still be prevented. But some slightly network users on the basis of no effect, so the server also need to add some correspondence control, any operation can not trust the client. General control is divided into two categories

Restrict user access frequency dimension

       For the same user (Userid dimension), do page-level cache, requests per unit of time, unified cache go and return the same page

Restricting the access frequency dimension

       When a large number of query requests with the same period a commodity, you can do page-level cache, regardless of who is going to visit next time, as long as this page will direct return

Summary of SOA services layer optimization

       Only the top two floors abnormal restrict user access, if the operator spike activity is better, a lot of users have participated in, the system will cause excessive pressure or even downtime, requiring back-end flow control

       The control system can be solved by the message queue backend, asynchronous processing, etc. to improve concurrency. For requests exceed the system water line directly to the principle of "Fail-Fast" and refused to fall

Spike entire flowchart

 

       Spike system core comprising layers of the filter, gradually decreasing pressure transient access, reducing the impact on the final database. Through the above flow chart where you will find the greatest pressure in place?

       Consumers amount of data MQ queue service, as long as the MQ queue withstand service, the latter deduction orders and inventory pressure are able to control their own, according to the pressure on the database, you can create custom orders consumers avoid excessive , resulting in excessive pressure or direct database downtime.

       Inventory Services specializes in providing inventory management for the commodities spike, lock stock ahead of schedule, to avoid oversold phenomenon. At the same time, through overtime to grab the merchandise processing tasks have been found, but the payment orders and payment specified time, to deal with these orders, orders to restore stocks of goods corresponding

Guess you like

Origin www.cnblogs.com/spark9988/p/11512621.html