This web application compares the performance of PostgreSQL and MariaDB by running identical queries and measuring execution times. It uses Harness FME feature flags to dynamically determine which database to use for each request.
- Web interface that displays query results and execution times
- Dynamic database selection via Harness FME feature flags
- Sample queries to test different database operations
- Execution history tracking
- Container management for PostgreSQL and MariaDB
- Docker installed and running
- Python 3.6+
- Harness FME account for feature flag management (or use localhost mode for testing)
- Clone or download this repository
- Install required Python dependencies:
pip install -r requirements.txt
- Create a
.envfile based on the.env.exampletemplate:
cp .env.example .env
- Edit the
.envfile to add your Harness FME API key and a secure Flask secret key
- Create a Harness FME account if you don't have one
- Create a feature flag named
db_performance_comparisonwith two treatments:postgresandmariadb - Configure your targeting rules as desired (e.g., 50/50 split, geolocation-based, etc.)
- Copy your API key to the
.envfile
Start the web server:
python app.py
Access the application at: http://localhost:5000
-
Each time a user loads the page, the application:
- Ensures PostgreSQL and MariaDB containers are running
- Loads test data if needed
- Consults the Harness FME feature flag to determine which database to query
- Executes the query on the selected database
- Displays results and execution time in a user-friendly interface
- Tracks query execution history
-
Users can:
- Run new queries by reloading the page
- Select from sample queries
- View execution history
- Clean up containers when finished
The application includes a load testing script (load_tester.py) that can simulate multiple concurrent users accessing the web application. This is useful for generating traffic to the feature flag system and comparing database performance under load.
Install the required dependencies for load testing:
pip install selenium webdriver-managerYou'll need Chrome browser installed for the test script to work.
Basic usage with default settings (5 concurrent sessions, 60 seconds duration):
python load_tester.pyAdvanced usage with more options:
python load_tester.py --sessions 10 --duration 60 --auto-refresh--url- Base URL of the web app (default: http://localhost:5000)--sessions- Number of concurrent browser sessions (default: 5)--duration- How long each session should run in seconds (default: 60)--auto-refresh- Use the application's built-in auto-refresh feature--refresh-interval- Seconds between refreshes for manual mode (default: 5)--queries- Specific queries to distribute across sessions
Example with specific queries:
python load_tester.py --sessions 20 --queries "SELECT COUNT(*) FROM test_table" "SELECT * FROM test_table LIMIT 10"To stop and remove the Docker containers, visit: http://localhost:5000/cleanup
Or simply stop the Flask server with Ctrl+C (the application will clean up containers automatically)