大规模场景下对Istio的性能优化

简介

当前istio下发xDS使用的是全量下发策略,也就是网格里的所有sidecar(envoy),内存里都会有整个网格内所有的服务发现数据。这样的结果是,每个sidecar内存都会随着网格规模增长而增长。

Aeraki-mesh

aeraki-mesh项目下有一个子项目专门用来处理istio配置分发性能问题,我们找到该项目:
https://github.com/aeraki-mesh/lazyxds

从该项目的部署yaml中,我们知道它会在网格中增加两个组件:

  • egress:充当类似网格模型中默认网关角色

  • controller:用来分析并补全服务间的依赖关系

Egress

对应的配置文件为:lazyxds-egress.yaml
下面来一一查看该组件的组成部分

组件配置

apiVersion: apps/v1
kind: Deployment
metadata:name: istio-egressgateway-lazyxdsnamespace: istio-systemlabels:app: istio-egressgateway-lazyxdsistio: egressgateway
spec:replicas: 1selector:matchLabels:app: istio-egressgateway-lazyxdsistio: egressgatewaytemplate:metadata:annotations:sidecar.istio.io/discoveryAddress: istiod.istio-system.svc:15012sidecar.istio.io/inject: "false"labels:app: istio-egressgateway-lazyxdsistio: egressgatewayspec:containers:- args:......image: docker.io/istio/proxyv2:1.10.0imagePullPolicy: IfNotPresentname: istio-proxyports:- containerPort: 8080protocol: TCP- containerPort: 15090name: http-envoy-promprotocol: TCP......volumeMounts:- mountPath: /etc/istio/custom-bootstrapname: custom-bootstrap-volume......volumes:- configMap:defaultMode: 420name: lazyxds-als-bootstrapname: custom-bootstrap-volume

由于配置太多,这里只挑选主要的部分,从上面可以看出,其实是启动一个istio proxy,该proxy的启动配置文件是使用的configmap挂载出来的。

启动配置

apiVersion: v1
kind: ConfigMap
metadata:name: lazyxds-als-bootstrapnamespace: istio-system
data:custom_bootstrap.json: |{"static_resources": {"clusters": [{"name": "lazyxds-accesslog-service","type": "STRICT_DNS","connect_timeout": "1s","http2_protocol_options": {},"dns_lookup_family": "V4_ONLY","load_assignment": {"cluster_name": "lazyxds-accesslog-service","endpoints": [{"lb_endpoints": [{"endpoint": {"address": {"socket_address": {"address": "lazyxds.istio-system","port_value": 8080}}}}]}]},"respect_dns_ttl": true}]}}

从上面配置可以知道:

  • 定义了proxy组件代理的集群,该集群为"lazyxds-accesslog-service"

  • 该集群对应的后端服务地址为"lazyxds.istio-system",端口为8080
    这个后端就是lazyxds controller,后面细说

EnvoyFilter

从yaml文件我们看到,还定义了一个envoyfilter来修改proxy代理的流量配置

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:name: lazyxds-egress-alsnamespace: istio-system
spec:workloadSelector:labels:app: istio-egressgateway-lazyxdsconfigPatches:- applyTo: NETWORK_FILTERmatch:context: GATEWAYlistener:filterChain:filter:name: "envoy.filters.network.http_connection_manager"patch:operation: MERGEvalue:typed_config:"@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager"access_log:......- name: envoy.access_loggers.http_grpctyped_config:"@type": type.googleapis.com/envoy.extensions.access_loggers.grpc.v3.HttpGrpcAccessLogConfigcommon_config:log_name: http_envoy_accesslogtransport_api_version: "V3"grpc_service:envoy_grpc:cluster_name: lazyxds-accesslog-service

从这个配置文件,可以看出在启动envoy时,会向其注入一个accesslog service,也就是envoy的日志收集器,而这个service就是lazyxds-accesslog-service

Controller

具体的lazy xds实现就是通过这个controller实现的

apiVersion: apps/v1
kind: Deployment
metadata:labels:app: lazyxdsname: lazyxdsnamespace: istio-system
spec:replicas: 1selector:matchLabels:app: lazyxdstemplate:metadata:labels:app: lazyxdsspec:serviceAccountName: lazyxdscontainers:- image: aeraki/lazyxds:latestimagePullPolicy: Alwaysname: appports:- containerPort: 8080protocol: TCP
---
apiVersion: v1
kind: Service
metadata:labels:app: lazyxdsname: lazyxdsnamespace: istio-system
spec:ports:- name: grpc-alsport: 8080protocol: TCPselector:app: lazyxdstype: ClusterIP

从配置可以看到,在egress环节我们知道了proxy的代理的后端地址为lazyxds.istio-system,刚好对应这里的controller。

并且我们还知道,envoy的访问日志最终会发送给这个controller来处理,而这就是实现增量下发envoy配置的关键之处,也就是解决istio性能的解决之法。

增量下发

