In recent two years, domestic document SaaS products emerge in endlessly, collaborative cloud document as a tool and way of office in cloud era. Different from the traditional offline office software, collaborative cloud documents pay more attention to the communication and efficiency of collaboration, and also pay attention to performance and experience as a tool product. Not long ago, “24 Hours of a Lifesaving Document” flooded wechat moments. In the torrential rain in Henan province, Tencent Document quickly responded to the needs of the disaster area to improve stability and ensure product experience.

Tencent Document was born out of the online document module of TIM, a team collaboration IM software owned by QQ family. Initially, the technical architecture based on open source software has been unable to fully meet the needs of business with the rapid development of business, and has accumulated heavy technical debt. After careful discussion, the team decided to reconstruct the whole technical system gradually by modules from the bottom. In the process of technical iteration, the team is also constantly exploring and trying some advanced and mature technical solutions in the industry.

Many micro-services are integrated into the whole technical system of Tencent Document to provide business support for Tencent document, such as image recognition, SSR, screenshot, document preview, etc. These micro-services need to consider solutions from the perspective of efficiency and cost, so as to achieve the goal of scalability, easy maintenance and reduced development cost. With the wave of the company’s own cloud research, in recent development, the team has made in-depth use of Tencent cloud Serverless architecture in a number of micro-service projects, meeting business needs and achieving good results.

01. Tencent Document X Serverless cloud function multi-scenario application

1. Handle traffic peaks and valleys

Office products have obvious flow tides, such as 8 in the morning to 12, 2 in the afternoon to 6 in the afternoon these periods are relatively large flow, other time periods, especially the early morning no flow. With the rapid increase in the number of users, this tidal pattern is particularly obvious, and the real-time modification of massive users during peak periods causes great pressure on the server.

In traditional architectures, VMS can be added to achieve application scalability. However, due to insufficient estimated capacity, a large number of users may request timeout during peak traffic hours, which means brand reputation damage and user loss. Although you can expand capacity by creating virtual machine instances, you still need to do a lot of additional configuration. At the bottom of an application, many dependent frameworks or languages need to be installed. After installation, applications need to be configured and deployed. This cycle takes at least one to two hours.

Serverless solutions

Tencent Document uses Serverless cloud function to build the document page direct output service, and realizes the content rendering capability of the document as a function.Deployed in the cloud function environment, when the document service traffic surges, the cloud function load balancing system automatically allocates the execution environment to handle the load of content update requests triggered by massive users. The dynamic capacity expansion capability provides the most reasonable resource allocation for micro services. At the same time throughSetting the cloud function preset concurrency can pre-start multiple function instances, keep the cloud function active, eliminate the cold start, and reduce the time generated in the initialization of the running environment and business code.

2. SSR front-end rendering

Tencent document since its launch, has reached tens of thousands of months of activity, in order to support users to open the page can quickly see the page content, browser directly parsing HTML straight out of the string template display page, traffic surge leads to cluster load, front-end rendering pressure increase, the first screen load time is slow and other problems. The SSR team needed to implement a set of flexible and highly available direct parsing services to process the page content of documents and tables, meeting the goals of being extensible, easy to maintain, and reducing development costs. The rendering ability of the document is almost in the charge of the front-end students, while most of the front-end students have little knowledge of the service side and have little experience in service development and operation. Long-term operation and maintenance cost is an important evaluation dimension of the new architecture design, so that the front-end team can focus more on the business logic itself.

Serverless solutions

SSR (server-side Rendering) relies on Node.js service to render pages, which requires more Server CPU resources than CSR (client-side Rendering), which only provides static files. With the Serverless solution, front-end students do not need to pay attention to the deployment, operation and expansion of SSR server, and encapsulate the underlying services through cloud functions, which greatly reduces deployment operation and maintenance costs, focuses more on business development and improves development efficiency.

New Serverless Web Funciton service development mode, simply modify the monitoring port, you can directly deploy the current popular Node.js framework on the cloud, enjoy Serverless technology to free operation and maintenance, low cost, on-demand expansion and shrinkage of many advantages, welcome to experience.

3. External service invocation – OCR image recognition

