The technical story behind the Little Bochun night

Source: Internet
Author: User

Objective

The annual Spring Festival Gala is once again on the curtain, and Weibo is also a smooth ride for the New Year's Eve.

Talk about Horse Spring Festival Gala, People first thought is not the spring evening wonderful program, but Micro Bo on the Spit trough, while watching the Spring Festival gala, Edge Brush micro bo, side spit Groove, has become the custom of the Chinese. See the Spring Festival Gala is no longer to watch the program, but in order to be able to spit on the micro-Bo slot, know that everyone in the spit slot what, more people jokingly is not the Spring Festival evening achievement of micro-blog, but Weibo saved the Spring Festival Gala.

Horse Gala is particularly eye-catching, not only because Feng Xiaogang personally sits, as the director, but also worth mentioning is the first time this spring Festival gala as its main way to interact with the audience, and Sina Weibo is to become the official two-dimensional code exclusive partner. In the program broadcast, the user general mobile phone client, scan the bottom right corner of the official two-dimensional code, you can participate in the Spring Festival evening topic discussion. Not only that, the audience participating in the discussion, but also free to receive micro-BO red envelopes, the opportunity to draw prizes. In this way, greatly enhance the micro-blog's active degree of instant ascension, while the online number of people turned several times, to the micro-blogging system to bring unprecedented access to pressure.

According to previous statistics, the Spring Festival Gala visit will surge to the daily level of the number of times, and the instantaneous publication volume is soaring dozens of times times, so the scene is no less than Taobao double 11 and 12306 grab the ticket when the "grand".

The results of the final statistics show that during the horse Gala broadcast, the number of visits and publication of micro-blog are again high, and our system runs smoothly from beginning to end, withstood the test of this peak. Behind this success is the effort of our engineers for nearly one months. What are the problems faced and how to solve them? Below, we all discover for everybody.

Challenge 1: How to cope with the pressure of multiple times of daily traffic?

The annual spring Festival ticket, 12306 will collapse, Taobao Double 11 o'clock, there will be a short purchase failure. The reason is that limited server resources are difficult to withstand tens of millions of people at the same time online access. Similarly, when the Spring Festival Gala, the number of visits to the microblog will also surge, while online numbers have reached a daily number of times more. In the face of a sudden increase in access pressure, most Internet companies will be temporarily expanding to deal with, but also we need to expand. So how do you expand? What parts need to be enlarged? How much is the specific expansion? These are problems that need to be solved.

One thing to mention is that Weibo currently has thousands of servers deployed online to ensure regular access. If faced with the original number of times the access pressure, if the simple rough through linear expansion to deal with, you need to deploy the original number of times the server, that is, tens of thousands of servers. This is unacceptable both in terms of hardware costs and management costs. So what is to be done?

On-line pressure measurement, find the limit, minimize the expansion of the front-end machine

As we all know, in order to ensure as far as possible the stability of the server running on the line, resources are a certain degree of redundancy, the general security value of more than 30%. In the face of 5 times times the number of visits, for cost reasons, simple expansion is difficult to accept. This time, we should make full use of each server, without affecting the business performance of the premise, so that each server utilization to the limit, can greatly reduce the number of resource expansion. How to evaluate the server's endurance limit is the key, for this we in the business low peak period, to the online server on the actual pressure test. The specific methods are as follows:

If there are 300 tomcat servers in the online service pool that provide API services, normally, the load per server is less than 1 (in order to simplify the model, we only mention the system load this indicator, the actual situation is more complex than this, but also consider CPU utilization, bandwidth, IO latency, etc.). Through the operation of the system, we are 10%, 20%, 30%, 40%, 50%, and so on the scale of the service pool 300 tomcat machine 503, by observing the load of a tomcat server and API service interface performance, when the server's load to reach the limit or API When the interface performance of a service reaches a threshold, assuming that the number of Tomcat servers in the service pool is 100, then we can infer the service pool, which can withstand 3 times times the normal access pressure at the limit. Similarly, in order to bear 5 times times the amount of traffic, only one more machine can be enlarged.

Challenge 2: How to respond to the instantaneous amount of tens of thousands of/s published?

One notable feature of Internet applications is that they read more and write less. There are many mature solutions for reading, such as cache data can be cached to reduce the pressure of the database and other ways to solve. As for the case of writing more, because the database itself write performance bottlenecks, relatively difficult to solve.

The microblogging system uses asynchronous message queues when processing published microblogs. Specifically, when users publish microblogs, instead of directly updating the database and caching, they write to the MCQ message queue first. The messages in the message queue are then read through the queue machine handler and then written to the database and cache. So, how to guarantee the read-write performance of message queue, and how to ensure the performance of the queue processor is the key of the system.

Sets the double queue by message size to guarantee write speed.

As you know, Weibo has a maximum length of no more than 140 characters, while most users actually publish smaller Weibo lengths. To increase the speed at which message queues are written, we write message queues of different sizes for different lengths of microblogging messages. For example, a 512-byte line, more than 512 bytes of write long queues, less than 512 bytes of write short queues, where the short queue of stand-alone write performance is much higher than the long queue. The actual online results show that the QPS of the short queues is at the million/s level, the QPS of the long queue is at the thousand/s level, and the 99% microblogging message length is less than 512 bytes. This optimization greatly improves the writing and reading performance of microblogging messages.

