In the enterprise, doing activities is a very common demand, there are activities for C-end users, there are activities for internal employees. With the continuous development of Internet technology and outbreak reasons, such as online activities more and more, in the form of common are: content collection, review barrage, thumb up to vote, quiz questions, draw a red envelope, a team to share and PK list, whether single or more style, some of them have will produce a large number of concurrent requests.

During the activity, users will participate in the activity in a short period of time, such as dividing red envelopes, seckill and other activities, which will cause users to click in a concentrated way, resulting in high concurrent requests and certain pressure on the system. If the load is too high or the system crashes during the activity, users will be unable to participate in the activity, causing users to make fun of and complain.

However, activity systems are often only “one-time”, so there is relatively little investment in the development of such systems, and even some activities are developed by researchers using the gap time. Therefore, we often find that, if we do not carry out detailed development and design and pre-launch pressure test, some large activities of the system after the launch of the probability of problems is very high.

An active system that can support high traffic is the key to the success of an active system. Let’s take a look at how to design an active system with high traffic.

What is the architecture of a high traffic activity system?

Large traffic activity system needs to deal with a large number of concurrent calls, so the system design requires the ability of horizontal expansion to meet the business requirements. The following hierarchical system architecture design is usually adopted because the active system functions are usually relatively simple and there are fewer modules, so the system architecture is not too complex.

Usually, in the 0-1 stage of the system, in order to quickly launch the system, it is not considered to be layered, but in the face of large traffic activity system, it has to be layered design, layered architecture can make the system more easily for horizontal expansion, improve the system throughput, which is also the core requirements of large traffic system. At the same time, the layered architecture also increases the complexity and workload of the system.

The above architecture is divided into LB, business access layer, business logic layer, data storage layer and other layers.

LB

User traffic entry, external shielding internal service architecture details, internal reverse proxy traffic forwarding, improve the throughput of the whole system. The core function of the LB is to increase the throughput of the entire system through traffic distribution.

Service access layer

This layer is used to implement some common business logic processing, such as data encoding and decoding, user identity verification, access frequency control, flow limiting degradation, data caching, micro-service entry and other functions. This layer is usually implemented within the business logic layer in the form of middleware. Development needs to implement the business logic at this level and interact with the underlying resources.

The business functions realized by this layer are required by many systems and are shared by multiple business logic layer services. It is worth noting that this layer is generally stateless and can be scaled horizontally to increase system throughput capacity.

Business Logic Layer

The core layer of the business logic implementation, and the code related to the business logic is basically concentrated in this layer. This layer requires developers to spend a lot of time on design and implementation, and the amount of development time will directly affect whether the business logic can be fully designed and implemented. Business performance issues and system bugs are common at this level.

Developers need to implement the business logic at this level and interact with the underlying resources. This layer is usually stateless and can be scaled horizontally to increase system throughput capacity.

Data storage layer

The business data storage layer, where almost all business data eventually needs to be persisted to the database, is often the bottleneck of the system.

All the activities of the business need the database layer, the normal and reasonable use of the database will have a great impact on the system performance.

The data storage layer is stateful and it is difficult to increase the throughput capacity of the system through horizontal scaling. Database performance is usually improved by increasing the database instance configuration specification vertically, but vertical configuration has a physical upper limit and cannot be increased indefinitely. This requires developers to fully design in this layer to enhance the service capability of this layer.

The above system architecture is the most common and basic layered system architecture, but in the face of large traffic activities of the system, even experienced developers, also dare not to make a guarantee that a certain resistance to live.

What are the challenges of implementing a high volume system?

Issues to be considered at each layer of the system include:

When we expand the need to consider each layer in the architecture, the system development workload will not want to look at the front less, originally looked at the simple system is no longer simple, need to consider and solve a lot of problems.

Flow inlet LB layer

  1. Security protection: prevent all kinds of security attacks, damage to the system, steal data
  2. Access quality: the access quality of users in various regions using various networks should be considered, otherwise it is likely that some users will not be able to participate in the activity due to access quality
  3. LB configuration maintenance: depends on performance reliability, load balancing strategy, RS update maintenance and health checks, log monitoring alerts and other aspects of the problem
  4. Dial and test monitoring: monitor whether the system is properly provided service
  5. Network bandwidth: Whether the network bandwidth is sufficient, the bandwidth problem is usually more hidden and difficult to find

