Skip to content

PtashnikGIT/rtmp_load

 
 

Repository files navigation

rtmp_load — a load testing tool for RTMP servers

About

The tool spawns threads (with scriptable flow) which consume RTMP streams, parse them (only containers), collect some metrics (e.g. frames per second) and sumbit metrics to Mistress stat server for aggregation, storage and visualization.

Rough performance numbers for 10k threads on one host (Xeon E5-2640, Debian 6 3.2.0-0.bpo): 20-50% CPU of each of all cores, 4-6 Gbit network usage (streams had SD-quality), 14GB of RAM.

Setup

Tested on Ubuntu 12 and Debian 6

sudo apt-get install librtmp0 librtmp-dev yasm pkg-config
sudo apt-get install python-virtualenv
cd rtmp_load
virtualenv --no-site-packages venv
source venv/bin/activate
pip install -r requirements.txt
bold

Usage

Test scenarios are Lua scripts. Basically, a script produces settings and passes them to the special function that runs the test.

Copy and edit the test template:

cp test.lua.example your_test.lua

You may configure:

  • rtmp_string - server address
  • is_live - 0 (default) or 1
  • delay_ms - by default random 0-999 - delay before a thread starts

spawn_phases is a list of phase settings. Each of phases is used sequentially to spawn threads. duration is duration of phase in seconds and rate is how many threads are spawned each second.

scenarios is a hash of type "function that produces settings -> weight of choice". Weight is used for weighted random choosing. It isn't in percents but it may be more intuitive to use it as percents, for example:

local scenarios = {
	[scenario1] = 20,
	[scenario2] = 80,
}

Run the test:

./run.py your_test.lua

Design

The design decisions were influenced by tight development time requirements :) There are three layers:

  • The C core that handles RTMP stream with libav/librtmp and OS threads. It collects some metrics and writes it to stdout
  • The Lua/LuaJIT scripting layer that manages threads and configuration
  • The Python wrapper script that launches the core, consumes the metrics from its stdout and pushes them to Mistress stat server

Feedback

Please don't hesitate to submit any feedback to the issue tracker

Development

pip install -r requirements_dev.txt

Updating libav

Remove "version.h" from .gitignore because this file is needed for building

Libav 9.9 works bad - "unknown error" from avformat_open_input, strange timings (lots of frame underruns which doesn't happen on 0.8.8) Though after heap profiling it seems like url_alloc_for_protocol(avformat_open_input) memleaks in 0.8.8 (-- 0.8.9 seems ok?)

License

The MIT License (see license.txt)

About

a load testing tool for RTMP servers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 89.6%
  • Assembly 4.8%
  • C++ 1.9%
  • Lua 1.5%
  • HTML 1.0%
  • Makefile 0.9%
  • Other 0.3%