Block queue, pressure queue machine limit processing capacity.

In order to verify the limit processing ability of the queue machine, we have carried on the actual pressure test to the line queue machine in the low peak period of the business, the concrete method is as follows:

Through the switch control, the queue machine handler stops reading messages, thus blocking Message Queuing, so that the accumulated messages reached 100,000, 200,000, 300,000, 600,000, 1 million, and then turn on the switch, so that the queue machine to restart processing messages, the whole process is similar to the dam water storage, and then open flood discharge, imagine A sudden rush of messages will put a lot of pressure on the queuing machine. By analyzing the log, you find the slowest place where the queue machine handler is located, which is the bottleneck.

With two actual pressure-measurement simulations, it is not surprising that we find that the system at the extreme pressure, the first to reach the bottleneck is not the database write, but cache update. Therefore, in order to improve the throughput of the queue processor under extreme pressure, we have optimized some of the cache updates.

Challenge 3: How to ensure the reliability of the system?

This column more highlights: http://www.bianceng.cn/webkf/tools/

Whether it is a micro-blog, or brush feed, in the micro-BO system processing is very complex, relying on a variety of internal resources and external services to ensure the reliability of the system is particularly difficult.

To this end, we have developed a code for the Touchstone--touchstone pressure measurement system, the reliability of the system to fully detect.

First, we have a service dependency and resource dependency on the various interfaces of Weibo, and define the corresponding SLA and downgrade switches for each service and resource. Then, simulate a resource or service exception, and then look at its impact on interface performance. Take Redis resources as an example, assuming that the system defines a redis SLA to be 300ms, the corresponding port is 6379, and the port is not available through touchstone to simulate Redis resource anomalies, and then verify the performance of the interfaces that depend on the resource to ensure SLAs. At the same time, by demoting the switch, the resource is degraded to verify the validity of the downgrade switch.

Based on the above methods, the system has been comprehensively tested, and the various services and resources of the SLA and downgrade switch to comb, always formed a business downgrade manual, to ensure that in the case of problems, operators need not develop the intervention, but also the first time according to the downgrade manual, to ensure that the problem can be resolved as soon as possible.

Challenge 4: How to ensure the stability of the core system?

Any system that contains both core and non-core systems. In the case of abnormal, abandon the car to protect handsome, only to ensure the stability of the core system is also acceptable.

To this end, we reduce the core interface and Non-core interface split, part of the deployment to different application pool, to ensure that non-core business does not affect the core business. For example, Weibo and the brush feed is the core business, and comments, praise belongs to Non-core business, so both should be deployed to different application pool. In the comments or praise of abnormal, the microblogging and brush feed will not be affected, thereby safeguarding the stability of the core business of the system.

Similarly, for a business, it is also important to distinguish between core and non-core logic. In the case of Weibo, updating the cache and writing database is the core logic, while pushing data to other business units is a non-core logic. As a result, push data can be asynchronously processed to a separate thread pool and, when an exception occurs, does not affect the update cache and write the database.

Challenge 5: How to achieve disaster tolerance in different places?

In recent years, remote disaster tolerance has become one of the problems faced by global Internet enterprises. Whether in the country, in the case of micro-letters, or abroad, with Twitter, for example, there have been incidents of global downtime. Thus, remote disaster recovery is still a challenge.

Weibo began its deployment of multiple computer rooms as early as 2010, and now has three computer rooms (for Unicom, telecom and overseas users, respectively).

Due to the irresistible factors such as man-made or weather, network faults have occurred in recent years. Weibo's three rooms, each independently undertook a part of the user's visit. In a computer room failure or too much pressure, through DNS switching, and other means, the flow of traffic to the other two rooms, so as to ensure that the user access to the room is not affected. A realistic example, in the Horse Spring Festival Gala Live, due to the view of the geographical distribution of the characteristics of the number of visitors to the Unicom room, and the increase in online numbers exceeded the telecom room and Guangzhou room, we pass a part of the exchange of the computer room traffic to the telecommunications room, The load of Unicom room is reduced to the range of safety value.

Challenge 6: How to monitor system status in real time?

As we all know, earthquakes occur in precursors, such as the abnormal reactions of some animals. Similarly, there are clues to be found before any problems in the system arise. This requires the system's key indicators to do real-time monitoring, when the indicators appear abnormal, the first time to send out the alarm information.

For this reason, we developed a monitoring system--dashboard based on the real Time Flow processing system (Storm). Different from the previous monitoring system, it can real-time processing system generated mass log, draw a more intuitive curve, convenient operation and maintenance management. Through the Dashborad, we can understand the real-time state of the system, mainly including the feed volume, the number of tweets, the processing performance of the queue machine, Message Queuing, such as the accumulation of indicators. When a monitoring indicator is abnormal, can be reflected in the first time in the dashboard, so that the first time to take measures to solve problems, to avoid problems magnified.

Postscript

The Spring Festival Gala has been over one months, and gradually become a memory. But the Spring Festival evening, our engineers pay great efforts to produce the value, but is a valuable wealth, hope this article can bring inspiration and even help, but also to the micro-Bochun late silently contribution to the engineers to salute!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.