|
1 | 1 | # DB(D) Endpoint(E) Latency(L) Testing(T) Ammeter(A)
|
2 | 2 |
|
3 |
| -## DELTA |
| 3 | +## DELTA - FastAPI based WebApp to test Database Latency (NEW, 2025) |
4 | 4 |
|
5 |
| -📌 Introducing DELTA (DB Endpoint Latency Testing Ammeter). DELTA is a tool to test real-world latency against a remote database using execution of a query and calculating the network return time. The tool provides functions to test latency of Oracle, MySQL and Postgres databases. |
| 5 | +This project is a secure, lightweight SaaS-like database latency testing GUI and API, built with FastAPI. |
6 | 6 |
|
7 |
| -The tool uses the oracledb python package to connect to Oracle databases and execute a single query per request (you can specify multiple requests as well). The tool uses the time module to measure the time it takes to execute the query, fetch the results, and close the connection. It calculates the latency of each request and the average latency of all requests. |
| 7 | + |
8 | 8 |
|
| 9 | + |
9 | 10 |
|
10 |
| -🔧 DELTA is a cloud tool to test real-world latency against a remote database endpoint using execution of a query and calculating the network return time. |
| 11 | + |
11 | 12 |
|
| 13 | +## Databases Supported 🔌 : |
12 | 14 |
|
13 |
| -🔧 Network tools like ping ,iperf or tcp ping can only give you network based latency which does not always translate well to an application running those queries on a remote database. |
14 |
| - |
15 |
| - |
16 |
| -🐍 DELTA uses Python client for Oracle, MySQL and PostgreSQL to run a query like “SELECT 1” or "SELECT 1 FROM DUAL". You can then specific the number of executions of the query and DELTA calculates the average network round-trip time for all the executions of the query on the remote database. The script also includes error handling to track failed requests. You can also include your own custom queries. |
17 |
| - |
18 |
| - |
19 |
| - ## Databases Supported 🔌 : |
20 |
| - |
21 |
| - |
22 |
| - ### Oracle DB >= 12.2 📌 : |
23 |
| - |
| 15 | +### Oracle DB >= 12.2 📌 : |
24 | 16 | - Amazon RDS Oracle
|
25 |
| - |
26 | 17 | - OCI Autonomous Database
|
27 |
| - |
28 | 18 | - OCI VMDB
|
29 |
| - |
30 | 19 | - OCI Exadata Cloud Service
|
31 |
| - |
32 | 20 | - Oracle Database On-Premise
|
33 | 21 |
|
34 |
| - |
35 | 22 | ### Postgres >= 11 📌 :
|
36 |
| - |
37 | 23 | - Amazon RDS Postgres
|
38 |
| - |
39 | 24 | - Amazon RDS Aurora Postgres
|
40 |
| - |
41 | 25 | - Postgres On-premise
|
42 | 26 |
|
43 |
| - |
44 | 27 | ### MySQL >= 5.7 📌 :
|
45 |
| - |
46 | 28 | - Amazon RDS MySQL
|
47 |
| - |
48 | 29 | - Amazon RDS Aurora MySQL
|
49 |
| - |
50 | 30 | - OCI MySQL Database Service
|
51 |
| - |
52 | 31 | - OCI MySQL Heatwave
|
53 |
| - |
54 | 32 | - MySQL On-Premise
|
55 | 33 |
|
56 |
| - |
57 | 34 | ### URL - HTTPS | HTTP 📌 :
|
58 |
| - |
59 | 35 | - Check Public or Private URLs for latency
|
60 | 36 |
|
61 | 37 |
|
62 |
| -# Deploy |
63 |
| - |
64 |
| -## Requirement |
65 |
| - |
| 38 | +### 1. Create a Python Virtual Environment |
| 39 | +```bash |
| 40 | +python3 -m venv .venv |
| 41 | +# Activate on Unix/macOS: |
| 42 | +source .venv/bin/activate |
| 43 | +# Activate on Windows: |
| 44 | +.venv\Scripts\activate |
66 | 45 | ```
|
67 |
| -Python >= 3.6.8 |
| 46 | +### 2. Install requirements |
| 47 | +```bash |
| 48 | +pip install -r requirements.txt |
68 | 49 | ```
|
69 |
| - |
70 |
| -## Clone Repo |
71 |
| - |
| 50 | +### 3. Launch the Web App |
| 51 | +```bash |
| 52 | +uvicorn app.main:app --host 0.0.0.0 --port 8000 |
72 | 53 | ```
|
73 |
| -git clone https://github.com/oracle-quickstart/db-endpoint-latency-testing-ammeter.git |
74 |
| -
|
75 |
| -cd db-endpoint-latency-testing-ammeter/ |
76 |
| -
|
77 |
| -python3 -m venv db-endpoint-latency-testing-ammeter |
78 |
| -
|
79 |
| -source db-endpoint-latency-testing-ammeter/bin/activate |
| 54 | +### 4. Open your browser at: |
80 | 55 | ```
|
81 |
| - |
82 |
| -## Install Python packages |
| 56 | +http://localhost:8000 |
83 | 57 | ```
|
84 |
| -## On CentOS or Oracle Linux or Redhat Linux |
85 |
| -sudo yum install postgresql postgresql-devel python36-devel |
86 |
| -
|
87 |
| -## On Ubuntu |
88 |
| -sudo apt install libpq-dev python3.x-dev |
| 58 | +- Log in: `admin` / `change_this` (update password in `app/main.py` for production). |
| 59 | +- Fill out the form and run latency tests in real time with live chart and table views. |
| 60 | +- For any errors (connection, authentication) you'll see detailed front-end feedback. |
89 | 61 |
|
90 |
| -## Install requirements |
91 |
| -pip3 install -r requirements.txt |
| 62 | +### 5. API Usage via Curl/CLI Example: |
| 63 | +```bash |
| 64 | +curl -u admin:change_this -X POST http://localhost:8000/api/test-latency \ |
| 65 | + -F dbtype=postgresql -F host=localhost -F port=5432 -F username=postgres -F password=yourpassword -F database=postgres -F interval=1 -F period=10 |
92 | 66 | ```
|
| 67 | +- API returns JSON, suitable for automation and CI. |
93 | 68 |
|
94 |
| -# Calculate Latency for Oracle DB |
| 69 | +--- |
95 | 70 |
|
96 |
| -Set the below credentials in the delta.py script |
97 |
| -``` |
98 |
| -oracle_un='your_user' |
99 |
| -oracle_pw='your_password' |
100 |
| -oracle_cs='your_connection_string' |
101 |
| -``` |
102 |
| -Run |
103 |
| -``` |
104 |
| -python3 delta.py --db oracle --interval 3 --period 5 --csvoutput oracle_latency.csv |
105 |
| -``` |
| 71 | +## Command-Line (delta.py) Usage — Secure, No Stored Credentials |
106 | 72 |
|
| 73 | +The original `delta.py` script remains available for CLI power users and can test Oracle, PostgreSQL, MySQL, and URLs. **No credentials are stored in this file**; you must supply all values as arguments or interactively via a prompt. |
107 | 74 |
|
108 |
| -# Calculate Latency for MySQL |
| 75 | +Use it like this (replace ALL UPPERCASE placeholders): |
109 | 76 |
|
110 |
| -Set the below credentials in the delta.py script |
111 |
| -``` |
112 |
| -mysql_un = 'mysql' |
113 |
| -mysql_pw = 'your_password' |
114 |
| -mysql_host = 'localhost' |
115 |
| -mysql_port = '3306' |
116 |
| -mysql_db = 'mysql' |
117 |
| -``` |
118 |
| -Run |
119 |
| -``` |
120 |
| -python3 delta.py --db mysql --interval 3 --period 5 --csvoutput mysql_latency.csv |
121 |
| -``` |
122 |
| - |
123 |
| -# Calculate Latency for PostgreSQL |
| 77 | +### Oracle Example |
124 | 78 |
|
125 |
| -Set the below credentials in the delta.py script |
126 |
| -``` |
127 |
| -pgsql_un = 'postgres' |
128 |
| -pgsql_pw = 'your_password' |
129 |
| -pgsql_host = 'localhost' |
130 |
| -pgsql_port = '5432' |
131 |
| -pgsql_db = 'postgres' |
| 79 | +```bash |
| 80 | +python delta.py --db oracle --user ADMIN_USER --password YOUR_PASSWORD --host "YOUR_ORACLE_DSN" --interval 3 --period 5 --csvoutput oracle_latency.csv |
132 | 81 | ```
|
133 |
| -Run |
134 |
| -``` |
135 |
| -python3 delta.py --db postgresql --interval 3 --period 5 --csvoutput postgres_latency.csv |
136 |
| -``` |
137 |
| - |
| 82 | +- If you omit an argument, you will be prompted at runtime (passwords asked securely). |
138 | 83 |
|
139 |
| -# Calculate URL Latency |
| 84 | +### PostgreSQL Example |
140 | 85 |
|
141 |
| -Set the below parameter in the delta.py script |
142 |
| -``` |
143 |
| -test_url = 'your_url' |
144 |
| -``` |
145 |
| -Run |
146 |
| -``` |
147 |
| -python3 delta.py --db url --interval 3 --period 5 --csvoutput url_latency.csv |
| 86 | +```bash |
| 87 | +python delta.py --db postgresql --user PG_USER --password YOUR_PASSWORD --host PG_HOST --port 5432 --database DB_NAME --interval 3 --period 5 --csvoutput postgres_latency.csv |
148 | 88 | ```
|
| 89 | +### MySQL Example |
149 | 90 |
|
150 |
| -# Test Cases for Each DB and URL |
151 |
| - |
| 91 | +```bash |
| 92 | +python delta.py --db mysql --user MYSQL_USER --password YOUR_PASSWORD --host MYSQL_HOST --port 3306 --database DB_NAME --interval 3 --period 5 --csvoutput mysql_latency.csv |
152 | 93 | ```
|
153 |
| -python3 delta.py --db oracle --interval 3 --period 5 --csvoutput oracle_latency.csv |
| 94 | +### URL Example |
154 | 95 |
|
155 |
| -python3 delta.py --db mysql --interval 3 --period 5 --csvoutput mysql_latency.csv |
| 96 | +```bash |
| 97 | +python delta.py --db url --url "https://example.com" --interval 3 --period 5 --csvoutput url_latency.csv |
| 98 | +``` |
| 99 | +- All arguments can also be supplied interactively if omitted. |
| 100 | +- No passwords, usernames, or hostnames are stored in the codebase. |
156 | 101 |
|
157 |
| -python3 delta.py --db postgresql --interval 3 --period 5 --csvoutput postgres_latency.csv |
| 102 | +--- |
158 | 103 |
|
159 |
| -python3 delta.py --db url --interval 3 --period 5 --csvoutput url_latency.csv |
160 |
| -``` |
161 | 104 |
|
162 | 105 | ## Contributing
|
163 | 106 |
|
|
0 commit comments