A comprehensive Docker-based solution for MariaDB performance testing with integrated Percona PMM monitoring.
βββ docker-compose.yml # Complete environment setup
βββ Dockerfile # Test application container
βββ README.md # This documentation
βββ test_files/ # Test scripts directory
βββ auto_run_tests.sh # Automated test runner
βββ setup_database.sh # Database setup
βββ insert_test.sh # INSERT operations
βββ update_test.sh # UPDATE operations
βββ delete_test.sh # DELETE operations
βββ select_test.sh # SELECT queries
βββ run_performance_tests.sh # Interactive test menu
# Start all services
docker compose up -d
# Enable query response time plugin
./mariadb_setup/enable-query-response-time.sh
# Setup PMM table statistics
./mariadb_setup/enable-pmm-table-stats.sh
# Run performance tests on custom database
sudo docker run --rm -e DB_NAME=sales_db --name sales_db_test --network mariadb_app_network mariadb-tester- Container:
mariadb1 - Port:
3306 - Credentials: root / 123
- Default DB:
performance_test
- Container:
pmm-server - Web UI: http://localhost:8080
- HTTPS UI: https://localhost:8443
- Login: admin / admin
- Container:
pmm-client - Purpose: Monitoring agent for MariaDB
- Auto-connects: Links to PMM server automatically
- Built from:
Dockerfile - Purpose: CRUD and performance testing
- Database Parameter: Configurable via
DB_NAMEenvironment variable - Usage: Run separately using docker commands
# First, build the test image
docker build -t mariadb-tester .
# Run tests on default database (performance_test)
sudo docker run --rm --network mariadb_app_network mariadb-tester
# Run tests on custom database (simplified syntax)
sudo docker run --rm --network mariadb_app_network \
-e DB_NAME=sales_db --name sales_db_test mariadb-tester
# Run interactive test menu
sudo docker run --rm -it --network mariadb_app_network \
-e DB_NAME=sales_db --name sales_db_test mariadb-tester ./run_performance_tests.sh| Script | Description | Operations |
|---|---|---|
setup_database.sh |
Database and table creation | DDL |
insert_test.sh |
High-volume INSERT operations | CREATE |
select_test.sh |
Complex SELECT queries | READ |
update_test.sh |
Bulk UPDATE operations | UPDATE |
delete_test.sh |
Bulk DELETE operations | DELETE |
auto_run_tests.sh |
Complete automated suite | ALL |
- Start services:
docker compose up -d - Open browser: http://localhost:8080
- Login: admin / admin
οΏ½ Setup PMM Monitoring:
# Enable query response time plugin
./mariadb_setup/enable-query-response-time.sh
# Setup PMM table statistics (follow instructions)
./mariadb_setup/enable-pmm-table-stats.shManual Registration via Web UI:
- Go to Configuration β Inventory
- Click "Add Service"
- Select "MySQL"
- Use these connection details:
- Host:
mariadb1 - Port:
3306 - Username:
root - Password:
123 - Service Name:
mariadb-monitoring
- Host:
- βοΈ CRITICAL - Advanced Settings:
- β Enable "Table Statistics"
- β Set "Table Statistics Limit" to 5000
- β Enable "Query Analytics" with "Performance Schema"
- β Enable "User Statistics"
All test scripts support these parameters:
DB_NAME=your_database # Target database name
DB_HOST=mariadb1 # Database host
DB_PORT=3306 # Database port
DB_USER=root # Database username
DB_PASS=123 # Database password# Build test image first (if not already built)
sudo docker build -t mariadb-tester .
# Test specific database (simplified)
sudo docker run --rm --network mariadb_app_network \
-e DB_NAME=sales_db --name sales_db_test mariadb-tester
# Test with different database
sudo docker run --rm --network mariadb_app_network \
-e DB_NAME=inventory --name inventory_test mariadb-tester
# Test with custom user credentials (override defaults)
sudo docker run --rm --network mariadb_app_network \
-e DB_NAME=inventory -e DB_USER=testuser -e DB_PASS=testpass \
--name inventory_test mariadb-tester# Start core services (MariaDB + PMM)
docker compose up -d
# Stop all services
docker compose down
# View logs
docker compose logs -f mariadb1
docker compose logs -f pmm-server
# Clean restart
docker compose down -v && docker compose up -d
# Build test application
sudo docker build -t mariadb-tester .
# Run specific test
sudo docker run --rm --network mariadb_app_network \
-e DB_NAME=sales_db --name sales_db_test \
mariadb-tester ./insert_test.shCREATE TABLE transactions (
transaction_id INT AUTO_INCREMENT PRIMARY KEY,
product_name VARCHAR(100),
quantity INT,
price DECIMAL(10,2),
transaction_date DATETIME
);- Dockerized Environment - Complete setup with one command
- Database Flexibility - Test any database via
DB_NAMEparameter - Comprehensive Testing - CRUD operations + performance tests
- Real-time Monitoring - Percona PMM integration
- Network Isolation - All services on dedicated network
- No Auto-registration - Manual PMM configuration for control
# 1. Start core services
docker compose up -d
# 2. Build test application
sudo docker build -t mariadb-tester .
# 3. Run tests on your database
sudo docker run --rm --network mariadb_app_network \
-e DB_NAME=myapp_db --name myapp_test mariadb-tester
# 4. Monitor in PMM dashboard
# Visit: http://localhost:8080
# 5. Clean up
docker compose downThis setup provides a complete MariaDB testing and monitoring environment with minimal configuration required.
DB_NAME="performance_test"
DB_USER="root"
DB_PASS="" # Set your password
DB_HOST="localhost"
DB_PORT="3306"cd /home/magdi/mariadb
chmod +x *.sh
./run_performance_tests.sh# Run all tests
./run_performance_tests.sh all
# Run individual tests
./run_performance_tests.sh setup
./run_performance_tests.sh insert
./run_performance_tests.sh update
./run_performance_tests.sh delete
./run_performance_tests.sh select
# Show statistics
./run_performance_tests.sh stats
# Clean database
./run_performance_tests.sh clean# Setup database first
./setup_database.sh
# Run performance tests
./insert_test.sh # Insert 100,000 records
./select_test.sh # Various SELECT patterns
./update_test.sh # Update 50,000 records
./delete_test.sh # Delete 25,000 records
# Optimize MariaDB configuration
./optimize_mariadb.sh- Records: 100,000 (configurable)
- Batch Size: 1,000 records per batch
- Threads: 4 parallel threads
- Data: Realistic product transactions with random data
- Features: Bulk inserts with transaction batching for optimal performance
- Updates: 50,000 (configurable)
- Patterns: Price adjustments, quantity updates, product name changes, date updates
- Threads: 4 parallel threads
- Features: Various update patterns to simulate real-world scenarios
- Deletes: 25,000 (configurable)
- Patterns: Old records, low-value transactions, high quantities, specific products
- Threads: 4 parallel threads
- Features: Different deletion criteria to test various index usage
- Query Types: Simple, Aggregate, Complex
- Queries: 1,000 per type (configurable)
- Threads: 4 parallel threads
- Features:
- Simple: ID ranges, product filters, price ranges
- Aggregate: COUNT, SUM, AVG, GROUP BY operations
- Complex: Subqueries, window functions, statistical analysis
The optimizer script automatically:
- Detects system resources (RAM, CPU, disk space)
- Calculates optimal buffer pool size (70% of RAM)
- Sets appropriate connection limits
- Optimizes InnoDB settings for bulk operations
- Disables safety features for maximum performance (testing only!)
- InnoDB Buffer Pool: 70% of available RAM
- Log File Size: 25% of buffer pool size
- Flush Settings: Optimized for performance over durability
- Thread Pool: Based on CPU cores
- Disabled Features: Binary logging, doublewrite buffer (testing only)
- INSERT: 15,000-25,000 records/second
- SELECT Simple: 5,000-10,000 queries/second
- SELECT Aggregate: 1,000-3,000 queries/second
- SELECT Complex: 500-1,500 queries/second
- UPDATE: 5,000-15,000 updates/second
- DELETE: 3,000-10,000 deletes/second
Performance varies significantly based on hardware, MariaDB configuration, and system load.
Each test script provides:
- Real-time progress updates
- Execution time measurement
- Throughput calculations (operations/second)
- Error reporting
- Sample result verification
INSERT test completed!
Total time: 6.45s
Records inserted: 100000
Throughput: 15503.88 records/second
Current table count: 100000 records
- Scripts disable important safety features (durability, binary logging)
- Use dedicated test systems, not production databases
- High-volume operations may impact system performance
- Ensure adequate disk space before running tests
β "No data" in PMM Table Details Dashboard:
# Enable query response time
./mariadb_setup/enable-query-response-time.sh
# Setup PMM table statistics
./mariadb_setup/enable-pmm-table-stats.shπ§ Manual Fix:
- Ensure Table Statistics are enabled during service registration
- Set Table Statistics Limit to 5000+ (not default 1000)
- Enable Performance Schema for Query Analytics
- Wait 2-3 minutes after registration for data collection
-
Connection Failed
- Check MariaDB service status:
sudo docker compose ps - Verify credentials in script configuration
- Ensure MariaDB is accepting connections
- Check MariaDB service status:
-
Low Performance
- Check system resources (RAM, CPU, I/O)
- Monitor system load during tests
- Use
docker compose logs mariadb1for debugging
-
Out of Memory Errors
- Reduce batch sizes in scripts
- Decrease thread count
- Increase system swap space
- Optimize MariaDB memory settings
-
Permission Errors
- Ensure scripts are executable:
chmod +x *.sh - Use
sudofor Docker commands - Verify file system permissions
- Ensure scripts are executable:
Edit variables in each script:
TOTAL_RECORDS=100000 # Number of records to insert
BATCH_SIZE=1000 # Records per batch
THREADS=4 # Parallel threads
QUERIES_PER_TYPE=1000 # Queries per test typeModify the test functions in each script to add:
- Different data patterns
- Custom query types
- Additional product categories
- Specific business logic scenarios
- Run baseline tests with default MariaDB settings
- Apply optimizations with
optimize_mariadb.sh - Run tests again and compare results
- Adjust individual parameters and re-test
# Create a performance monitoring loop
while true; do
echo "Starting performance test cycle at $(date)"
./run_performance_tests.sh all
echo "Sleeping for 1 hour..."
sleep 3600
doneFor issues or questions:
- Check MariaDB error logs:
/var/log/mysql/error.log - Monitor system resources:
htop,iotop,free -h - Review MariaDB performance schema
- Adjust script parameters based on your system capabilities
Note: This test suite is designed for database performance evaluation and should be used in controlled test environments only.