|
| 1 | +# DB-ESDK Performance Benchmark - Python |
| 2 | + |
| 3 | +This directory contains the Python implementation of the AWS Database Encryption SDK (DB-ESDK) performance benchmark suite. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The Python benchmark provides comprehensive performance testing for the DB-ESDK Python runtime, measuring: |
| 8 | + |
| 9 | +- **Throughput**: Operations per second and bytes per second using ItemEncryptor operations |
| 10 | +- **Latency**: Encrypt, decrypt, and end-to-end timing for encrypted operations |
| 11 | +- **Memory Usage**: Peak memory consumption and efficiency |
| 12 | +- **Concurrency**: Multi-threaded performance scaling |
| 13 | +- **Statistical Analysis**: P50, P95, P99 latency percentiles |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +- Python 3.11 or higher |
| 18 | +- Poetry package manager |
| 19 | + |
| 20 | +## Setup |
| 21 | + |
| 22 | +### Install Poetry |
| 23 | + |
| 24 | +```bash |
| 25 | +# Install Poetry (if not already installed) |
| 26 | +curl -sSL https://install.python-poetry.org | python3 - |
| 27 | + |
| 28 | +# Or using pip |
| 29 | +pip install poetry |
| 30 | +``` |
| 31 | + |
| 32 | +### Install Dependencies |
| 33 | + |
| 34 | +```bash |
| 35 | +# Install all dependencies including dev dependencies |
| 36 | +poetry install |
| 37 | + |
| 38 | +# Install only production dependencies |
| 39 | +poetry install --no-dev |
| 40 | +``` |
| 41 | + |
| 42 | +## Running Benchmarks |
| 43 | + |
| 44 | +### Quick Test |
| 45 | + |
| 46 | +```bash |
| 47 | +# Using Poetry |
| 48 | +poetry run esdk-benchmark --quick |
| 49 | + |
| 50 | +# Using tox (recommended for isolated environment) |
| 51 | +tox -e benchmark |
| 52 | + |
| 53 | +# Using module execution |
| 54 | +poetry run python -m esdk_benchmark --quick |
| 55 | + |
| 56 | +# Direct script execution |
| 57 | +poetry run python src/esdk_benchmark/program.py --quick |
| 58 | +``` |
| 59 | + |
| 60 | +### Full Benchmark Suite |
| 61 | + |
| 62 | +```bash |
| 63 | +# Using Poetry |
| 64 | +poetry run esdk-benchmark |
| 65 | + |
| 66 | +# Using tox (recommended for isolated environment) |
| 67 | +tox -e benchmark-full |
| 68 | + |
| 69 | +# Using module execution |
| 70 | +poetry run python -m esdk_benchmark |
| 71 | + |
| 72 | +# Direct script execution |
| 73 | +poetry run python src/esdk_benchmark/program.py |
| 74 | +``` |
| 75 | + |
| 76 | +### Custom Configuration |
| 77 | + |
| 78 | +```bash |
| 79 | +# Specify custom config and output paths |
| 80 | +poetry run esdk-benchmark \ |
| 81 | + --config /path/to/config.yaml \ |
| 82 | + --output /path/to/results.json |
| 83 | +``` |
| 84 | + |
| 85 | +## Command Line Options |
| 86 | + |
| 87 | +- `--config, -c`: Path to test configuration file (default: `../../../config/test-scenarios.yaml`) |
| 88 | +- `--output, -o`: Path to output results file (default: `../../../results/raw-data/python_results.json`) |
| 89 | +- `--quick, -q`: Run quick test with reduced iterations |
| 90 | +- `--help, -h`: Show help message |
| 91 | + |
| 92 | +## Configuration |
| 93 | + |
| 94 | +The benchmark uses a YAML configuration file to define test parameters: |
| 95 | + |
| 96 | +```yaml |
| 97 | +data_sizes: |
| 98 | + small: [1024, 5120, 10240] |
| 99 | + medium: [102400, 512000, 1048576] |
| 100 | + large: [10485760, 52428800, 104857600] |
| 101 | + |
| 102 | +iterations: |
| 103 | + warmup: 5 |
| 104 | + measurement: 10 |
| 105 | + |
| 106 | +concurrency_levels: [1, 2, 4, 8] |
| 107 | +``` |
| 108 | +
|
| 109 | +## Output Format |
| 110 | +
|
| 111 | +Results are saved in JSON format with the following structure: |
| 112 | +
|
| 113 | +```json |
| 114 | +{ |
| 115 | + "metadata": { |
| 116 | + "language": "python", |
| 117 | + "timestamp": "2025-09-05T15:30:00Z", |
| 118 | + "python_version": "3.11.5", |
| 119 | + "platform": "Darwin-23.1.0-arm64-arm-64bit", |
| 120 | + "cpu_count": 8, |
| 121 | + "total_memory_gb": 16.0, |
| 122 | + "total_tests": 45 |
| 123 | + }, |
| 124 | + "results": [ |
| 125 | + { |
| 126 | + "test_name": "throughput", |
| 127 | + "language": "python", |
| 128 | + "data_size": 1024, |
| 129 | + "concurrency": 1, |
| 130 | + "put_latency_ms": 0.85, |
| 131 | + "get_latency_ms": 0.72, |
| 132 | + "end_to_end_latency_ms": 1.57, |
| 133 | + "ops_per_second": 636.94, |
| 134 | + "bytes_per_second": 652224.0, |
| 135 | + "peak_memory_mb": 0.0, |
| 136 | + "memory_efficiency_ratio": 0.0, |
| 137 | + "p50_latency": 1.55, |
| 138 | + "p95_latency": 1.89, |
| 139 | + "p99_latency": 2.12, |
| 140 | + "timestamp": "2025-09-05T15:30:15Z", |
| 141 | + "python_version": "3.11.5", |
| 142 | + "cpu_count": 8, |
| 143 | + "total_memory_gb": 16.0 |
| 144 | + } |
| 145 | + ] |
| 146 | +} |
| 147 | +``` |
| 148 | + |
| 149 | +## Key Features |
| 150 | + |
| 151 | +### DB-ESDK Integration |
| 152 | + |
| 153 | +- Uses AWS Database Encryption SDK for DynamoDB with transparent encryption |
| 154 | +- Configures attribute actions (ENCRYPT_AND_SIGN, SIGN_ONLY, DO_NOTHING) |
| 155 | +- Tests ItemEncryptor operations with client-side encryption |
| 156 | +- Uses Raw AES keyring for consistent performance testing |
| 157 | + |
| 158 | +### ItemEncryptor Operations |
| 159 | + |
| 160 | +- Performs encrypt_python_item operations using Python dict format |
| 161 | +- Measures decrypt_python_item operations for consistency |
| 162 | +- Tests realistic workloads with encryption overhead |
| 163 | +- Supports multiple data formats (Python dict, DynamoDB JSON, DBESDK shapes) |
| 164 | + |
| 165 | +### Performance Metrics |
| 166 | + |
| 167 | +- **Throughput Tests**: Measures ops/sec and bytes/sec for ItemEncryptor operations |
| 168 | +- **Memory Tests**: Tracks peak memory usage during encrypted operations using psutil |
| 169 | +- **Concurrency Tests**: Evaluates multi-threaded performance scaling with ThreadPoolExecutor |
| 170 | +- **Latency Analysis**: P50, P95, P99 percentiles for operation timing |
| 171 | + |
| 172 | +## Project Structure |
| 173 | + |
| 174 | +``` |
| 175 | +python/ |
| 176 | +├── README.md # This file |
| 177 | +├── pyproject.toml # Poetry configuration and dependencies |
| 178 | +├── tox.ini # Tox configuration for testing |
| 179 | +├── src/ |
| 180 | +│ └── esdk_benchmark/ |
| 181 | +│ ├── __init__.py # Package initialization |
| 182 | +│ ├── __main__.py # Module execution entry point |
| 183 | +│ ├── program.py # Main program and CLI |
| 184 | +│ ├── benchmark.py # Core benchmark implementation |
| 185 | +│ ├── models.py # Data models and configuration |
| 186 | +│ └── tests.py # Individual test implementations |
| 187 | +├── tests/ # Test suite |
| 188 | +│ ├── __init__.py |
| 189 | +│ └── test_benchmark.py |
| 190 | +└── run_benchmark.py # Convenience runner script |
| 191 | +``` |
0 commit comments