# 服务网格

服务网格（service mesh）是一层基础设施，负责管理、保护并观测分布式应用中各服务之间的通信，通常的做法是让流量经由代理转发，这样应用代码本身就不必实现这些功能。<sup>[1](https://docs.cloud.google.com/service-mesh/docs/overview)</sup> 从架构上看，服务网格由一个或多个控制平面（control plane）和一个数据平面（data plane）组成：控制平面负责配置行为，数据平面负责转发流量；在 [Kubernetes](https://www.edgepedia.org/zh/kubernetes) 上，数据平面最常见的部署方式是为每个微服务配一个边车代理（sidecar proxy）。<sup>[1](https://docs.cloud.google.com/service-mesh/docs/overview)</sup>

| 关键事实 | 详情 |
|---|---|
| 核心功能 | 流量管理（负载均衡、重试、熔断、金丝雀路由）、安全（双向 TLS、认证、授权）与可观测性（指标、追踪）<sup>[1](https://docs.cloud.google.com/service-mesh/docs/overview)</sup><sup> • </sup><sup>[2](https://www.durrellgemuh.com/blog/kubernetes-service-mesh-comparison-istio-linkerd-consul/)</sup> |
| 架构 | 控制平面管理由代理构成的数据平面；边车模式在每个 Pod 中放置一个代理容器，将网络功能与应用逻辑解耦<sup>[1](https://docs.cloud.google.com/service-mesh/docs/overview)</sup> |
| 主流项目 | Istio（Envoy 边车）、Linkerd（Rust 微代理）、Consul Connect（HashiCorp）以及基于 eBPF 的 Cilium<sup>[3](https://techprephq.com/question/devops/networking/compare-istio-linkerd-consul-connect-cilium-service-mesh-across-proxy)</sup> |
| 延迟开销 | 在 CNCF 于 2,000 RPS 下进行的基准测试中，Linkerd 在 6 毫秒基线之上增加了 9 毫秒中位延迟，Istio 则增加了 15 毫秒；在最大值上，Linkerd 增加了 47 毫秒，Istio 约为 253 毫秒<sup>[4](https://www.cncf.io/blog/2021/05/28/benchmarking-linkerd-and-istio/)</sup> |
| 实测开销范围 | 学术测量发现，基准应用在特定配置与负载下，延迟最高增加 185%，虚拟 CPU 核数最多增加 92%<sup>[5](https://arxiv.org/abs/2207.00592)</sup> |
| 采用趋势 | CNCF 调查显示，2023 年有 50% 的组织将服务网格用于少数或多数应用的生产环境，2024 年约为 42%，而“近期无使用计划”的比例从 16% 升至 31%<sup>[6](https://www.cncf.io/wp-content/uploads/2025/04/cncf_annual_survey24_031225a.pdf)</sup> |
| 无边车方向 | Istio 的环境模式以每节点 ztunnel 代理取代每 Pod 边车，并可选配基于 Envoy 的航点代理以提供七层功能；该模式在 Istio 1.24 中晋升为 Stable<sup>[7](https://istio.io/latest/docs/ambient/overview/)</sup> |

## 服务网格的作用

随着应用被拆分为众多微服务，同样的连通性问题在各个团队中反复出现：保障服务间调用的安全、识别工作负载、控制哪个服务可以访问另一个服务，以及理解发布过程中的故障。若在每个应用中各自实现这些行为，就会导致策略不一致并带来额外的维护负担。服务网格将选定的通信控制移入一个专门的基础设施层。<sup>[8](https://stackbriefly.com/blog/service-mesh-platforms-2026-istio-linkerd-consul-kuma-cilium)</sup>

具体而言，服务网格负责流量管理（如负载均衡、重试、超时与熔断）、安全（如双向 TLS 加密与授权）以及可观测性（如指标与分布式追踪）。<sup>[2](https://www.durrellgemuh.com/blog/kubernetes-service-mesh-comparison-istio-linkerd-consul/)</sup> 谷歌的文档将目标描述为：让服务间的通信可管理、可观测且安全，使开发者能专注于应用功能，而运维团队则用一致的工具管理网络与安全，且无需改动应用代码。<sup>[1](https://docs.cloud.google.com/service-mesh/docs/overview)</sup>

## 架构：控制平面与数据平面

每个主流服务网格都将控制平面与数据平面分离：控制平面在集群层面管理数据的流动方式，数据平面则是负责在服务之间转发流量的进程。<sup>[9](https://logz.io/blog/istio-linkerd-consul-comparison-service-meshes/)</sup> 在常见的边车模式中，一个代理容器运行在每个 Pod 内部，负责接收来自应用的数据、向应用发送数据，并处理流量向其他 Pod 或集群外部的流转。<sup>[9](https://logz.io/blog/istio-linkerd-consul-comparison-service-meshes/)</sup> 这些代理构成数据平面，并由控制平面作为一个整体加以控制。<sup>[10](https://linkerd.io/what-is-a-service-mesh/)</sup>

边车模式是有代价的。2022 年一项使用 MeshInsight 工具的学术研究证实，服务网格可能带来很高的开销：对基准应用而言，延迟最高增加 185%，虚拟 CPU 核数最多增加 92%，其严重程度与配置和工作负载密切相关。当网格以 TCP 代理方式运行时，开销主要来自进程间通信与套接字写入；当它以 HTTP 代理方式运行时，开销主要来自协议解析。<sup>[5](https://arxiv.org/abs/2207.00592)</sup>

## 起源

服务网格模式源于大规模服务端应用的演进历程。在 2000 年代，典型的 Web 应用采用三层架构，层与层之间的通信有限。当规模变得极大时，谷歌、奈飞、推特等公司将应用拆分为微服务，并用推特的 Finagle、奈飞的 Hystrix、谷歌的 Stubby 等库来解决通信复杂性。后来，容器与 Kubernetes 等编排器使这些功能可以在运行时以网络代理的形式绑定，而非在编译时以库的形式绑定，从而将平台功能与应用解耦。<sup>[10](https://linkerd.io/what-is-a-service-mesh/)</sup>

Linkerd 是第一个服务网格项目，于 2017 年初加入云原生计算基金会（CNCF），并在 2018 年重写为使用 Rust 微代理；2018 年 9 月，它与 Conduit 项目合并，形成 Linkerd 2.0。<sup>[10](https://linkerd.io/what-is-a-service-mesh/)</sup><sup> • </sup><sup>[9](https://logz.io/blog/istio-linkerd-consul-comparison-service-meshes/)</sup> Istio 由谷歌、IBM 和 Lyft 于 2017 年 5 月开源，使用 Lyft 最初开发的代理 Envoy 作为其数据平面。<sup>[9](https://logz.io/blog/istio-linkerd-consul-comparison-service-meshes/)</sup><sup> • </sup><sup>[11](https://mcislab.github.io/publications/2023/emse_yihao.pdf)</sup> HashiCorp 的 Consul 始于 2014 年，最初是一个服务通信框架，其服务网格组件于 2017 年底定义。<sup>[11](https://mcislab.github.io/publications/2023/emse_yihao.pdf)</sup>

## 主要实现

**Istio** 使用 Envoy（C++）边车，提供完整的七层策略、双向 TLS 与流量管理；在广泛比较的各家网格中，它功能最丰富，资源消耗也最大。<sup>[3](https://techprephq.com/question/devops/networking/compare-istio-linkerd-consul-connect-cilium-service-mesh-across-proxy)</sup> 其控制平面组件 istiod 负责管理配置、证书签发与服务发现。<sup>[12](https://codelit.io/blog/kubernetes-service-mesh-comparison)</sup> Istio 于 2023 年 7 月从 CNCF 毕业。<sup>[13](https://istio.io/latest/blog/2025/roadmap/)</sup>

**Linkerd** 使用 Rust 代理（linkerd2-proxy），常驻内存集（RSS）仅约 10 MB，通过透明代理保留源 IP，并侧重四层、追求简洁；它通常是各网格中最易运维的。<sup>[3](https://techprephq.com/question/devops/networking/compare-istio-linkerd-consul-connect-cilium-service-mesh-across-proxy)</sup> 2021 年，它成为唯一一个获得 CNCF 毕业资格的服务网格。<sup>[10](https://linkerd.io/what-is-a-service-mesh/)</sup>

**Consul Connect** 与 HashiCorp Consul 集成以实现服务注册表，可运行于边车或透明代理模式，并使用 Envoy 作为其代理。<sup>[3](https://techprephq.com/question/devops/networking/compare-istio-linkerd-consul-connect-cilium-service-mesh-across-proxy)</sup> 其控制平面以节点代理的形式运行在每个节点上；这种分布式架构由每台主机本地的代理管理流量，因而其性能可能更接近 Linkerd 而非 Istio。<sup>[9](https://logz.io/blog/istio-linkerd-consul-comparison-service-meshes/)</sup>

**Cilium** 采用 eBPF 原生方案，三层/四层处理无需边车，仅在七层使用 Envoy；它在四层策略上性能强劲。<sup>[3](https://techprephq.com/question/devops/networking/compare-istio-linkerd-consul-connect-cilium-service-mesh-across-proxy)</sup>

## 性能

各项基准测试一致表明，开销可测量但幅度不定。在 CNCF 发布的一项基准测试中，测试在启用双向 TLS 的情况下分别以每秒 20、200 和 2,000 次请求运行：在 2,000 RPS 下，Linkerd 的中位延迟为 15 毫秒，基线为 6 毫秒（增加 9 毫秒），Istio 则为 21 毫秒（增加 15 毫秒）；在最大值上，Linkerd 在 25 毫秒基线之上增加了 47 毫秒，Istio 则增加了约 253 毫秒。从所报告的各个百分位数来看，Istio 引入的额外延迟比 Linkerd 多 40% 至 400%。<sup>[4](https://www.cncf.io/blog/2021/05/28/benchmarking-linkerd-and-istio/)</sup> 后来的一项对比报告称，在 2,000 RPS 下，Istio 相较于无网格的 Kubernetes 环境增加了约 15 毫秒的中位延迟；Linkerd 的 P50 为 16.5 毫秒、P99 为 38.5 毫秒，Istio 则为 18.5 毫秒和 45.5 毫秒；代理内存方面，Linkerd 约为 26 MB，Istio 最高达 150 MB。<sup>[14](https://www.hokstadconsulting.com/blog/latency-benchmarks-istio-linkerd-consul)</sup>

2024 年一项针对双向 TLS 测试用例的学术研究发现，Istio、Istio Ambient、Linkerd 和 Cilium 在延迟与内存上存在显著性能差异，根源在于边车与无边车架构之别，以及 mTLS 实现中隐藏的默认功能。<sup>[15](https://arxiv.org/abs/2411.02267)</sup>

## 采用情况与去边车化趋势

CNCF 于 2021 年底对 253 名社区成员进行的一项微型调查发现，70% 的受访者在生产或开发环境中运行服务网格，19% 正在评估；Linkerd 和 Istio 领先，分别有 72% 和 34% 的受访者正在使用或计划使用。主要的采用障碍是工程专业人才短缺（47%）、架构与技术复杂性（41%）以及缺乏指导与最佳实践（36%）。<sup>[16](https://www.cncf.io/blog/2022/05/17/service-meshes-are-on-the-rise-but-greater-understanding-and-experience-are-required/)</sup> 在 2020 年 CNCF 的调查中，生产环境用户里有 47% 使用 Istio，其次是 Linkerd 和 Consul，各占 41%。<sup>[17](https://www.cncf.io/wp-content/uploads/2020/12/CNCF_Survey_Report_2020.pdf)</sup>

此后，兴趣有所降温。CNCF 2024 年度调查显示，约 42% 的受访组织将服务网格用于少数或多数应用的生产环境，低于 2023 年的 50%；计划试用的公司数量同比减半，而“近期无使用计划”的比例从 16% 翻倍至 31%。调查将此归因于对复杂性、成本与性能的担忧，并指出服务网格需要专业知识，可能引发延迟与吞吐量问题，而更轻量的 Kubernetes 原生方案已经出现。<sup>[6](https://www.cncf.io/wp-content/uploads/2025/04/cncf_annual_survey24_031225a.pdf)</sup>

主要的架构应对是无边车模式。Istio 的环境模式将数据平面拆分为两部分：一是用 Rust 编写的每节点 ztunnel 代理，通过一种名为 HBONE 的、基于 HTTP CONNECT 的[隧道协议](https://www.edgepedia.org/zh/tunneling-protocol)处理三层/四层功能，如双向 TLS、认证、四层授权与遥测；二是可选的基于 Envoy 的航点代理，在需要时提供七层流量管理——这一切都无需修改应用 Pod。<sup>[7](https://istio.io/latest/docs/ambient/overview/)</sup> 环境模式在 Istio 1.24 中晋升为 Stable。<sup>[13](https://istio.io/latest/blog/2025/roadmap/)</sup>

## References

1. [Cloud Service Mesh overview, Google Cloud Documentation](https://docs.cloud.google.com/service-mesh/docs/overview)
2. [Kubernetes Service Mesh: Istio vs Linkerd vs Consul, Durrell Gemuh](https://www.durrellgemuh.com/blog/kubernetes-service-mesh-comparison-istio-linkerd-consul/)
3. [Compare Istio, Linkerd, Consul Connect, and Cilium Service Mesh, TechPrep](https://techprephq.com/question/devops/networking/compare-istio-linkerd-consul-connect-cilium-service-mesh-across-proxy)
4. [Benchmarking Linkerd and Istio, CNCF Blog (2021)](https://www.cncf.io/blog/2021/05/28/benchmarking-linkerd-and-istio/)
5. [Dissecting Service Mesh Overheads (MeshInsight), arXiv:2207.00592](https://arxiv.org/abs/2207.00592)
6. [The Technology Roadmap Snapshot, CNCF Annual Survey 2024](https://www.cncf.io/wp-content/uploads/2025/04/cncf_annual_survey24_031225a.pdf)
7. [Istio Ambient Mode Overview, Istio Documentation](https://istio.io/latest/docs/ambient/overview/)
8. [Service Mesh Platforms in 2026, StackBriefly](https://stackbriefly.com/blog/service-mesh-platforms-2026-istio-linkerd-consul-kuma-cilium)
9. [Istio vs. Linkerd vs. Consul: A Comparison of Service Meshes, Logz.io](https://logz.io/blog/istio-linkerd-consul-comparison-service-meshes/)
10. [What is a service mesh?, Linkerd](https://linkerd.io/what-is-a-service-mesh/)
11. [On Practitioners' Concerns when Adopting Service Mesh Frameworks, mcislab](https://mcislab.github.io/publications/2023/emse_yihao.pdf)
12. [Service Mesh 2026: Istio vs Linkerd vs Consul vs Cilium, Codelit](https://codelit.io/blog/kubernetes-service-mesh-comparison)
13. [Istio Roadmap for 2025-2026, Istio Blog](https://istio.io/latest/blog/2025/roadmap/)
14. [Latency Benchmarks: Istio, Linkerd, Consul, Hokstad Consulting](https://www.hokstadconsulting.com/blog/latency-benchmarks-istio-linkerd-consul)
15. [Performance Comparison of Service Mesh Frameworks: the MTLS Test Case, arXiv:2411.02267](https://arxiv.org/abs/2411.02267)
16. [Service meshes are on the rise, CNCF Blog (2022)](https://www.cncf.io/blog/2022/05/17/service-meshes-are-on-the-rise-but-greater-understanding-and-experience-are-required/)
17. [CNCF Survey Report 2020](https://www.cncf.io/wp-content/uploads/2020/12/CNCF_Survey_Report_2020.pdf)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Software engineering and development process › Software design and architecture › Titles Mu to Z

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/service-mesh

English original: https://www.edgepedia.org/service-mesh
