At present, many enterprises are faced with the diversity of technology stack during the implementation and evolution of microservices. The entire microservices field has gradually precipitated countless related components, making it more difficult for everyone to choose, which also brings constant challenges to the infrastructure construction of enterprises. Tencent also faced such a pain point, so since 2019, Tencent has created a unified micro-service solution Polaris Mesh. Polaris Mesh abstracted and integrated these components to create the company’s standardized service discovery and governance scheme, helping businesses improve r&d efficiency and operation quality.
After two years of development, Polaris has registered more than one million services in Tencent, the number of service instances exceeds five million, and the daily usage of interface transfer exceeds thirty trillion. Key products such as Tencent Music, Tencent Video, Tencent Conference, Tencent Document, enterprise wechat, wechat Pay and King of Glory are all in use.
On September 8, Tencent Cloud officially announced the open source Polaris Mesh for all developers, opening the source code of applications in mass production environment, promoting the open source ecological construction with microservices as the core, and hoping to help the industry better carry out the transformation of distributed or microservice architecture.
From monomer to microservice architecture
In the last decade or so, business architecture has evolved from singleton to distributed to microservices. All code in a single architecture is in one application, suitable for small or start-up businesses. If the number of application modules and developers is small, monolithic architectures are easy to develop, test, deploy, and scale. As application modules and developers increase, monolithic architectures face many problems, such as:
-
Any changes require recompiling and deploying the entire system, which is risky, costly to test, and slow to compile.
-
Defects in one service module will affect other service modules and reduce the availability of the entire system.
-
If the request volume of each service module is uneven, some hotspot modules cannot be horizontally scaled.
In order to solve these problems, distributed and microservice architectures split business modules into independent services, but the complexity of the whole system has also increased dramatically, and it is difficult to implement distributed and microservice architectures without supporting technical components. As the direction of the micro service developers, we all know that the service discovery and governance is the key technology of distributed and micro service architecture, can very good help you solve service addressing, traffic scheduling, fault tolerance, access control and observability problem, but the key technology in the industry currently open source advantages and disadvantages of each solution is not perfect.
Service discovery and governance techniques
Currently, there are three main service discovery and governance solutions in the industry:
-
The first, represented by Spring Cloud, integrates a number of service discovery and governance components into the development framework. Although it can be used in virtual machine and container environment without difference, it needs to introduce multiple scattered functional components during development, lack of unified data surface and control surface, and different languages and frameworks can not be unified management.
-
The second is Kubernetes Service, which registers the Service to the built-in ETCD and uses the domain name resolution plug-in to discover the Service. However, it has a disadvantage that it cannot provide the Service governance function.
-
The third service grid, represented by Istio, implements service discovery and governance by hijacking business requests. This scheme is less intrusive to the development code and has a unified data surface and control surface, but it needs to deploy the traffic agent process, and it will increase the operation and maintenance cost and have a large loss of resources and performance.
We believe that each of the three solutions has its advantages and disadvantages. It is not a question of who replaces who, but rather of integrating with each other to meet different business needs. Most of Tencent’s internal core businesses use the first scheme, and many businesses use the other two schemes on Kubernetes. However, there are still problems such as data unconnected between cross-department business systems and lack of standardized service governance.
In order to be able to merge the advantages of the above three kinds of solution, at the same time avoid their shortcomings, we created a unified solution – the north star, committed to creating a new generation of tencent service discovery and management center, to solve the problems existing in the original platform, and support the seamless migration, implementation company service connectivity and centralized management. At present, Polaris has more than one million registered services, more than five million service instances, and more than 30 trillion interface daily usage. Tencent Music, Tencent Video, Tencent Conference, Tencent Document, enterprise wechat, wechat Pay and King of Glory are all in use.
What is the North Star?
Polaris Mesh is a service discovery and governance center developed by Tencent. Based on the service registry, Polaris Mesh extends service governance functions and corresponding control surfaces, provides multi-language client implementations, and different development frameworks can be integrated and used. As containerization and cloud native advances, Polaris also supports automatic access to Kubernetes services and grid Sidecar, enabling interoperability and unified governance between them.
3.1 Functions and Features
Polaris has five main functions:
-
Register discovery: The foundation of Polaris is a high-volume and highly available service registry that, in addition to supporting service registration and discovery of multiple protocols, also supports health checks on registered service instances to avoid callers sending requests to abnormal instances. In a distributed application architecture built around services, service registration and discovery are crucial to improve application scalability and reduce application migration costs.
-
Traffic scheduling: Polaris provides dynamic routing and load balancing traffic scheduling functions. Dynamic routing, based on request label, instance label and label matching rules, can realize multiple routing strategies such as proximity by region, unitary isolation and canary publishing. Load balancing Allocates requests to different instances of the called party in a balanced manner, supporting various algorithms such as random weight, minimum load, and weight consistency Hash.
-
Fuse downgrading: Polaris supports fuse downgrading of instance, interface, and service granularity. If a partial instance of the called party is fusing, the request is assigned to another instance. If an interface or service of the called party is fusible, the call is returned based on the demotion policy. Network jitter, machine faults, and program defects may cause instances, interfaces, or services to be abnormal. Fusing degradation improves the success rate of service requests.
-
Access control: Polaris provides two access control functions: authentication and traffic limiting. The called party can set authentication rules to allow and deny the access of the called party. The called party can also set single-node or distributed traffic limiting rules. On the one hand, the called party cannot be completely unavailable due to sudden traffic. On the other hand, the called party may consume a large amount of resources and affect other called parties.
-
Service Grid: Polaris provides a unified control surface and data surface for the above service discovery and governance functions. The data plane function is implemented in configuration mode. The control plane can deliver service data and governance rules to the data plane and dynamically adjust the execution policies of the data plane. Data plane supports multi-language SDK and Sidecar modes.
3.2 System Components
Polaris components are divided into core and ecological components:
-
Core components: console, control surface and data surface
-
Ecological component: for framework, gateway and Kubernetes docking
The Polaris control surface contains both the service registry and the service governance control surface, which is equivalent to the control surface of the industry’s service grid. The data surface is divided into SDK and Sidecar modes. SDK mode provides multi-language implementation, does not need to hijack the business request, and business request protocol is independent, suitable for integration in the development framework. The Sidecar mode requires service requests to be hijacked, resulting in performance and resource loss and high deployment and o&M costs. Therefore, the Sidecar mode is suitable for non-invasive development scenarios.
To reduce the cost of using the business, Polaris offers three types of ecological components. The first type is used for seamless integration of various development frameworks and Polaris data surface, so framework users do not need to directly call Polaris data surface, reducing the intrusion of development; The second type is used for seamless integration of various gateways and Polaris data planes, enabling the gateway to forward requests directly to Polaris service; The third ecological component is only Polaris-Controller, which supports automatic access to Kubernetes service and grid Sidecar.
3.3 Best Practices
At present, The commonly used frameworks, gateways and container platforms of Tencent have been integrated with Polaris, forming a service discovery and governance system with Polaris as the core. Here are the best practices of Polaris in Tencent:
First, as a unified service discovery platform of the company, to realize the interconnection of Intranet services of the company. Polaris uses a separate architecture for computing and storage. The computing layer can be expanded in parallel with the increase of the number of clients, easily supporting millions of client access. In addition, the server supports multiple deployment modes, such as same-city or cross-city multi-center deployment, to meet different Dr Requirements.
Second, provide uniform service discovery and governance capabilities for different development languages and frameworks. Tencent has many business lines and many development languages and frameworks. Polaris data surface supports multi-language SDK and Sidecar modes. The framework can directly integrate the SDK of the corresponding language, without the need to deploy Sidecar, increase operation and maintenance costs, and have no performance and resource loss.
Third, as a gateway to Intranet service connector. The gateway can integrate with Polaris to forward requests directly to Polaris services, enabling microservices gateway capabilities.
Fourth, the existing open source components are divided into two systems, one built around the service registry and development framework, and one built around the Kubernetes service and grid. Both systems have their own highlights and limitations. With the advancement of containerization and cloud native, more and more enterprises are using both systems simultaneously. However, the realization of the two systems is separated, which adds unnecessary cost to the business. Polaris fuses the two systems to provide an integrated service discovery and governance solution for virtual machine and container environments, development frameworks, and grids.
Fourth, the relationship between Polaris and open source ecology
4.1 North Star and Frame
Polaris clients can be integrated into a variety of frameworks to quickly upgrade a bare development framework to a distributed and microservice framework with complete service discovery and governance capabilities.
Polaris has been integrated into all commonly used frameworks of Tencent’s business, including self-developed frameworks as well as open source frameworks such as gRPC, Spring and Gin. As mentioned above, these integrations will also be open source as Polaris ecological components, which framework users can import directly without any changes to the logic code.
4.2 Polaris and Gateways
Similar to gateways and frameworks, Polaris can also be integrated with common open source gateways.
4.3 Polaris and Kubernetes
With the advancement of containerization and cloud native, more and more enterprises begin to use Kubernetes deployment services, and Tencent is no exception.
In addition to the registry and framework, there are two service discovery and governance scenarios on the Kubernetes environment:
-
Kubernetes service: discovers services through DNS domain name resolution and implements load balancing using iptables or IPVS. This solution is simple and easy to use, but lacks other service governance capabilities, resulting in performance bottlenecks for large-scale services.
-
Grid: Service discovery and governance by hijacking business requests. This scheme has comprehensive functions, but it has CPU and performance loss and high operation and maintenance cost.
In Tencent, the vast majority of businesses use the registry and framework scheme, and many businesses use Kubernetes service. Grid is still in the trial stage in a small range.
Polaris provides Polaris-Controller, supports Kubernetes service and grid Sidecar automatic injection, realizing the connection and unified governance of the three schemes.
Fifth, Polaris open source planning
Polaris has evolved and developed in the process of meeting Tencent’s business needs, accumulating experience in Tencent’s super-scale service discovery and governance. No open source component is completely similar to Polaris. Tencent has many business lines, including instant messaging, music and video, fintech and enterprise services, etc. The problems faced by Polaris and the corresponding solutions are highly versatile. We believe that Polaris can also help other enterprises to better transform their distributed or micro-service architectures, improve their r&d efficiency and operational quality.
The Polaris open source version comes directly from The production code of Tencent, and we have submitted the main part to the community. We look forward to more interested and capable developers to participate in the construction. The follow-up plans include but are not limited to:
-
Improve service discovery and governance
-
Provides data side SDKS for more languages
-
Optimize the performance of Sidecar on the data side
-
Enhance Polaris integration with related open source components
-
Improve project documentation
-
Bring in open source enthusiasts from other companies
Welcome to join
Up to now, Tencent has opened more than 130 high-quality projects, more than 2,000 code contributors, and more than 370,000 open source projects star. Polaris is a newly launched open source project in the field of micro services. Interested partners are also welcome to submit an issue and PR on Github for discussion and contribution, or join Polaris community group to participate in community discussion.
Polaris GitHub: github.com/polarismesh…
Polaris official website: polarismesh.cn/
Communication group: since the number of members of the group has reached 300+, please add the wechat account of the middleware xiaoq sister (wechat signal: midwareQmei) and send the group password “Polaris” to wait for the verification and reply.