Business core layer

  1. Basic resources: It involves the creation and configuration management of resources such as computing, network and storage, as well as multiple access issues such as security scanning, security protection, monitoring and alarm, and system optimization
  2. Business deployment: it involves issues such as service release change, frequency control and current limit, fault tolerance and disaster tolerance, performance optimization, log collection and many other aspects
  3. Business development: business logic design and realization, fault tolerance and disaster tolerance

Data storage layer

  1. Data security: prevent password leakage data theft and other problems
  2. Business design: database database sub-table design, database index design
  3. Performance optimization: improve system throughput capacity

High performance and high availability

  1. High performance: the processing capacity and performance bottlenecks at each layer of the system, how to eliminate and optimize the performance bottlenecks in the link, eliminate the performance bottlenecks in the link may need a lot of work to find
  2. High availability: the fault tolerant and disaster tolerant design of the whole link, how to reduce and avoid the impact of faults such as network jitter and available zone faults on the system

In addition to the list in the figure, the business needs to consider the following issues:

  1. How to verify the user identity to ensure the authenticity of the user identity?
  2. How to prevent brush, prevent wool party wool?
  3. How to conduct statistics on business data?
  4. How to quickly build development, production and other sets of environment?
  5. How to deal with online problems quickly?
  6. How to run the event? Implement a set of operation management background system?
  7. How to control the active switch? Timed polling or active push?

When all of these issues come together, they create quite a challenge for developers. We all need to think it through in order to make our activities foolproof. The R&D team has:

  1. System architecture: a holistic technical architecture design plan is required
  2. System operation and maintenance: It can control the operation and maintenance of the full-link business resources
  3. Business design: implement business logic, fault tolerant and disaster tolerant design
  4. Performance optimization: give full consideration to the possible performance bottlenecks of the system, and carry out design optimization accordingly
  5. Capacity design: Assess the capacity of the system. How to deal with the high traffic calls that exceed the estimate
  6. Monitoring alarm: take the initiative to find all kinds of problems in the system, early elimination of hidden dangers
  7. Service deployment: application and deployment of relevant business resources, deployment of business services

As a result, the development team may be divided into various aspects of the system, which leaves the development team with less energy to focus on the business logic and solve the core problem facing the system: how to deal with a large number of highly concurrent service invocations.

There are many architectural design principles and schemes of high performance and high availability, but it is not easy to achieve a high performance and high availability system, and there are a lot of specific and detailed work to be done behind it, such as the system fault tolerance and disaster tolerance capacity.

Tencent Cloud · Cloud Development (hereinafter referred to as “Cloud Development”) based on Serverless mode can help developers solve the above problems and challenges.

Serverless cloud development: the solution?

Business systems in general need to implement two capabilities:

  1. Business logic: Realize business logic, including front-end and back-end business logic. Part of the business logic is a generic requirement.
  2. Access link: build high-performance and large-capacity access link to connect the user side and the business logic layer. This is a general requirement.

Tencent cloud · cloud development on the universal access link and part of the common logic abstract out of the unified implementation, to help developers solve common problems. Cloud development provides security, high reliability, high concurrency, high performance general back-end capability foundation, provides high performance, high concurrency and large capacity access link for developers, so that developers do not need to care about a series of problems involved in link construction, let the business side based on Serverless architecture to achieve business logic, shielding the underlying infrastructure for developers. Provide efficient elastic expansion capacity to solve business capacity problems. Cloud development helps the business solve the problem of commonality, so that developers can focus more on solving the business itself, reducing cost and increasing efficiency.

The comparison between the traditional model and the cloud development model is shown in the figure:

In the cloud development mode, users only need to pay attention to the design and implementation of the core business logic of the front and back ends, without caring about the underlying infrastructure and access links.

3.1 Elastic scalability of business resources

Developers realize their business logic based on the business resources provided by Tencent Cloud · Cloud Development. By relying on the elastic expansion capacity of the underlying resources of the cloud development platform, the user business has the elastic expansion capacity, which is efficient and fast, and avoids the resource and labor cost caused by capacity expansion under the traditional mode. Business services use resources on demand and charge according to volume, saving project costs.

Cloud function

When the user request enters the user’s cloud function through the cloud function access layer Invoker, it triggers the user’s logical logic. Cloud function is an elastic computing resource that can automatically expand and expand flexibly following the concurrent amount of the user, as shown in the figure below:

Each concurrent user request will correspond to a cloud function instance. When the user request increases, the cloud function instance will automatically expand its capacity; when the user request volume decreases, the cloud function instance will gradually shrink its capacity. The process of elastic scaling is automatic, convenient and fast, which provides users with strong elastic scaling ability, and then provides strong ability support for the high concurrency of users’ business.

