Locust

用 Python 编写的可伸缩的用户负载测试工具。「Scalable user load testing tool written in Python.」

Github stars Tracking Chart

Locust(刺槐)

链接

简介

Locust 是一个易于使用、分布式的用户负载测试工具。它用于负载测试 web 站点(或其他系统),并计算出一个系统可以处理多少并发用户。

这个想法是,在一次测试中,一群蝗虫会攻击你的网站。每个蝗虫(或测试用户,如果你愿意)的行为是 由您定义和群集进程实时监控从Web UI。这将有助于你进行战斗测试和识别瓶颈 在让真正的用户进入之前在你的代码中。

其思想是在测试期间,一群模拟用户将攻击您的网站。每个用户的行为是由您使用 Python 代码定义的,而集群过程是由 web UI 实时监控的。这将帮助您在让真正的用户进入之前进行测试并识别代码中的瓶颈。

Locust 完全是基于事件的,因此在一台机器上支持数千个并发用户是可能的。与许多其他基于事件的应用程序不同,它不使用回调。相反,它通过 gevent 使用轻量级进程。每个聚集在你的站点上的 locust 实际上是在它自己的进程中运行的(或者说是 greenlet)。这允许您用 Python 编写非常有表现力的场景,而不用回调使代码复杂化。

特性

  • 用普通的 Python 编写用户测试场景
    不需要像通常那样使用笨拙的 ui 或臃肿的 XML 代码。基于协程而不是回调,您的代码的外观和行为类似于正常的代码,会阻塞Python代码。
  • 分布式、可扩展 —— 支持数十万用户
    Locust 支持在多台机器上运行负载测试。由于基于事件,即使一个 Locust 节点也可以在一个进程中处理数千个用户。这背后的部分原因是,即使您模拟了那么多用户,也不是所有用户都在主动地攻击您的系统。通常,用户都在无所事事地考虑下一步该做什么。每秒请求数 != 在线用户数量。
  • 基于 Web 的用户界面
    Locust 有一个整洁的 HTML+JS,实时显示所有相关的测试细节。由于 UI 是基于 web 的,所以它是跨平台的,并且易于扩展。
  • 可以测试任何系统
    Even though Locust is web-oriented, it can be used to test almost any system. Just write a client for what ever you wish to test and swarm it with users! It's super easy! 尽管 Locust 是面向 web 的,但它几乎可以用于测试任何系统。只要编写一个客户端,就可以测试你想要测试的东西,并将其与用户一起使用!这超级简单!
  • 可控制(Hackable)
    Locust 非常小,非常容易被攻击,我们打算让它保持这种状态。所有重大的事件 IO 和协程委托给 gevent。替代测试工具的脆弱性是我们创建 Locust 的原因。

文档

可以在以下位置找到更多信息和文档:http://docs.locust.io/

问题/帮助?

有关如何使用 Locust 的问题,请随时在 Slack 旁边停下来,或在 Stack Overflow 标签为 Locust 的地方提出问题。

错误报告或功能请求

打开 Github 问题,并按照此处列出的模板进行操作。

作者

许可证

根据 MIT 许可开放源代码(详情请参阅LICENSE文件)。

支持的Python版本

Locust 支持 Python 2.7,3.3,3.4,3.5 和 3.6。

(First edition: vz edited at 2020.04.28)

Overview

Name With Ownerlocustio/locust
Primary LanguagePython
Program languageMakefile (Language Count: 5)
PlatformLinux, Mac, Windows
License:MIT License
Release Count129
Last Release Name2.27.0 (Posted on )
First Release Namev0.4 (Posted on 2011-12-05 14:27:34)
Created At2011-02-17 11:08:03
Pushed At2024-05-13 15:29:32
Last Commit At2024-05-13 17:29:32
Stargazers Count23.8k
Watchers Count430
Fork Count2.9k
Commits Count4.8k
Has Issues Enabled
Issues Count1614
Issue Open Count27
Pull Requests Count800
Pull Requests Open Count1
Pull Requests Close Count288
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Locust

Build Status
codecov
license
PyPI
PyPI
GitHub contributors

  • Website: locust.io
  • Documentation: docs.locust.io
  • Support/Questions: Slack signup

Description

Locust is an easy-to-use, distributed, user load testing tool. It is intended for load-testing web sites (or other systems) and
figuring out how many concurrent users a system can handle.

The idea is that during a test, a swarm of locusts will attack your website. The behavior of each locust (or test user if you will) is
defined by you and the swarming process is monitored from a web UI in real-time. This will help you battle test and identify bottlenecks
in your code before letting real users in.

Locust is completely event-based, and therefore it's possible to support thousands of concurrent users on a single machine.
In contrast to many other event-based apps it doesn't use callbacks. Instead it uses light-weight processes, through gevent.
Each locust swarming your site is actually running inside its own process (or greenlet, to be correct).
This allows you to write very expressive scenarios in Python without complicating your code with callbacks.

Features

  • Write user test scenarios in plain-old Python
    No need for clunky UIs or bloated XML—just code as you normally would. Based on coroutines instead
    of callbacks, your code looks and behaves like normal, blocking Python code.

  • Distributed & Scalable - supports hundreds of thousands of users
    Locust supports running load tests distributed over multiple machines.
    Being event-based, even one Locust node can handle thousands of users in a single process.
    Part of the reason behind this is that even if you simulate that many users, not all are actively hitting your system. Often, users are idle figuring out what to do next. Requests per second != number of users online.

  • Web-based UI
    Locust has a neat HTML+JS that shows all relevant test details in real-time. And since the UI is web-based, it's cross-platform and easily extendable.

  • Can test any system
    Even though Locust is web-oriented, it can be used to test almost any system. Just write a client for what ever you wish to test and swarm it with locusts! It's super easy!

  • Hackable
    Locust is very small and very hackable and we intend to keep it that way. All heavy-lifting of evented I/O and coroutines are delegated to gevent. The brittleness of alternative testing tools was the reason we created Locust.

Documentation

More info and documentation can be found at: https://docs.locust.io/

Questions/help?

For questions about how to use Locust, feel free to stop by the Slack or ask questions on Stack Overflow tagged Locust.

Bug reporting

Open a Github issue and follow the template listed there.

Authors

  • Carl Byström (@cgbystrom on Twitter)
  • Jonatan Heyman (@jonatanheyman on Twitter)
  • Joakim Hamrén (@Jahaaja)
  • Hugo Heyman (@hugoheyman)

License

Open source licensed under the MIT license (see LICENSE file for details).

Supported Python Versions

Locust is supported on Python 3.6, 3.7, 3.8.

To the top