# Gatling（软件）

**Gatling** 是一款开源负载测试工具，测试场景（称为模拟）以代码形式编写，针对目标服务运行，并以 HTML 报告的形式汇总响应时间、吞吐量和错误。<sup>[1](https://github.com/gatling/gatling)</sup> 它由 Gatling Corp 联合创始人兼首席技术官斯特凡·朗代尔（Stéphane Landelle）于 2011 年作为开源项目创建，以免费的 Apache 2.0 社区版发行，同时提供 2017 年推出的商业企业版。<sup>[2](https://gatling.io/about)</sup><sup> • </sup><sup>[3](https://www.lemagit.fr/actualites/366565600/Tests-de-charge-le-Francais-Gatling-Corp-veut-monter-en-puissance)</sup>

| 关键事实 | 详情 |
|---|---|
| 首次发布 | 开源项目始于 2011 年；一份简介将朗代尔开发该框架的时间定为 2012 年<sup>[2](https://gatling.io/about)</sup><sup> • </sup><sup>[3](https://www.lemagit.fr/actualites/366565600/Tests-de-charge-le-Francais-Gatling-Corp-veut-monter-en-puissance)</sup> |
| 许可证 | 社区版采用 Apache 2.0，可免费使用（包括商业用途）；gRPC、MQTT 和 GraphQL 组件采用 Gatling 企业版组件许可证<sup>[1](https://github.com/gatling/gatling)</sup> |
| 语言 | JVM 上的 Java、Kotlin 和 Scala；通过独立 SDK 支持 JavaScript 和 TypeScript<sup>[1](https://github.com/gatling/gatling)</sup> |
| 引擎 | 虚拟用户是构建于 Netty 之上的非阻塞引擎中的轻量级消息，而非操作系统线程<sup>[1](https://github.com/gatling/gatling)</sup> |
| 协议（Apache 2.0） | HTTP/1.1、HTTP/2、WebSocket、服务器发送事件和 JMS<sup>[1](https://github.com/gatling/gatling)</sup> |
| 构建集成 | Maven、Gradle、sbt 和 npm 插件；可在本地或 CI 中运行，并支持在突破阈值时使构建失败的断言<sup>[1](https://github.com/gatling/gatling)</sup> |
| 企业版规模 | 每个负载生成器的理论上限为 35,000 至 40,000 个虚拟用户，或每秒 300,000 个请求，具体取决于场景<sup>[4](https://docs.gatling.io/guides/analysis/enterprise-reports/)</sup> |

## 测试即代码模型

Gatling 模拟是开发者代码仓库中的代码，使用 Java、Kotlin、Scala、JavaScript 或 [TypeScript](https://www.edgepedia.org/zh/typescript) 的流畅 DSL 编写。该项目以此区别于将测试存储在专有 XML 格式中的 GUI 驱动工具：测试产生可读的差异，与应用代码一样经过拉取请求审查，并通过 Maven、Gradle、sbt 或 npm 插件在团队已有的任何 CI 系统中运行。<sup>[1](https://github.com/gatling/gatling)</sup> 录制器可将浏览器会话或 HAR 文件转换为模拟，供给器从 CSV、JSON 或数据库提供测试数据；检查器验证状态码、响应体、标头和计时。<sup>[1](https://github.com/gatling/gatling)</sup> 企业版增加了无代码 GUI 构建器，以及直接从 Git 中的源构建模拟的能力。<sup>[5](https://docs.gatling.io/)</sup>

每次运行都会生成 HTML 报告，包含百分位数、随时间变化的吞吐量以及每个请求的错误，当突破阈值时断言可使构建失败，团队借此在流水线中执行性能门禁。<sup>[1](https://github.com/gatling/gatling)</sup>

## 引擎与工作负载模型

Gatling 的决定性设计选择是其并发模型。虚拟用户是构建于 [Netty](https://www.edgepedia.org/zh/netty) 网络框架之上的非阻塞引擎中调度的轻量级消息，而非每个用户一个操作系统线程；该项目认为，基于每用户一线程模型的工具需要一组负载生成器才能达到相同的负载。<sup>[1](https://github.com/gatling/gatling)</sup> 朗代尔花费大量精力优化该框架，使其能在几台服务器甚至单台计算机上运行。<sup>[3](https://www.lemagit.fr/actualites/366565600/Tests-de-charge-le-Francais-Gatling-Corp-veut-monter-en-puissance)</sup>

Gatling 同时支持开放和封闭工作负载模型，并提供注入辅助方法（如 `incrementUsersPerSec`）来构建爬坡配置；在分布式企业版测试中，注入配置默认分布到所有负载生成器上。<sup>[6](https://docs.gatling.io/concepts/injection/)</sup>

## 协议与许可边界

社区版以 Apache 2.0 提供 HTTP/1.1、HTTP/2、WebSocket、服务器发送事件和 JMS，无任何限制。三个协议组件——gRPC、MQTT 和 GraphQL——则采用 Gatling 企业版组件许可证分发；在社区版中，它们被限制为 5 个并发用户和 5 分钟测试，且 GraphQL 仅在 JVM SDK 中可用。Kafka、AMQP、SFTP、FTP 和 JDBC 由第三方社区插件覆盖，而非 Gatling 本身。<sup>[1](https://github.com/gatling/gatling)</sup>

## 社区版与企业版

随着项目发展，Gatling 企业版于 2017 年推出，是构建于同一引擎之上的商业平台。它增加了在 AWS、Azure、GCP 或 [Kubernetes](https://www.edgepedia.org/zh/kubernetes) 上的托管或私有负载生成、实时仪表板、趋势分析、SLO 监控、AI 辅助运行摘要、基于角色的访问控制、SSO，以及与 [GitHub Actions](https://www.edgepedia.org/zh/github-actions)、GitLab CI、Jenkins、Datadog、Dynatrace、OpenTelemetry、Slack、Teams 和 Jira 的集成。<sup>[2](https://gatling.io/about)</sup><sup> • </sup><sup>[1](https://github.com/gatling/gatling)</sup><sup> • </sup><sup>[5](https://docs.gatling.io/)</sup> 官方 GitHub Action `gatling/enterprise-action@v1` 可在企业版基础设施上触发测试。<sup>[7](https://www.vervali.com/blog/jmeter-vs-gatling-vs-k6-the-complete-2026-comparison-benchmarks-ci-cd-scripting-and-use-cases/)</sup>

关于容量，Gatling 自身的指导是：理论极限为单个负载生成器 35,000 至 40,000 个虚拟用户，或每秒 300,000 个请求，但实际数字取决于场景的请求和 API 调用；企业版负载生成器选项卡显示测试消耗了生成器容量的多少。<sup>[4](https://docs.gatling.io/guides/analysis/enterprise-reports/)</sup>

## 对比

Gatling 最常与 [Apache JMeter](https://www.edgepedia.org/zh/apache-jmeter) 和 k6 进行比较。在 Abstracta 的一项基准测试中，除工具外其他条件保持不变，使用 Gatling 2.2.2 与 JMeter 3.0 进行 5 分钟恒定负载测试，两种工具达到相似的最大负载，但 JMeter 需要操作系统级调优才能达到相同的并发用户数（Windows 临时端口耗尽在 400 用户时导致连接错误），且多使用约 30% 的内存——接近 6 GB，而 Gatling 略高于 4 GB——作者将此差异归因于 JMeter 每个虚拟用户的线程数更多。<sup>[8](https://abstracta.us/blog/performance-testing/gatling-vs-jmeter-findings)</sup> 评论者一致从范围而非原始速度的角度描述权衡：JMeter 覆盖更广泛的企业协议（如 JDBC、JMS、FTP 和 LDAP）并提供 GUI，而 Gatling 的代码优先脚本适合代码审查和 CI 流水线，其异步引擎提供高虚拟用户密度。<sup>[9](https://softwaretestpilot.com/compare/jmeter-vs-k6-vs-gatling)</sup><sup> • </sup><sup>[10](https://totalshiftleft.ai/blog/k6-vs-jmeter-vs-gatling)</sup> 一项关于网页游戏工作负载的韩国研究发现，工具优势因工作负载类型而异：k6 在写入密集型场景中表现最佳，JMeter 在读取导向任务中最佳，而 Gatling 在混合工作负载中表现出高效的内存使用。<sup>[11](https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART003269595)</sup>

## 采用情况

GitHub 仓库约有 7,000 个星标和 1,200 个复刻。<sup>[1](https://github.com/gatling/gatling)</sup> Gatling Corp 表示该平台被超过 300,000 个组织使用，其下载页面声称超过 30,000,000 名开发者使用过该开源工具。<sup>[2](https://gatling.io/about)</sup><sup> • </sup><sup>[12](https://gatling.io/download-gatling-community-edition)</sup> 在大多数当前的负载测试工具格局调查中，它与 JMeter、k6、Locust 和 LoadRunner 一同出现。<sup>[13](https://www.ciopages.com/buyer-guides/application-performance-testing)</sup>

## References

1. [gatling/gatling: Modern Load Testing as Code, GitHub README](https://github.com/gatling/gatling)
2. [About Gatling, Gatling Corp](https://gatling.io/about)
3. [Tests de charge : le Français Gatling Corp prépare sa montée en puissance, LeMagIT](https://www.lemagit.fr/actualites/366565600/Tests-de-charge-le-Francais-Gatling-Corp-veut-monter-en-puissance)
4. [Understanding load tests with Gatling Enterprise Edition's advanced reporting features, Gatling documentation](https://docs.gatling.io/guides/analysis/enterprise-reports/)
5. [Gatling documentation](https://docs.gatling.io/)
6. [Gatling injection scripting reference, Gatling documentation](https://docs.gatling.io/concepts/injection/)
7. [JMeter vs Gatling vs k6 Comparison 2026, Vervali](https://www.vervali.com/blog/jmeter-vs-gatling-vs-k6-the-complete-2026-comparison-benchmarks-ci-cd-scripting-and-use-cases/)
8. [Open Source Gatling vs JMeter: Our Findings, Abstracta](https://abstracta.us/blog/performance-testing/gatling-vs-jmeter-findings)
9. [JMeter vs k6 vs Gatling (2026): Load Testing Tool Comparison, Software Test Pilot](https://softwaretestpilot.com/compare/jmeter-vs-k6-vs-gatling)
10. [k6 vs JMeter vs Gatling: Which Load Testing Tool (2026), TotalShiftLeft](https://totalshiftleft.ai/blog/k6-vs-jmeter-vs-gatling)
11. [웹게임의 기능 특성을 고려한 부하 테스트 도구의 성능 및 자원 효율성 비교 분석, KCI](https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART003269595)
12. [Download Gatling Community Edition, Gatling Corp](https://gatling.io/download-gatling-community-edition)
13. [Buyer's Guide: Application Performance & Load Testing, CIOPages](https://www.ciopages.com/buyer-guides/application-performance-testing)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Named software products and platforms › Software testing frameworks

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/gatling-software

English original: https://www.edgepedia.org/gatling-software
