gRPC load-balancing testing tool
Project description
Nudnik
Goals
Allow easy testing of load-balancing and failures in gRPC and REST based service-mesh
Features
- Rate limiting
- Fake IO load from either client or server side
- Export timing metrics to a file or InfluxDB with any custom formatting
Quick Start
- Install Nudnik:
# Install package
pip install nudnik
- Run example Server:
nudnik --server
- Run a client that identifies itself as
barbaz
, fork to2
threads, each sending5
gRPC messages every3
seconds.
nudnik --name barbaz --streams 2 --interval 3 --rate 5
Docker - Quick Start
- Running on your local/remote docker daemon using docker-compose:
docker-compose up
Under The Hood
The server binds to the host:port that were specified, and listens to incoming gRPC messages. Every message consists of several fields:
- name: The name of the client, arbitrary string
- stream_id: The stream id, the streams are numbered from
0
to whatever was configureed via thestreams
arg. - message_id: At every
interval
, the client sendsrate
messages, this id is an autoincrement index for that message. - ctime: The timestamp at which the request was created
- rtime: The timestamp at which the request was retransmitted (0 if not applicapble)
- rcount: The amount of times this message was retransmitted (0 if not applicapble)
- meta: Just another string field that does nothing, you may send additional arbitrary data to increase message size or specify
random
to generate random data with every request - load: This field may be repeated several times, it instructs the server to create fake load of some sort before replying.
Upon recieveing a message, the server will:
- parse the
load
field - perform the required load
- print a log message using the configured
out_format
- reply an
OK
to the client, also add the fieldptime
, which represents the time at which the request was parsed at the server, this allows the client to calculate exact RTT, even if NTP is not synchronized.
Local Development
As a rule of thumb wed'e recommend using virtualenv. Requirement are Python 3.7 + requirements.txt file
- Clone and initialize Nudnik:
# Install python requirements
pip install grpcio grpcio-tools requests-unixsocket
# Clone and configure the repository
git clone https://github.com/salosh/nudnik.git
git config --global push.default matching
git config --global user.name "Your Name"
git config --global user.email your.email@salosh.org
# "Compile" the entity protobuf
cd nudnik
python -m grpc_tools.protoc --proto_path=./nudnik/ --python_out=./nudnik/ --grpc_python_out=./nudnik/ ./entity.proto
Configure
Configuration documentation
Formatting documentation
Via Nudnik
Command line args:
nudnik -h
usage: nudnik [-h] [--config-file CONFIG_FILE] [--host HOST] [--port PORT]
[--server] [--name NAME]
[--name-mismatch-error {prefix,suffix,exact}] [--meta META]
[--workers WORKERS] [--streams STREAMS]
[--initial-stream-index INITIAL_STREAM_INDEX]
[--interval INTERVAL] [--rate RATE] [--count COUNT]
[--chaos CHAOS] [--load load_type load_value]
[--retry-count RETRY_COUNT] [--fail-ratio FAIL_RATIO] [--ruok]
[--metrics {stdout,file,influxdb,prometheus}]
[--stats {stdout,file,influxdb,prometheus}] [--extra EXTRA]
[--debug] [--verbose] [--version]
Nudnik - gRPC load tester
optional arguments:
-h, --help show this help message and exit
--config-file CONFIG_FILE, -f CONFIG_FILE
Path to YAML config file
--host HOST, -H HOST host
--port PORT, -p PORT port
--server, -S Operation mode (default: client)
--name NAME, -n NAME Parser name
--name-mismatch-error {prefix,suffix,exact}
Fail request on name mismatch (default: None)
--meta META, -M META Send this extra data with every request
--workers WORKERS, -w WORKERS
Number of workers (Default: Count of CPU cores)
--streams STREAMS, -s STREAMS
Number of streams (Default: 1)
--initial-stream-index INITIAL_STREAM_INDEX
Calculate stream ID from this initial index (Default:
0)
--interval INTERVAL, -i INTERVAL
Number of seconds per stream message cycle (Default:
1)
--rate RATE, -r RATE Number of messages per interval (Default: 10)
--count COUNT, -C COUNT
Count of total messages that should be sent (Default:
0 == unlimited)
--chaos CHAOS, -c CHAOS
Compute statistical process level random crashes [0,
3600/interval] (Default: 0)
--load load_type load_value, -l load_type load_value
Add artificial load [rtt, rttr, cpu, mem, cmd, fcmd]
(Default: None)
--retry-count RETRY_COUNT
Number of times to re-send failed messages (Default:
-1, which means infinite times)
--fail-ratio FAIL_RATIO
Percent of requests to intentionally fail (Default: 0)
--ruok, -R Enable "Are You OK?" HTTP/1.1 API (default: False)
--metrics {stdout,file,influxdb,prometheus}, -m {stdout,file,influxdb,prometheus}
Enable metrics outputs (Default: None)
--stats {stdout,file,influxdb,prometheus}, -t {stdout,file,influxdb,prometheus}
Enable stats outputs (Default: None)
--extra EXTRA, -e EXTRA
Extra args (Default: None)
--debug, -d Debug mode (default: False)
--verbose, -v Verbose mode, specify multiple times for extra
verbosity (default: None)
--version, -V Display Nudnik version
2018 (C) Salo Shp <https://github.com/salosh/nudnik.git>
Via config file:
nano ./config.yml
Getting started
Please refer to our examples repository for multiple guides and usage examples
Visit our website at https://salosh.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nudnik-0.0.32.tar.gz
(36.5 kB
view hashes)
Built Distribution
Close
Hashes for nudnik-0.0.32-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28ca37b1eaf77a6e014170d835f048ed32888f917706545f3739b243adbbd5cb |
|
MD5 | 3950ea7ac95888d0b569340a913d04a9 |
|
BLAKE2b-256 | 5f4f484195268f6cebdcff92c2a27b8d760e7f66c16d207d88cfd0a80da04506 |