Another open source masterpiece of Tencent North Star, a million-level cloud native service discovery and governance center

Follow the “Wonderful World of Linux”

Set it as a “star” and take you to enjoy Linux every day!

Polaris is Tencent’s open source service discovery and governance center , dedicated to solving service visibility, fault tolerance, traffic control and security issues in [distributed] or microservice architectures. Although there are some components in the industry that can solve some of these problems, there is a lack of a standard, multi-language, framework-agnostic implementation.

Tencent has a large number of distributed services, coupled with the diversity of business lines and technology stacks, and has accumulated dozens of related components, large and small. Starting in 2019, we have abstracted and integrated these components through Polaris to create a unified service discovery and governance solution for the company to help businesses improve R&D efficiency and operational quality.

At present, the number of service registrations of Polaris in Tencent exceeds one million, and the daily interface call volume exceeds ten trillion. The versatility and stability have been verified on a large scale. Therefore, we contribute it to the open source community, hoping to help other companies and attract more developers to participate in the co-construction.

feature

  • The functions of Polaris are implemented in the form of plug-ins. Businesses can choose to use them according to their needs, and it is also very easy to achieve expansion.

  • Provides two access methods: SDK and Sidecar, SDK is suitable for high-performance business scenarios, and Sidecar is suitable for non-invasive development mode

  • For the access method of the SDK, clients in multiple languages ​​such as Java, Go, C++ and NodeJS are provided, and the functions are the same

  • The Polaris SDK can be integrated into commonly used frameworks and gateways such as Spring Cloud, gRPC and Nginx

  • Suitable for Kubernetes, supports automatic injection of K8s service and Polaris sidecar

  • The open source version of Tencent’s million-level service governance center has accumulated Tencent’s years of distributed service governance experience

control plane

The implementation of the Polaris control surface has three characteristics:

  • The computing and storage are separated, and the computing layer nodes can be expanded in parallel with the increase of client nodes, which can easily support access to millions of nodes.

  • There is only one process in the control plane, which is divided into access layer, logic layer, storage layer and cache layer. The structure is clear and easy to maintain.

  • The access layer, storage layer and cache layer adopt plug-in design, which is easy to expand and suitable for different application scenarios

Polaris and k8s

k8s service

k8s provides service discovery and load balancing functions through service:

  • The user creates a service, the service binds the corresponding pod through the label, and each service is associated with a cluster ip

  • k8s first relies on kubedns, coredns or other dns plugins to parse the service into cluster ip

  • Then through iptables or IPVS, forward the request of the cluster ip to the corresponding pod

Click on the picture above to open the applet, and receive “Meituan Takeaway” red envelopes for free every day!

The current implementation of k8s service has shortcomings:

  • When the number of services exceeds a certain number, iptables and IPVS have performance problems and are not suitable for large-scale business

  • The load balancing algorithms supported by iptables and IPVS are limited, implemented in the kernel and cannot be extended at the application layer

  • Does not provide common service governance functions such as dynamic routing, circuit breaker downgrade, access current limiting, and access authentication

  • It is not compatible with the service registration and discovery methods of microservice frameworks such as spring cloud, and cannot be [connected]

Using Polaris on k8s

Use Polaris to complement k8s’ service discovery and governance capabilities:

  • It supports both the automatic registration of k8s service and the use of SDK and framework for registration, both of which are managed together

  • In addition to the original DNS access method of k8s, it also supports high-performance and non-intrusive service mesh solutions

  • High-performance service mesh provides multi-language SDK, and integration of common frameworks and North Star SDK

  • Non-intrusive service mesh provides Sidecar, business does not need to rely on SDK or framework

Quick start

pre-preparation

Prepare the database

You need to download and install MySQL, the version number is >=5.7, you can download it here: https://dev.mysql.com/downloads/mysql/5.7.html

Import database table building script

The table building script is  ./store/defaultStore/polaris_server.sql, which can be imported through the mysql command or the admin client

Prepare the golang compilation environment

Polaris server compilation requires golang compilation environment, and the version number requires >=1.12, which can be downloaded here: https://golang.org/dl/#featured

Compile and build

chmod +x build.sh
./build.sh

polaris-server-release_${version}.tar.gz Packages that can be seen in the current directory after the build is complete  .

Install

Unzip the package

Get polaris-server-release_${version}.tar.gz and extract it

Modify database configuration

Enter the decompressed directory, open polaris-server.yaml, and replace several variables related to DB configuration with actual database parameters; ##DB_USER## (database username), ##DB_PWD## (database password), ## DB_ADDR## (database address), ##DB_NAME## (database name)

Execute the installation script

chmod  +x ./tool/ *.sh 
#Installation
./tool/install.sh

#Test whether the process is started successfully./tool/p.sh

After running p.sh in the last step, return to Polaris Server to prove that the startup is successful.

Verify installation

curl http://127.0.0.1:8080

Return to Polaris Server to prove functionality

experience

Official website address: https://polarismesh.cn/, the official also provides an online experience version, address: http://159.75.195.18/

Warehouse address: https://github.com/polarismesh/polaris

This article is reproduced from: “Github lovers”, the original text: https://tinyurl.com/4n823c7y, the copyright belongs to the original author. Contributions are welcome, submission email: editor@hi-linux.com.

You might also like

Click the image below to read

13 pictures show you how to understand Kubernetes Service to unlock GitHub’s new posture, and write code online with one click!

For more interesting Internet news, pay attention to the “Wonderful Internet” video account to learn all about it!

Leave a Comment

Your email address will not be published. Required fields are marked *