Function Compute provides the auto scaling feature, event triggering mechanism, and pay-as-you-go billing method. This topic describes how to use Function Compute to handle traffic surges during peak hours in Sina Weibo.
Sina Weibo is a microblogging platform that you can access by using various mobile terminals, such as PCs and mobile phones, to instantly share text, images, and videos. Everyone can create and post blogs and becomes the lead actor of their lives. Sina Weibo provides a simple way for users to publish content in real time based on the public platform architecture. Rapid blog proliferation enables users to interact with others and connect with the world.
Since its launch in August 2009, Sina Weibo maintained steady and rapid growth. In June 2019, its monthly active users reached 486 million and the average daily active users was 211 million. This rapid business growth poses a challenge to the original underlying system of Sina Weibo.
Traffic surge: The yearly New Year's Day, Spring Festival Gala, and red envelope campaigns bring large amounts of traffic and pose great challenges to Sina Weibo. These scenarios feature high instantaneous peak traffic for a short period of time. The period of each peak interaction event is about three hours. Services such as star events and red envelope campaigns often encounter instantaneous peak traffic multiple times higher than normal values.
High peak-to-valley ratio: Social media is closely related to work and rest time of people. In the afternoon, people concentrate on their work and do not have time to post on social media, and the number of requests is small. In the evening, people are free to log on to social media and catch up with what happened on that day, and the number of requests surges. The average load for Sina Weibo changes over time, and peak traffic can exceed the lows by more than five times.
Sina Weibo used the following traditional countermeasures to handle traffic surges:
Apply for sufficient equipment in advance to ensure redundancy.
Downgrade non-core services.
However, in the preceding solutions, Sina Weibo must predict related IT costs in advance. Other issues also occurred, such as different business load saturations, tedious scaling processes, and long periods of time. The top priority for Sina Weibo technicians is to keep a rather better use experience in the face of the rapid expansion of users and burst traffic without increasing server costs.
The public cloud serverless architecture can be used to cope with explosive traffic. Function Compute is a serverless computing platform provided by Alibaba Cloud. Function Compute dynamically allocates runtime environments and schedules computing resources in milliseconds based on the number of requests received. Function Compute minimizes latency when the workload is heavy and maintains high resource utilization when the workload is low. In addition, by using Function Compute, Sina Weibo can reduce costs because it needs only to pay for computing resources that are used when the code is running. Function Compute integrates with Object Storage Service (OSS) and can process images stored in OSS in real time.
Function Compute provides the auto scaling feature, event triggering mechanism, and pay-as-you-go billing method. Sina Weibo uses Function Compute to deploy image processing services. Sina Weibo stores images uploaded by users in OSS and defines functions to process the images in a personalized way. When a user requests an image from a client, the request is sent to Function Compute by Alibaba Cloud Content Delivery Network (CDN). The relevant functions are used to download the original image from OSS, convert it into the expected image in real time based on the client type, and then return the final image.
Function Compute can scale computing resources in milliseconds to ensure that applications are stable when traffic bursts occur. User experience is not affected by the number of visits.
Running the image processing service in Function Compute helps Sina Weibo continuously reduce costs. Sina Weibo no longer maintains large numbers of idle servers that are used to process surge traffic during peak hours. Without managing and maintaining infrastructure, developers can focus on cooperating with product teams and increasing business value.
As the number of active users of Sina Weibo continues to increase and Sina Weibo continues to expand, Function Compute can automatically allocate more runtime environments to support continuous business growth of Sina Weibo.