Skip to content

tom00/shopware-db-latency-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Shopware Database Connection Latency Test

A simple PHP script to test Shopware's MySQL/MariaDB database connection latency and optionally verify TLS/SSL connectivity.

Features

  • Measures database connection time in milliseconds
  • Tests query execution latency
  • Optional TLS/SSL connection support
  • Verifies active TLS cipher when enabled
  • Parses standard DATABASE_URL environment variable

Requirements

  • PHP 7.4 or higher
  • PDO MySQL extension
  • MySQL or MariaDB database

Installation

Clone or download this repository:

git clone <repository-url>
cd shopware-db-connection-latency-test

No additional dependencies are required - this is a standalone PHP script.

Usage

Basic Usage (without TLS)

Set the DATABASE_URL environment variable and run the script:

export DATABASE_URL="mysql://username:password@hostname:3306/database_name"
php db-latencty-test.php

With TLS/SSL

To enable TLS/SSL connection (with certificate verification disabled):

export DATABASE_URL="mysql://username:password@hostname:3306/database_name"
php db-latencty-test.php --tls

DATABASE_URL Format

The DATABASE_URL should follow this format:

mysql://[user]:[password]@[host]:[port]/[database]

Example:

mysql://root:mypassword@localhost:3306/shopware

Cloud Database Example:

mysql://dbuser:securepass@db.example.com:3306/production_db

Output

The script provides the following information:

Connecting to: localhost:3306/shopware
TLS: Enabled (certificate verification disabled)
--------------------------------------------------
✓ Connection successful!
Connection time: 8.23 ms
TLS Status: Active (Cipher: TLS_AES_256_GCM_SHA384)
Query test time: 2.15 ms

Metrics Reported

  • Connection time: Time to establish database connection
  • TLS Status: Active cipher when TLS is enabled
  • Query test time: Time to execute a simple SELECT 1 query

Troubleshooting

Error: DATABASE_URL environment variable is not set

Make sure to set the DATABASE_URL before running the script:

export DATABASE_URL="mysql://user:pass@host:3306/dbname"

Error: Invalid DATABASE_URL format

Check that your DATABASE_URL follows the correct format with all required components.

Connection Failed

  • Verify database credentials
  • Check that the database server is running
  • Ensure network connectivity to the database host
  • Verify firewall rules allow the connection

TLS Warning: TLS may not be active

The database server may not support TLS or it's not configured. Check your MySQL/MariaDB server configuration.

Use Cases

  • Testing database connection performance in different environments
  • Diagnosing network latency issues
  • Verifying TLS/SSL connectivity
  • Comparing connection times between regions/cloud providers
  • Performance benchmarking for Shopware or other PHP applications

License

MIT License.

About

Script that tests database connection and prints latency

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages