当前位置:网站首页>Get started REPORT | today, talk about the microservice architecture currently used by Tencent
Get started REPORT | today, talk about the microservice architecture currently used by Tencent
2022-07-02 12:45:00 【Follow me to learn java】
Since last year 10 After Sogou was officially merged by Tencent in January , I've always wanted to tell you about some of the technology stacks currently being developed and used inside Tencent , I think it has high learning value for students . But there are clear regulations within the company , It is not allowed to share and publish unpublished information privately . Once found , Dismissal of high voltage line ! So I haven't done it for a long time .
Recently, I was in Tencent TechoDay During the technology open day, I learned about the core Polaris of microservices being used internally (Polaris-Mesh) And one-stop microservice development framework Spring Cloud Tencent Have been opened to the outside world .
The north star Github:https://github.com/polarismesh
Spring Cloud Tencent:https://github.com/Tencent/spring-cloud-tencent
Then I can combine them today to give you a brief talk about Tencent's internal micro service system .
One 、 Why embrace microservices
I am a 2011 Entered Tencent in , The technology stack used at that time was mainly LAMP(Linux + Apache + MySQL + PHP). At that time, another popular technology stack in the industry was MVC(Spring + iBatis/Hibernate + Tomcat). Whether it's LAMP still MVC, They are all designed for single entities to share the architecture . The developed services are also deployed on physical servers , Generally, it is deployed by the operation and maintenance .
stay web The era of web pages , The above two sets of technology stacks have been really popular for a long time . But with the explosion of mobile Internet , There are more and more services to be developed , Functions are becoming more and more complex , Team developers are also expanding , More and more frequently . The traditional single service architecture gradually presents these problems .
Inefficient Deployment Services : Traditional single services are deployed directly on physical machines or virtual machines , The software that the service operation depends on must be manually installed and configured by the operation and maintenance department .
Machine resources are difficult to reuse : Modern server configurations are very high , But few single services to run can put CPU、 Memory and other resources are fully utilized , There will be a lot of idle . But in order to ensure the isolation between services , They often dare not deploy multiple services they don't want to do together .
The cost of teamwork is high When there are multiple people in charge of the same service , It is inevitable that the submitted code will affect each other , Release also needs to be discussed . In addition, the testing work before each release also needs to be very comprehensive .
Later on , Slowly, the concept of service has been derived . Split the single application into several different services for independent deployment and release . For example, I was responsible for Sogou mobile assistant , In the background, it is divided into application recommendation lists 、 Apply check updates 、 Search for 、 Accurate recommendation 、 Cloud control 、 Address location and other independent services come out .
stay 2014 Year begins , Docker Containers became popular , The degree of virtualization is compared with that before KVM With a qualitative leap . A container image can package all the software environments that the service depends on , In the smallest case, it's only a dozen M That's it , It's very free and convenient to distribute . It can be started in seconds .
The industry has carried out a series of evolution and iteration around container technology , Gradually evolved today's Micro service architecture . The popularity of microservices is 2017 Suddenly broke out years later , Major first-line Internet companies have also introduced this technology and implemented it in their actual business , Tencent is no exception .
Two 、 Tencent's microservice engine
Early on, various departments within Tencent began to test water micro services to varying degrees . stay 2020 In, we integrated many previous microservice frameworks within the company , Born the present with tPRC As the core of the microservice framework . Now most of the services and interfaces have almost switched to the container based microservice architecture .
Tencent is also good , The industry . Although the microservice architecture will differ in the details of technology selection . But basically, it can be represented by the following microservice architecture diagram .
In this microservice architecture , The left and right sides are the infrastructure of microservices , In the middle is the development framework . Among these basic components , I think the most important and core is the one on the left of the above figure gateway 、 Name Service Polaris 、 And the configuration center . This is also Tencent's external cloud micro service engine (Tencent Cloud Service Engine,TSE) The ability to open to the outside world .
So I'll talk about these three next .
2.1 Cloud gateway
In the era of monomer application , The practice in the access layer is generally to apply for an Internet domain name , Then in the access layer, the request is distributed to different business servers according to the domain name .
In the microservices architecture , Gateway is still the entrance of traffic . But in the era of micro Services , The number of services is much more than before . It is no longer possible to directly configure one domain name and one service , And in the microservice scenario, routing 、 The demand for monitoring, configuration management and other aspects is stronger .
Therefore, a microservice gateway is needed , As all API The main entrance of the interface . The gateway encapsulates the back-end microservices , adopt API The gateway exposes services uniformly . Provide unified security in the gateway 、 route 、 Flow control 、 Monitoring and other services . When traffic arrives , After some preprocessing, the gateway can distribute traffic according to different service names .
2.2 Service Governance Center
Tencent's service governance component is called Polaris . The project was originally a unified name service component jointly built by Tencent's internal open source collaboration , For resolution RPC Called service registration 、 Dynamic routing 、 Load balancing and fault tolerance .
Now Polaris is not only deployed to Tencent cloud to provide external services , And also settled in the open source community . The project has been widely concerned by the industry since it was launched .
Github Address :https://github.com/polarismesh
The project is not only to open source all the source code , Moreover, detailed usage documents are configured .
Next, let me introduce this open source project Polaris Mesh Problems solved and capabilities provided .
In the microservice Architecture , The first problem to be solved is how to find the service you want to call . In a big company , There may be thousands of services running online at the same time . So when your service wants to call a service , How to correctly find the corresponding service and access it ?
This problem is through Polaris Polaris Mesh Service registration and discovery mechanism . The service provider will send Polaris Mesh Register your service name and address . When the caller needs to call, it is embedded in the process Proxy Agent first Polaris Mesh Get the service address to call , After finding it, directly launch the call .
Generally, service providers have multiple instances , So which one should I choose to visit ? There are two different usage scenarios .
One use case is grouping , For example, your service callers and service providers may be deployed in multiple places , stay Linux Network performance 15 Two optimization suggestions ! In the article, we mentioned that it is best to call services in the same machine room . Avoid calling across machine rooms . Because it will take too long . Another example is that you may need to deploy the test environment separately , And grayscale environment .
Another application scenario is load balancing , Even in the same environment and machine room , It is possible that each service provider's CPU And other configurations are different , It is also necessary to reasonably schedule the request traffic .
These two practical application scenarios need to be solved through reasonable routing rules .
Let's talk about current limit . In the responsiveness of services, there is a word called avalanche . Avalanche refers to a natural phenomenon , There is a lot of snow on the snow mountain , But they are stable . But when the last snowflake fell , The whole snow mountain collapsed . There is a similar phenomenon in services , If your service can be handled normally every second 1000 A request , But if it comes 1001 A request , The whole service will crash , even 1 A request can't be handled normally . This is the avalanche in service .
In order to eliminate this phenomenon in service management , A current limiting function was born . You can configure the maximum processing capacity of a service instance , When this processing capacity is exceeded, no new requests will come later , To ensure the normal operation of the service . There are two ways of current limiting , One is rapid failure , Refuse the extra request directly . Second, line up evenly , Let the service handle it slowly . It's like the flow restriction bar in the subway station .
These two current limiting capacities are Polaris Mesh Can be easily configured in .
In addition to the above abilities ,Polaris Mesh It also includes circuit breaker rules 、 Access authentication 、 Observable and so on . In terms of access mode, it not only provides Java / Go / C++ / Node.js / PHP Of SDK Access , And support Spring Cloud / gRPC 、 Service Grid 、K8s Service governance and other mainstream clients . The complete access method is shown in the figure below :
On the use , I think the configuration tools provided by Tencent cloud are more convenient than those we use internally . Routing rules 、 Fusing rules 、 Current limiting rules can be configured directly on the interface . It's very convenient to use .
2.3 Configuration center
In the era of traditional single service , Configuration is often written in a thing called configuration file . But in the era of microservices , Due to the explosion in the number of services , A lot of configuration items , All kinds of irregular modification requirements will make the whole work process seem chaotic . Too scattered configuration files increase the difficulty of management .
So in the era of micro Services , Configuration centers have become standard . The idea is to put all the parameters in the project 、 Configuration information such as switches , All in a centralized place for unified management , And provide a set of standard interfaces . When a service needs to get configuration , Call the interface to pull . When there is a configuration update , The configuration center will notify each service period to load dynamically .
In the industry , There are many common solutions , Include Zookeeper、Eureka、Nacos、Consul、Apollo wait . Tencent's cloud TSE All of the above mainstream configuration center solutions support , And the function is enhanced , Provide a visual console 、 Service management 、 journal 、 monitor 、 The alarm 、 Authentication and other functions that the original scheme does not have .
On deployment , You no longer need your own operation and maintenance team to deploy . One click deployment supports multiple activities 、 Highly available configuration center clusters such as persistence .
In the visual console , It is very convenient to manage the data of the configuration center 、 Log view 、 Operation monitoring and other daily operations .
The north star Github Address :https://github.com/polarismesh
2.4 Development framework
about Java For developers , It can also be used directly Spring Cloud Tencet Development framework . The framework implements Spring Cloud Standard microservices SPI, It relies on Polaris polaris, Implement various distributed micro service scenarios .
Spring Cloud Tencent All components have been uploaded to Maven The central warehouse , Just introduce dependencies .
Spring Cloud Tencent:https://github.com/Tencent/spring-cloud-tencent/
3、 ... and 、 summary
Microservice architecture is a popular technology . Building a set of microservice infrastructure often requires assembling a series of microservice middleware , For example, service registry 、 Configuration center 、 Log center, etc . The initial cost investment is very high . Generally, large companies have special human and financial resources to build these basic wheels needed by microservices .
For small and medium-sized companies , Even for individual developers , If all from 0 Deploy these basic components that microservices depend on , Deployment alone is enough to toss for a long time . Moreover, there are many technology options in microservices , For example, the configuration center has Zookeeper、Eureka、Nacos、Consul、Apollo And so on . The difficulty of learning and operation and maintenance is much more complex than the traditional development mode .
But as a small and medium-sized company or individual developer , If you don't touch the microservice architecture, it will slowly be out of touch with the times . Fortunately, now public cloud manufacturers have provided microservice infrastructure . I am here Techo Day The feeling experienced on , It's just too convenient , Open the box .
Recall that I just started to toss Zookeeper、Consul When , Compilation and installation alone waste a lot of time . Now one click deployment can be used , It's really convenient . And I feel that Tencent's external product experience is better polished , In fact, many places are easier to use than our internal tools .
边栏推荐
- Js6day (search, add and delete DOM nodes. Instantiation time, timestamp, timestamp cases, redrawing and reflow)
- Docker compose configuration mysql, redis, mongodb
- js1day(输入输出语法,数据类型,数据类型转换,var和let区别)
- JDBC prevent SQL injection problems and solutions [preparedstatement]
- 面渣逆袭:MySQL六十六问,两万字+五十图详解!有点六
- 深拷贝 事件总线
- 移动式布局(流式布局)
- Docsify deploy IIS
- 正确遍历EntryList方法
- . Net, C # basic knowledge
猜你喜欢
深拷贝 事件总线
面渣逆袭:MySQL六十六问,两万字+五十图详解!有点六
JS7day(事件对象,事件流,事件捕获和冒泡,阻止事件流动,事件委托,学生信息表案例)
Docker compose configuration mysql, redis, mongodb
JS6day(DOM结点的查找、增加、删除。实例化时间,时间戳,时间戳的案例,重绘和回流)
Rust search server, rust quick service finding tutorial
Deep Copy Event bus
移动式布局(流式布局)
线性DP AcWing 899. 编辑距离
Anxiety of a 211 programmer: working for 3 years with a monthly salary of less than 30000, worried about being replaced by fresh students
随机推荐
Counting class DP acwing 900 Integer partition
C#运算符
CV2 in OpenCV VideoWriter_ Fourcc() function and cv2 Combined use of videowriter() function
spfa AcWing 851. SPFA finding the shortest path
js5day(事件监听,函数赋值给变量,回调函数,环境对象this,全选反选案例,tab栏案例)
Js1day (syntaxe d'entrée / sortie, type de données, conversion de type de données, Var et let différenciés)
Openssh remote enumeration username vulnerability (cve-2018-15473)
Js8day (rolling event (scroll family), offset family, client family, carousel map case (to be done))
Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
防抖 节流
线性DP AcWing 895. 最长上升子序列
Js10day (API phased completion, regular expression introduction, custom attributes, filtering sensitive word cases, registration module verification cases)
哈希表 AcWing 840. 模拟散列表
spfa AcWing 851. spfa求最短路
ASP. Net MVC default configuration, if any, jumps to the corresponding program in the specified area
H5 to app
Introduction to CPU instruction set
Modular commonjs es module
应用LNK306GN-TL 转换器、非隔离电源
Use MySQL events to regularly perform post seven world line tasks