Accesslog接口

要接受envoy的访问日志,必须实现envoy定义的接口:

type AccessLogServiceServer interface {// Envoy will connect and send StreamAccessLogsMessage messages forever. It does not expect any// response to be sent as nothing would be done in the case of failure. The server should// disconnect if it expects Envoy to reconnect. In the future we may decide to add a different// API for "critical" access logs in which Envoy will buffer access logs for some period of time// until it gets an ACK so it could then retry. This API is designed for high throughput with the// expectation that it might be lossy.StreamAccessLogs(AccessLogService_StreamAccessLogsServer) error
}

日志解析

lazyxds实现如下:

func (server *Server) StreamAccessLogs(logStream als.AccessLogService_StreamAccessLogsServer) error {for {data, err := logStream.Recv()if err != nil {return err}httpLog := data.GetHttpLogs()if httpLog != nil {for _, entry := range httpLog.LogEntry {server.log.V(4).Info("http log entry", "entry", entry)fromIP := getDownstreamIP(entry)if fromIP == "" {continue}upstreamCluster := entry.CommonProperties.UpstreamClustersvcID := utils.UpstreamCluster2ServiceID(upstreamCluster)toIP := getUpstreamIP(entry)if err := server.handler.HandleAccess(fromIP, svcID, toIP); err != nil {server.log.Error(err, "handle access error")}}}}
}

上面主要的逻辑就是解析envoy的访问日志,然后进行处理:

  • lazy xds Controller 会对接收到的日志进行访问关系分析,然后把新的依赖关系表达到 sidecar CRD 中。

  • 同时 Controller 还会更新 Egress 的规则:删除、更新或创建。

Slime

网易Slime方案与腾讯云Aeraki方案的思路一致
文档:https://cloudnative.to/blog/netease-slime/
github:https://github.com/slime-io/slime/tree/master/staging/src/slime.io/slime/modules/lazyload

https://cloud.tencent.com/developer/article/1922778

https://www.zhaohuabing.com/post/2018-09-25-istio-traffic-management-impl-intro/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/68225.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【数据结构初阶】一. 复杂度讲解

相关代码gitee自取: C语言学习日记: 加油努力 (gitee.com) 接上期: 学C的第三十四天【程序环境和预处理】_高高的胖子的博客-CSDN博客 1 . 算法效率 (1). 什么是数据结构: 数据结构(Data Structure)是计算机存储、…

STM32G030F6 (SOP-20)Cortex ® -M0+, 32KB Flash, 8KB RAM, 17 GPIOs

淘宝淘了一批 STM32G030F6P6 SOP20.先备注一下, 还没想到能干嘛用. 手上的 STM32F103C6T6还剩一些. 一堆 “淘宝原厂STM32F103C8T6”, 还烫着手. 理解信息: ( 逐步补充 ) System Clock GPIOs GPIOs 17 PA[7:0] : 8bits USART Timer ADC I2…

git 操作

merge操作 git checkout -b bugFix git commit //在bugFix branch上操作,并且commit git checkout main git commit //在main上操作,并且commit git merge bugFix //此时on main branch,如果在bugFix branch执行merge bugFix&#…

10881 - Piotr‘s Ants (UVA)

题目链接&#xff1a;Online Judge 根据刘汝佳的解法的思路&#xff0c;我的代码如下&#xff1a; #include <cstdio> #include <algorithm> #include <string> const int maxn 10001;struct ant{int id;int loc;int dir; };bool cmp(const ant &a, c…

springdoc-openapi-ui 整合 knife,多模块分组,脚手架

pom文件&#xff1a; <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache.o…

混合查询多家快递,快速掌握物流信息

在现代社会&#xff0c;快递服务已成为我们日常生活的重要组成部分。无论是购物还是文件传递&#xff0c;我们都需要快递服务的帮助。然而&#xff0c;不同的快递公司需要不同的查询方法&#xff0c;这无疑增加了我们的查询难度。因此&#xff0c;有没有一种方法可以让我们一次…

CVE-2023-3450:锐捷 RG-BCR860 命令执行漏洞复现

锐捷 RG-BCR860 命令执行漏洞(CVE-2023-3450)复现 0x01 前言 本次测试仅供学习使用&#xff0c;如若非法他用&#xff0c;与本文作者无关&#xff0c;需自行负责&#xff01;&#xff01;&#xff01; 0x02 漏洞描述 Ruijie Networks RG-BCR860是中国锐捷网络&#xff08;R…

【英文文章总结】数据管理指南系列:渐进式数据库设计

原文连接&#xff1a;系列https://martinfowler.com/data/https://martinfowler.com/data/ Evolutionary Database Design (martinfowler.com) 架构的进化。如何允许更改架构并轻松迁移现有数据&#xff1f; 如何应对项目的变动 迭代开发&#xff1a;很长一段时间人们把数据…

R语言列操作函数

