Home Backend Development PHP Tutorial Analysis on high concurrency issues in the development of King of Glory

Analysis on high concurrency issues in the development of King of Glory

Feb 01, 2018 pm 02:08 PM
develop King glory

This article shares with you a very interesting topic about high concurrency issues in the development of Honor of Kings. I hope it can bring you ideas for solving such problems. Let’s learn together about the analysis of high concurrency issues in the development of Honor of Kings.

"Glory of Kings" is a national-level mobile game with a huge user base and has maintained a high frequency of updates. In this business scenario, bursts have become very frequent. However, business experience is crucial, and the use of CDN is essential. Similarly, there are often scenarios where bandwidth bursts, such as breaking news videos, large-scale live broadcast events, the release of popular movies and TV series, and the release of popular games and other applications. At the same time, due to the rapid upgrade of home bandwidth and mobile networks, the magnitude of burst bandwidth is getting larger and larger, often reaching Tb level, or even 10Tb. How to protect business emergencies quickly and at low cost has become a major challenge for CDN.

The most popular mobile game "Honor of Kings" in China has hundreds of millions of users and tens of millions of daily active users. How to ensure business emergencies quickly and at low cost? This article starts from this problem, discusses the corresponding solution to the problem, and summarizes its effects.

Background

In 2007, Tencent’s self-built CDN was launched and connected to its first business, Tencent.com. Up to now, the CDN bandwidth has grown from tens of Gb at the earliest to tens of Tb now. The bandwidth of single services is also getting larger and larger. The constant bandwidth of most services is several hundred Gb, and some burst services have reached 10Tb. The rapid upgrade of the network, the explosive growth of mobile users, and the rise of video services including on-demand and live broadcasts have made business bursts more and more frequent, the burst bandwidth has become higher and higher, and the requirements for CDN have become higher and higher.

Benefiting from the booming development of Tencent's business, the self-built CDN has successively supported Tencent's internal businesses such as game downloads, streaming video acceleration, and Spring Festival red envelopes. In 2014, Tencent opened up the CDN's full capabilities and became a Tencent Cloud CDN product. , in addition to carrying internal business, it has also begun to connect to third-party customers, such as Kuaishou on-demand, Douyu Live, etc. All of the above services have emergency scenarios and strong cost requirements. Tencent CDN has accumulated rich experience in how to protect business emergencies at low cost. Next, we will analyze the challenges and problems, solutions, and effects.

1. Challenges and problems

The following will start with the business characteristics and analyze the current challenges and problems.

1. Business characteristics and challenges

The diverse scenarios of CDN are doomed to be full of challenges for emergencies. Burst services are characterized by large volume, diverse scenarios, and irregularities.

a) Large volume: Most of the burst service bandwidth exceeds Tb, and some even reach 10T;

b) Diversified scenarios: hot dramas and news hot spots on demand; Live broadcasts of games such as LOL/KPL/DOTA2, live sports such as NBA/World Cup, and live broadcasts of variety shows such as concerts; downloads of games such as Honor of Kings in application downloads; red envelope activities, e-commerce promotions, etc. in static web page acceleration;

c) Irregular: Some sudden events are unpredictable and you won’t know until the event is about to start or has already started, such as breaking news.

The volume is large and more resources need to be prepared; the scenarios are diverse and different resource requirements need to be met; the irregularity puts high requirements on our expansion efficiency.

2. Current problems

The cost of reserving a large amount of resources just to meet sudden business needs is too high and will cause a huge waste of resources. Therefore, resources are generally reused to cope with business emergencies. However, there are two problems in directly reusing resources:

a) Only some resources can be reused: CDN business generally distinguishes platforms and resource usage according to business types. The main reason is that different business types have different resource requirements. , for example, the on-demand category requires more storage; the static page category with more https requests requires more CPU resources. This limitation prevents resources from being fully utilized and makes resource preparation more difficult. For example, video bursts mainly use video buffers, but download and web page buffers cannot be used directly, which limits the size of the buffer. Even if the same type of resources is reused, because it involves the coordination of multiple business resources, the preparation time will generally exceed two days, which cannot cope with temporary emergencies;

b) Unable to reduce costs: In addition, for some sudden services, such as For game application downloads, the bandwidth peaks in the morning and noon. If only the resources of this platform are used, the settlement bandwidth will increase significantly, thereby increasing costs. The characteristics of off-peak hours with other services cannot be used to reduce settlement bandwidth.

