Skip to main content

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 to 2 threads, each sending 5 gRPC messages every 3 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 the streams arg.
  • message_id: At every interval, the client sends rate 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 field ptime, 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

Metadata

Release files for nudnik 0.0.33

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nudnik 0.0.33
File Size Uploaded
nudnik-0.0.33.tar.gz 36.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nudnik 0.0.33
File Interpreter ABI Platform
nudnik-0.0.33-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 82.2 kB

Release files / nudnik-0.0.33.tar.gz

Download URL nudnik-0.0.33.tar.gz
Size 36.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2a6df7d97c4f32fa5ef063c39d99da5c8ec55c0269668cf30c7addc8b77b8ce8
BLAKE2b-256 checksum
How to use checksums
0a7418f8bbf6c02002b7db94c04a85c2f824a7a291bbeae246ec77ff7caa12ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

Release files / nudnik-0.0.33-py2.py3-none-any.whl

Download URL nudnik-0.0.33-py2.py3-none-any.whl
Size 45.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
72f91e7e0a42329841e9afe0f568ebb3d7fc8d7aa164b14413973c985cb07a14
BLAKE2b-256 checksum
How to use checksums
e2ae01f46c294fa95c7d67dc0eac9e5d5187dacb0a1e6e6961398f53803b365a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.33 This release

2 release files

0.0.32

2 release files

0.0.30

2 release files

0.0.28

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page