Cloud development currently provides developers with the ability to support a single cloud function up to 1000 concurrences. If the average execution time of a cloud function is 100ms, then a single cloud function can reach 10,000 Qps, which can meet the needs of most user scenarios, and the total Qps of 50 cloud functions can reach 50W Qps.

Cloud database

Tencent Cloud · Cloud Development provides users with native database instances. Users do not need to purchase and maintain database instances. Through the cloud development SDK, developers can quickly start business development and save time.

The cloud database has also done a lot of special optimization in the access layer and the bottom layer of the database, as well as many aspects of the deployment design.

The cloud database access layer is designed in layers and supports large-scale horizontal and horizontal capacity expansion. The user requests can be flexibly scheduled between clusters to deal with possible service failures and provide higher availability and shorter recovery time. User requests enter the database engine layer through the service of the data access layer, and the database access layer deploys multiple clusters across AZ. The database access layer helps users to realize the maintenance and optimization of database connection. Users do not need to care about how to connect to the database, maintain the database account density, and improve the security of the database.

Tencent Cloud · Cloud Development Database provides users with:

  1. Automatic indexing: Analyze the slow query requests of users and optimize the index accordingly, which can optimize the database performance, improve the system throughput and enhance the concurrency ability in the absence of user awareness.
  2. Automatically elastic Cgroups provide computing resources on demand: adjust the computing resources required for database operation according to user database load as needed.
  3. Automated online thermal migration: When the host load is too high, the online thermal migration of user instances to the low-load host is almost invisible to the user. Hot migration can also support global load balancing among database hosts.

Through the above measures, cloud development provides users with database flexibility while reducing the cost of the user database. With these capabilities, developers pay less attention to the database.

Cloud development database also provides developers with real-time database push capability, based on which users can realize real-time push business and reduce the cost of building and promoting services.

As mentioned above, the database layer is stateful, and it is difficult to carry out horizontal expansion and shrinkage capacity. Cloud development provides users with certain vertical expansion capacity and optimization, and improves database performance. Users themselves also need to carry out some design optimization on the data.

3.2 Elastic scalability and reliability design of access link

The cloud development platform provides users with a high performance and large capacity access link directly to the business logic. Users do not need to build and maintain a series of resource services on the access chain, which reduces the cost of resources and labor.

The performance and availability of the cloud development platform will directly affect the performance availability of the user’s business. As a public cloud service, cloud development not only provides developers with all kinds of capability support, but more importantly, it can improve the performance and reliability of customer business services. Therefore, cloud development service carries out a lot of design optimization on the availability capacity and other aspects of the system.

Fault tolerance: cloud development services improve the fault tolerance of the system through link optimization, abnormal retry, multi-level caching, latency, failure degradation, fault elimination and other aspects of the optimization.

Capacity: Cloud development realizes the elastic scalability of access links through containerized service deployment, which has the advantages brought by containerization. When the user traffic increases, the access links can automatically expand and shrink flexibly with the user traffic, avoiding the problem of limited user services caused by the bottleneck of access links.

Disaster resilience: Based on the containerized deployment mode, the data flow access layer services are deployed in multiple clusters. Each cluster is deployed across available zones and has the capacity of disaster resilience across available zones. When the single machine, single available area failure, can quickly through the cluster switch for disaster recovery. At the same time, other services on which the data flow service depends are equipped with multi-cluster disaster resilience across AZ.

In the Tencent cloud · cloud development mode, the cloud development establishes the access link from the client to the business logic, and the developer does not need to pay attention to the link construction between the client and the business logic and a series of problems involved. At the same time, cloud development to provide users with the current popular Serverless architecture ability, developers based on lightweight cloud function, cloud hosting to achieve business logic, no need to care about the infrastructure, with the advantages of Serverless brought by very simple operation and maintenance, on a scale of the cost, elastic scalability and other aspects. It helps developers to truly focus only on the implementation of the business logic layer, liberating developers’ productivity and allowing developers to focus more time on business design.