2. Solution

Tencent Cloud CDN reuses existing resources through virtualization to build a burst pool common to all services, and all platforms share the Buffer. The devices in the burst pool are Docker virtual machines. The virtual machines have different specifications and can be used on demand as long as the business needs them. The bandwidth reserve in the burst pool reaches 10Tb, which can basically meet all business burst needs. If any business has sudden demand, with the automated listing interface, the 10Tb burst pool can be expanded in 10 minutes.

Burst pool system architecture

a) Burst pool: On the upper layer of the physical machine of each platform, a resource pool composed of Docker virtual machines, which controls CPU/memory/disk, etc. Use is restricted to prevent impact on physical machines. The original business is still deployed on the physical machine and does not need to be adjusted.

b) Automated deployment and monitoring system: Can automatically predict demand and expand capacity based on actual business needs. All sudden needs can be expanded within 10 minutes. For on-demand/download services, hot files are automatically distributed to reduce return-to-source bandwidth.

c) Scheduling system: The sudden nature and large volume of sudden services make through trains more advantageous than domain name scheduling systems. Through train scheduling is more flexible and takes effect quickly, reaching the minute level.

Virtual machines and physical machines are deployed with reporting agents, and business information and server load are reported to the monitoring system every minute. The monitoring system will predict a value based on the historical bandwidth and compare it with the current bandwidth. If the current bandwidth exceeds 50% of the predicted value, it is considered that there is a burst. According to the proportion of bandwidth increase, the system will automatically expand the equipment with corresponding data from the burst pool. For unexpected activities prepared in advance, operation and maintenance can specify the bandwidth demand, and then the system will automatically calculate the equipment demand and expand the capacity.

The server load information reported at minute granularity provides a basis for the monitoring system to make scheduling decisions. The system will determine whether the virtual machine needs to be enabled or disabled from the through train based on comprehensive information such as the remaining bandwidth of the computer room, server bandwidth, CPU, and IO. When accessing, the user first requests the express train dispatching system. The express train will return a 302 address according to the scheduling policy. The 302 address is the actual CDN resource address. The user jumps to the 302 address and gets the actual content.

2. Technical optimization

The important prerequisite for using virtualization technology to reuse resources is that it does not affect existing businesses. This requires sufficient isolation of resources, such as CPU/disk, and bandwidth usage. The following are several problems and solutions during the implementation process:

● Accurately control the load of a single machine: Excessive load will affect the quality of the service, and the load of a single machine needs to be accurately controlled.

Solution:

a) Quota system: There is a quota system in the express train, which limits the resources that each virtual machine can use, including CPU/IO and bandwidth. The information reported in the monitoring system, combined with the quota system, can ensure that the server load is limited to the specified range, with a granularity of minutes.

b) Some requests return 302: After limiting the CPU/bandwidth/IO, etc., the application can determine whether to process a request in real time based on the current load of the host machine. If the load is within the limit, it will be processed directly; if the load exceeds the limit, 302 will be returned, allowing the user to jump to the dispatch address of the through train. This can accurately control the load without affecting the service quality as much as possible. Real-time control of load at the program level is an effective supplement to the quota system.

c) Network card flow control: In extreme cases, if the business bandwidth exceeds the set threshold, the virtual network card will actively drop packets to avoid affecting the host machine.

● Limit disk size: Docker cannot limit the disk size at the file/directory level in the ext3/ext4 file system.

Solution:

Since Tencent Cloud CDN business basically uses the ext3/ext4 file system, in this case Docker can only restrict disks based on users or user groups, but now All network services are used directly in the root environment. Here we use loop device to solve the disk size limitation problem. Burst services in the virtual machine use the directory mounted on the loop device, which can indirectly limit the disk size and prevent the use of too many disks from affecting other services.

● CPU binding: The default is to bind all CPUs. High load on some single CPUs will affect the mother machine business.

Solution:

Use a script to collect all single CPU loads in the system every minute. To avoid frequent adjustments and being affected by glitch data, take the average value of 15 minutes. Finally, some cores with lower load are selected and dynamically bound through the configuration file cpuset.cpus to minimize the impact of the virtual machine on the host machine's business and make full use of resources.

