2 months ago
Are all services always within the same region if in the same environment? On my prod environmet my wordpress site makes super fast queries to the mariadb but on staging it's a bit slower and on PR it's even slower.
The actual database call which I tested with ssh: $wpdb->get_var("SELECT 1") timed about doubly as slow on staging and 20x slower on PR
I understand that given there's a bunch of WP settings that may be a factor but I thought that given I'm just making a direct database call the wordpress settings would be less likely to be an issue. It's hard to get a 1-1 identical environment across wordpress sites because copying over all the settings isn't easy but all the container level stuff should be the same. Any ideas? I'm just worried something about the mariadb might just start slowing down on my prod environment because of something I'm not considering right
3 Replies
2 months ago
Are all services always within the same region if in the same environment?
No, you can set whatever region you want on each individual service, so region locality is something you must check on your end.
Both are on the same region across all my environments so probably not that 🤔
a month ago
If region is already the same, I would split the test into connection setup vs query execution. A SELECT 1 through WordPress can still include WP bootstrap, DB connection creation, DNS, TLS/proxy path, and cache warmth differences.
I would run the same checks from each web container:
- Confirm the DB host is the internal Railway host, not the public TCP proxy host. Public proxy can look fine but adds a different network path.
- Time a raw mysql client call from the container to the exact host/port WordPress uses.
- Run several calls on one already-open mysql session. If first call is slow but repeated calls are fast, the penalty is connection/DNS/TCP setup, not MariaDB query time.
- Compare MariaDB metrics and cache state between prod/staging/PR. PR databases are often cold: smaller buffer pool warmth, cold volume cache, no warmed query/index pages, and sometimes different resource limits.
- Check whether PR/staging has any plugin/debug setting that runs during
wp evalor page bootstrap. WordPress can do a lot before your one$wpdbline executes.
A good minimal test is:
mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p"$DB_PASSWORD" -e "SELECT 1"
Then test repeated queries inside one session or with a tiny PHP script that opens one mysqli/PDO connection and runs SELECT 1 20 times. If only PR is 20x slower after connection reuse, then look at MariaDB resource/cache/volume metrics. If connection setup is the slow part, look at DB_HOST path, DNS, public-vs-private networking, and whether each environment is actually referencing its own DB service variables.