Tencent document slides support the ability to edit the formula, OCR image recognition is Tencent document slides combined with the external OCR service ability to complete the formula picture in the document into a formula, so as to facilitate users to edit the publicity. The problem lies in the following: ** External OCR services are limited, do not support front-end requests, only support server requests. ** Traditional solutions require background students to access, thus increasing the complexity of project management such as personnel scheduling and docking.

Serverless solutions

Tencent documents will externally provided OCR with cloud function SCF to do a layer of forwarding, Tencent documents and then connected to the interface of the cloud function. It solves the limitation of external services and saves background development resources. Front-end business development students can quickly connect with external services, greatly improving the development efficiency.

4. Plug-in Center – Access to third-party services

Tencent document plugin 1.0 scheme is based on document front-end wrapped in front plugin SDK scheme, the internal plug-ins business serious coupling document under the premise of not will document the ability to provide, in the form of security, a system’s ability to continue to open front end of the document editing, can make the front-end SDK and the realization of document side gradually become bloated, Finally, there is the potential for long-term technical debt in the megalithic application.

Serverless solutions

The core of the plug-in 2.0 solution is based on the open ability of background content editing. Using the responsive update mechanism of document data, ** cloud function becomes the key link in front-end, cloud function-background content editing. The open implementation is stripped from the front end and opened through cloud function bearing. ** At the same time, different services are called at different levels. Cloud functions have natural service isolation and dynamic repair capabilities, which can be isolated from each other for different services to upgrade and expand respectively to avoid the impact between services.

5. Grayscale release & environmental isolation

In the process of application version update and switch, in order to ensure the overall online system business stability and timely find business code problems, the R&D team will adopt grayscale release to test iteration. Through the cloud function for a specific version of the gradual traffic switch, can achieve a version of the smooth gray scale, to ensure that the new online version can be released in a controllable range of iteration.

By isolating the TEST environment from the production environment through the cloud function version, the API gateway of the TEST environment can be connected to the TEST version through the version solidification of $LASTEST online, and the production environment can be connected to the solidified version to ensure the code quality and safety of the production environment.

02. Advantages of Serverless architecture solution

  • Improving r&d efficiency

After the local development test, the CI/CD process is triggered to complete the deployment process. At the same time, cloud functions provide log monitoring, grayscale, release rollback capabilities, and can be fully automated through interfaces or plug-ins. The cloud function is based on Tencent cloud professional security cluster, with its own load balancing and elastic scaling, so the developers basically do not need to care about operation and maintenance and other issues, so they can have more time to focus on business optimization. Front-end development engineers with less server-side experience can easily develop and maintain services.

  • Cost savings

The cloud function implements 1ms billing granularity and charging based on actual usage, which helps users gain significant cost advantages and automatically reduces capacity when no traffic is accessed, saving deployment costs.

  • Flexibility is high

With the multi-version capability of Tencent cloud function, multiple online versions can be flexibly deployed. By cooperating with the gateway, multiple versions can coexist easily and customized processing capability can be provided.

  • Accelerating business iteration

After using The Serverless scheme, the burden of operation and monitoring is greatly reduced. The developers can put more energy on the optimization of the scheme and technical iteration, quickly verify the product characteristics, and promote the development of the team’s technical business.

03. Tencent document X Serverless architecture more scenarios to explore

Currently, the browser environment has performance bottlenecks. For complex asynchronous logic, cloud functions can be considered to serve the logic. Next, Tencent documents plan to Fass the front-end browser logic, which can be separated from the front-end to the server, so as to reduce the browser performance pressure.

On the track of collaborative office, the team’s business is still growing rapidly. In the face of rapidly changing technological iterations, the low-cost, rapid development, rapid deployment and rapid launch of Serverless solutions have become the team’s priority architecture in the selection of microservices technology. ** With the power of cloud function SCF, the team no longer has to worry about background computing resources and can be more confident to deal with more unexpected events. In the future, with the construction of Tencent Document open platform, there will be more microservices using cloud function SCF running in Tencent document business, to provide better services for the majority of users.

One More Thing

Experience Tencent Cloud Serverless Demo immediately and receive Serverless new user package 👉 Tencent Cloud Serverless novice experience

Welcome to: Serverless Chinese!