This repository contains a Python script to test parallel connections to a Redis server. The script includes functionalities to simulate normal and slow connections, populate the database, and measure performance metrics such as throughput and latency.
- Parallel Connections: Test Redis with multiple concurrent connections.
- Slow Connections: Simulate slow clients using raw sockets.
- Database Population: Populate Redis with keys and a large hash.
- Performance Metrics: Measure throughput and latency.
- Configurable Parameters: Customize test parameters through command-line arguments.
- Python 3.8 or above
redisPython library
Install the required dependencies:
pip3 install redis tqdm| Argument | Description | Default |
|---|---|---|
--host |
Redis host address (required). | N/A |
--port |
Redis port number (required). | N/A |
--data_size |
Size of data in bytes for key population. | 1024 |
--connections |
Number of parallel connections. | 10 |
--slow_connections |
Number of slow connections. | 0 |
--keys_count |
Number of keys to populate during the first stage (required). | N/A |
--skip_population |
Skip the population stage. | False |
--recv_chunk_size_min |
Minimum chunk size for socket recv in bytes. |
32 |
--recv_chunk_size_max |
Maximum chunk size for socket recv in bytes. |
128 |
--recv_sleep_time |
Sleep time between socket recv operations in seconds. |
1.0 |
--hash_fields |
Number of fields in the large hash. | 1000000 |
--hash_field_size |
Size of each field value in the large hash in bytes. | 100 |
Populate the database and test with 10 normal connections and 2 slow connections:
python parallel_redis_connections.py --host 127.0.0.1 --port 6379 --keys_count 1000 --connections 10 --slow_connections 2Skip the population stage:
python parallel_redis_connections.py --host 127.0.0.1 --port 6379 --keys_count 1000 --connections 10 --slow_connections 2 --skip_populationControl slow connection parameters (chunk size range and sleep time):
python parallel_redis_connections.py --host 127.0.0.1 --port 6379 --keys_count 1000 --connections 10 --slow_connections 2 --recv_chunk_size_min 64 --recv_chunk_size_max 256 --recv_sleep_time 0.5Control large hash size:
python parallel_redis_connections.py --host 127.0.0.1 --port 6379 --keys_count 1000 --connections 10 --hash_fields 500000 --hash_field_size 200Best practise for controlling the tool:
python parallel_redis_connections.py --host 127.0.0.1 --port 6379 --connections 100 --keys_count 1000 --data_size 1024 --hash_fields 50000 --hash_field_size 1024 --slow_connections 10 --skip_population --recv_chunk_size_min 2048 --recv_chunk_size_max 8192 --recv_sleep_time 0.01- Populates Redis with the specified number of keys.
- Creates a large hash (
large-hash) with a configurable number of fields and field sizes.
- Simulates slow connections using raw sockets.
- Performs
HGETALLon the large hash and processes the response in small chunks with a configurable delay.
- Multiple threads perform
GEToperations on the populated keys. - Measures throughput
- Throughput: Operations per second.
differentBufferSize.py is a Python script that interacts with a Redis server using both connection pools and sockets. It has two main stages: data population and data fetching.
- Population Stage: Uses a Redis connection pool to populate the database with keys of varying sizes.
- Fetch Stage: Opens parallel socket connections to fetch data from Redis. The fetch process simulates slow reading using delays, with a progress bar displayed via the
tqdmpackage.
python differentBufferSize.py --redis_host <hostname> \
--redis_port <port> \
--num_connections <connections> \
--initial_key_size <size_in_MB> \
--delta <size_in_MB> \
--sleep_time <seconds> \
[--noflush]--redis_host: Redis server hostname.--redis_port: Redis server port.--num_connections: Number of parallel connections to use.--initial_key_size: Initial key size in megabytes.--delta: Incremental increase in key size per connection in megabytes.--sleep_time: Time to sleep (in seconds) between sending commands during the fetch stage.--noflush: Prevents flushing the Redis database before starting.
redissocketargparsetqdm
python3 differentBufferSize.py --redis_host redis-10000.alon-5160.env0.qa.redis.com --redis_port 10000 --num_connections 20 --sleep_time 60 --initial_key_size 10 --delta 5