After the burst pool went online, it efficiently supported many large-scale burst events such as King of Glory downloads, NBA live broadcasts, KPL/LPL game live broadcasts, etc., saving 20 million yuan in costs. By sharing buffers, building a burst pool can significantly improve burst capabilities and reduce costs.

Summary

Tencent Cloud CDN uses Docker technology to reuse resources and build a Tb-level burst pool. It can support various business bursts such as live broadcast, on-demand, and static, and can automatically detect business Resource expansion can be completed within 10 minutes in case of sudden demand, with the characteristics of fast release and low cost. Resource reuse can improve resource utilization and provide a huge burst pool for services, but it must be noted that multiplexed services cannot affect each other, which requires real-time monitoring of the server and timely scheduling. There are also some areas for improvement, such as kernel parameters based on container isolation to facilitate tuning of different services; some business clients do not support 302 jumps, and the scheduling system needs to support domain name scheduling.

Related recommendations:

Solving high concurrency problems in web development

PHP and redis realize the snap-up and flash sale function examples under high concurrency Detailed explanation

Summary of high concurrency solutions for php read and write file conflicts

The above is the detailed content of Analysis on high concurrency issues in the development of King of Glory. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Honor Magic V3 folding screen mobile phone officially released, starting from 8,999 yuan Honor Magic V3 folding screen mobile phone officially released, starting from 8,999 yuan Jul 19, 2024 pm 08:57 PM

The Honor Magic flagship new product launch conference was held today at the "Spring Cocoon" Gymnasium of Shenzhen Bay Sports Center. Four new Magic flagship products, including Honor MagicV3, Honor MagicVs3, Honor Tablet MagicPad2, and Honor MagicBook Art14, were officially released, bringing surprises to consumers. As a folding flagship that truly achieves a combination of thinness, lightness and strength, the more powerful and thinner the Honor Magic V3, the more powerful and thinner it is, becoming another milestone of Honor's technological innovation and the most cutting-edge display of ultimate technology. This time, Honor MagicV3 cross-border innovation brings the industry's first thin and light folding screen solution Honor Luban architecture, which uses 19 kinds of innovative materials and 114 kinds of innovative micro structures. The folded body is thinned to 9.2mm, once again

Honor's first small foldable Magic V Flip all colors announced: Which one do you like? Honor's first small foldable Magic V Flip all colors announced: Which one do you like? Jun 10, 2024 pm 02:15 PM

According to news on June 3, Honor has officially announced that it will officially release its first small folding flagship - Honor Magic VFlip at 19:30 on June 13. The official also recently announced the appearance of the new phone’s three color options, allowing everyone to get a glimpse of its true appearance in advance. There are three colors: Iris Black, Champagne Pink, and Camellia White. As you can see, the Honor MagicVFlip body is very slim and should be designed to be thin and light. The weight is expected to be within 180g. The biggest highlight of the machine is the oversized secondary screen on the back, which covers the entire area except for the hole for the lens, creating a full-screen effect, and the flash is placed in the lower half. Such a design will greatly improve the usability of the secondary screen on the back, and it will no longer be just a simple reply

Honor X60i launched with smart island punch-hole screen + bathroom heater dual camera. How would you rate its appearance? Honor X60i launched with smart island punch-hole screen + bathroom heater dual camera. How would you rate its appearance? Jul 24, 2024 pm 12:37 PM

Yesterday, Honor announced that the Honor X60i is on the shelves. Pre-orders have been opened and pre-sales will be officially launched at 10:08 am on July 26. Let’s first take a look at the appearance and configuration. As you can see in the picture above, the Honor X60i uses a straight screen with a hole in the center similar to the shape of a smart island, and a right-angled middle frame. On the back is a bathroom heater with dual cameras, and the right side should be a flash, which is very iPhone-like. ~Honour +2MPfenye

Honor MagicBook Art 14 notebook starts pre-sale: starting from 7,999 yuan, integrating multiple innovations and breakthroughs Honor MagicBook Art 14 notebook starts pre-sale: starting from 7,999 yuan, integrating multiple innovations and breakthroughs Jul 16, 2024 pm 07:58 PM