目录 一.dplyr包 1.新增变量和变量重新赋值 2.筛选行 3.筛选列 4.分组计算 5.管道操作符 6.连接数据框 二.tidyr 1.列的分裂 2.列的合并 3.宽数据转长数据 4.长数据转宽数据 一.dplyr包 1.新增变量和变量重新赋值 > head(ToothGrowth)len supp dose 1 4.2 …

如何高效的解析Json?

Json介绍 Json是一种数据格式&#xff0c;广泛应用在需要数据交互的场景Json由键值对组成每一个键值对的key是字符串类型每一个键值对的value是值类型(boo1值数字值字符串值)Array类型object类型Json灵活性他可以不断嵌套&#xff0c;数组的每个元素还可以是数组或者键值对键值…

HDFS 集群动态节点管理

目录 一、动态扩容、节点上线 1.1 背景 1.2 扩容步骤 1.2.1 新机器基础环境准备 1.2.2 Hadoop 配置 1.2.3 手动启动 DataNode 进程 1.2.4 Web 页面查看情况 1.2.5 DataNode 负载均衡服务 二、动态缩容、节点下线 2.1 背景 2.2 缩容步骤 2.2.1 添加退役节点 …

/etc/ssh/sshd_config 配置文件中的 PasswordAuthentication PermitRootLogin 参数作用

1、PasswordAuthentication PasswordAuthentications是一种身份验证方式&#xff0c;通常用于远程服务器的登录。当用户连接到远程服务器并进行身份验证时&#xff0c;服务器会根据 用户名进行验证&#xff0c;如果验证成功允许用户访问服务器。在SSH中&#xff0c;PasswordAut…

补种胡杨树-滑动窗体

标题&#xff1a;补种未成活胡杨 | 时间限制&#xff1a;1秒 | 内存限制&#xff1a;262144K 近些年来&#xff0c;我国防沙治沙取得显著成果。某沙漠新种植N棵胡杨&#xff08;编号1-N&#xff09;&#xff0c;排成一排。一个月后&#xff0c;有M棵胡杨未能成活。 现可补种胡杨…

Dijkstra的算法实现 -- 基于优先级队列

什么是Dijkstra算法&#xff1f; Shortest Path Tree (SPT) 单源最短路径算法 从指定节点出发&#xff0c;到达任何其他节点的距离最短。 和K算法、P算法的区别是&#xff1f; K算法、P算法&#xff0c;这两个算法都是最小生成树算法 Minimal Spanning Tree&#xff08;MST&am…

centos7上hive3.1.3安装及配置

1、安装背景&#xff1b; hive是基于hadoop的数据仓库软件&#xff0c;部署运行在linux系统之上&#xff0c;安装之前必须保证hadoop环境运行正常&#xff0c;hive本身不是分布式软件&#xff0c;它的分布式主要是借助hadoop实现&#xff0c;存储是hdfs&#xff0c;计算是mapr…

笔记本家庭版本win11上win+r,运行cmd默认没有管理员权限,如何调整为有管理员权限的

华为matebookeGo 笔记本之前有段时间不知怎么回事&#xff0c;打开运行框&#xff0c;没有了那一行“使用管理权限创建此任务”&#xff0c;而且cmd也不再是默认的管理员下的&#xff0c;这很不方便,虽然每次winr &#xff0c;输入cmd后可以按ctrlshitenter以管理员权限运行&am…

transformer位置编码最详细的解析

位置编码positional encoding 1. 位置编码是什么&#xff0c;为什么需要它&#xff1f;2. transformer提出的位置编码方法3. 直觉4. 其他细节5. 相对位置6. 常见问题解答 1. 位置编码是什么&#xff0c;为什么需要它&#xff1f; 位置和词语的顺序是任何语言的重要组成部分。它…

STM32f103入门(4)对射式红外传感器计次(外部中断)

中断:在主程序运行过程中&#xff0c;出现了特定的中断触发条件 (中断源)&#xff0c;使得CPU暂停当前正在运行的程序&#xff0c;转而去处理中断程序处理完成后又返回原来被暂停的位置继续运行中断优先级:当有多个中断源同时申请中断时&#xff0c;CPU会根据中断源的轻重缓急进…

useRef 定义的 ref 在控制台可以打印但是页面不生效?

useRef 是一个 React Hook&#xff0c;它能让你引用一个不需要渲染的值。 点击计时器 点击按钮后在控制台可以打印但是页面不生效。 useRef 返回的值在函数组件中不会自动触发重新渲染&#xff0c;所以控制台可以显示变化而按钮上无法显示 ref.current的变化。 import { use…

孙哥Spring源码第14集

第14集 BeanDefintion的创建方式 【视频来源于&#xff1a;B站up主孙帅suns Spring源码视频】 1、注册BeanDefintion的方式如何根据情况进行选择呢&#xff1f; xml 注解 扫描 import 2、为什么没有人用Import 可以通过注解的方式进行对应类型的注册。 3、ImportSelector和…