In addition, cloud development helps users solve the above problems, but also provides developers with many other capabilities, so that developers can get additional service capabilities support.

  1. Reduce cost and increase efficiency, extremely simple operation and maintenance, reduce communication costs, avoid a lot of tedious matters, save development time, can have more sufficient time for business logic design in the limited development time.
  2. Architecture-free, for most scenarios, business development can be done directly without much architectural design
  3. Eliminate server setup and operation and maintenance
  4. Resources are charged according to demand to reduce costs
  5. Log, monitor alarm capability support
  6. WeChat native access, with the help of WeChat native capabilities
  7. Private link, access optimization, high security, anti hijack, anti attack, anti brush, anti wool
  8. Authentication, native right to avoid authentication, reliable user identity information, prevent impersonation, prevent malicious users
  9. Open API, native cloud call ability, convenient for WeChat development API, WeChat payment API call
  10. Real-time data push, developers need to build push service
  11. Active Switch: Provides capabilities such as operational switches for developers
  12. Comment Barrage: Support developers with comments barrage and other capabilities
  13. CMS content management
  14. Event operation: Developers can operate events through CMS, such as SMS operation
  15. Background management: to provide developers with development-free background management ability, save development costs
  16. Tool support
  17. Small program developer tools
  18. CLI command-line tools
  19. Cloudbase Framework
  20. VSCode plug-in
  21. Low bit platform
  22. An efficient, drag-and-drop, low-code development platform that quickly builds multiterminal applications through professional templates, drag-and-drop components, and visual configurations
  23. Cloud development based on the underlying capability support, cloud development native capability support
  24. Expert service of cloud development team, help the business solve various problems encountered in the business, and provide optimization suggestions.

Resisting 500 million visits, Tencent Cloud · Cloud Development escorts you

When a new form of technology appears in front of people, some people choose to wait and see, and then decide whether to try to adopt it, while others are bold to try. Although Serverless and Tencent Cloud · Cloud Development have only been born for two years, cloud development has been pursued by a large number of developers. Currently, there are more than 650,000 registered accounts for cloud development and more than 1 million developers. The average daily volume of cloud development calls is nearly 1 billion. During the Spring Festival in 2021, the daily volume of service calls is more than 1.6 billion.

Cloud development has a good application in Tencent games, WeChat payment, WeChat reading, cat’s eye movies, Shenzhen airport and other diversified activities to help businesses quickly meet demands and support large flow peak smoothly.

For example, on the final night of Creation Camp 2020 last year, cloud development ensured the stable operation of the business and achieved 100% security without dead corners. At the same time, it also held the whole audience with high performance in the voting “seckill” scene, escorting the smooth progress of the program.

“Sichuan Tianfu Health Pass”, the official health code of Sichuan Province, which has been online for two weeks and received over 500 million visits, was developed based on the cloud development base. The front-end uses Weapps cloud to develop low code visualization, componencization, low code and other capabilities, and the back-end uses cloud function, cloud database, cloud hosting and other cloud native capabilities, giving full play to the advantages and convenience of cloud low code visualization development. Customized development with high quality was completed in more than ten days. At the same time, compared to traditional development model, delivery efficiency is doubled while labor costs are cut in half.

Spring Festival this year, WeChat Lucky Money cover again detonate a social network, timed open individual red envelope cover production activities is directly lower threshold, let more people be able to enjoy convenient to customize the red envelopes of pleasure out of the cover, this activity is to carry on the development of cloud, during the whole event platform lived hundreds of millions of flood peak flow, resource cost only spend thousands of yuan, effectively improve the efficiency of research and development, It greatly reduces the labor cost.

conclusion

A simple system needs sufficient design to meet the challenge of large traffic activities. Various types of systems have some common basic work. Tencent Cloud · Cloud Development abstracts such common work from the system and provides it to users in the way of service, so that developers do not need to care about these basic work.

Active systems with large traffic often need the demand of online capacity expansion. Cloud development provides the Serverless architecture to carry user business, so that the business does not need to relate to the underlying infrastructure at the same time, it has the automated elastic capacity of expansion and shrinkage, and helps the system resist the access of large traffic.

In this way, cloud development can help developers free up from basic work, and have more time to do business design, database design, stress testing and other work, so that the system can better meet the calls of large traffic activities.

Product introduction

Cloud development (TCB) is the cloud native integrated development environment and tool platform provided by Tencent Cloud. It provides developers with high availability, automatic elastic expansion of back-end cloud services, including computing, storage, hosting and other serverless capabilities, which can be used for integrated cloud development of a variety of end-end applications (small programs, Official account, Web application, Flutter client, etc.), which helps developers to build and manage back-end services and cloud resources in a unified way, avoiding tedious server construction, operation and maintenance in the application development process, and allowing developers to focus on the implementation of business logic with lower development threshold and higher efficiency. Open cloud development: https://console.cloud.tencent.com/tcb?tdl_anchor=techsite product documentation: https://cloud.tencent.com/product/tcb?from=12763 technical documentation: https://cloudbase.net?from=10004 technology exchange and Q group: 601134960 Latest news pay attention to WeChat public account [Tencent Yunyun Development]