According to news from this website on July 12, the Honor Magic flagship new product launch conference was held in Shenzhen, launching the new high-end flagship thin and light notebook Honor MagicBook Art14, which is "lighter, thinner and more AI", as well as the thin and light folding flagship Honor MagicV3, Honor MagicVs3, and Honor tablet MagicPad2 and other new products in the flagship family. As Honor’s first high-end flagship thin and light notebook, Honor MagicBook Art14 combines product features such as extreme thinness and lightness, smart eyes, eye-protecting screen, audio-visual experience, and efficient and powerful AI capabilities. Honor MagicBook Art 14 starts at 7,999 yuan, and will be available for pre-sale through all channels at 16:18 on July 12. It will be officially sold for the first time at 10:00 on July 26. Honor C

Honor tablet MagicPad 2 review: OLED good screen empowers entertainment and office experience Honor tablet MagicPad 2 review: OLED good screen empowers entertainment and office experience Jul 19, 2024 am 10:10 AM

1. Foreword: Honor launches new flagship tablet product with 4320Hz high-frequency dimming OLED screen. Some time ago, search terms related to "downloading and watching movies have become a niche behavior among young people" and "Steam generation installation" became hot searches. For Most people may laugh it off, but this phenomenon actually reflects changes in the devices used by users. Authoritative data shows that among the devices used by minors in 2022, mobile phones will take the lead with over 91.3% of Internet access, followed by tablets with a share of 45.5%, and the usage rates of desktop computers and laptops will be 33.2% and 33.2% respectively. 31.7%, showing a clear downward trend compared with 2021. The root of this change

Three cameras with 20x zoom, Honor selects Xiaopai Smart Camera Pro innovation is coming Three cameras with 20x zoom, Honor selects Xiaopai Smart Camera Pro innovation is coming Aug 23, 2024 pm 09:44 PM

Have you installed cameras in your home? In recent years, home camera products have suddenly become a hit. I asked my friends around me, and boy, every house has one, and some even have more than one. However, with the popularity of the product, it has also brought some complaints during use. For example, you can only see one place at the same time, and if you want to see other places, you have to adjust the pan/tilt and rotate the camera back and forth. There is a certain blind spot and time difference when viewing the picture; or when you want to take a closer look at a certain location in your home, you find that the picture is blurry and you cannot see it at all. Clarity; etc... The experience is greatly compromised. Honor Select and Xiaopai Technology jointly launched the Honor Select Xiaopai Smart Camera Pro featuring "three lenses and dual images". Provides new solutions to industry and user pain points

Honor X60i mobile phone will be launched tomorrow: visual quadrilateral OLED direct screen Honor X60i mobile phone will be launched tomorrow: visual quadrilateral OLED direct screen Jul 25, 2024 pm 01:54 PM

According to news on July 25, the Honor X60i mobile phone will start pre-sale at 10:08 tomorrow (July 26). The mobile phone adopts a lightweight design, weighs about 172g, and has a thickness of about 7.18mm. Honor X60i adopts a straight screen design with a hole in the center and almost unbounded ultra-narrow borders on all four sides, which greatly broadens the field of view. The rear camera module is presented in an elegant vertical layout, supplemented by a flash on the right side, which not only highlights the sense of technology but also the beauty of simplicity. The overall design inspiration seems to echo the Huawei Pura70 series, but without losing its own characteristics. In terms of color selection, Honor X60i has carefully prepared four fashionable colors: Magic Night, Black Clouds, Water Blue, Moon Shadow, White Coral and Purple to meet the personalized aesthetic needs of different people. The hardware configuration should not be underestimated either. Honor X60

Refresh the record of small foldable and light weight! Honor Magic V Flip is only 7.15mm thick and weighs 193g when unfolded Refresh the record of small foldable and light weight! Honor Magic V Flip is only 7.15mm thick and weighs 193g when unfolded Jun 13, 2024 pm 10:13 PM

According to news on June 13, at 7:30 tonight, Honor MagicVFlip will officially debut. Following the previous Honor Magic V2 becoming the thinnest and lightest large foldable in the industry, the Honor Magic VFlip once again broke the record for the thinnest and lightest small foldable, with an unfolded thickness of 7.15mm, a folded thickness of 14.89mm, and a weight of 193g. Equipped with the flagship Honor Luban hinge, it has passed the Swiss SGS high-reliability folding quality certification and provides users with a user experience that is both thin, durable and stable. While the body is thin and light, Honor Magic VFlip is also equipped with the industry's largest external screen, which is 4.0 inches tall and has a frame of only 2.87mm. It achieves a record-breaking 85% external screen screen-to-body ratio, bringing a strong visual shock. At the same time, oversized

See all articles