I have a simple laravel 11 application running on php 8.3, and i only change the db (mysql) settings via the .env file when im using local db (127.0.0.1) everything is extremly fast i logged the query time and it can be seen here:
[2024-06-12 22:05:42] local.INFO: select * from w_users where id = ? limit 1 {"bindings":[1],"time":4.1}
[2024-06-12 22:05:42] local.INFO: select * from w_users where w_users.id = ? limit 1 {"bindings":[1],"time":1.49}
later i switched to an external db provider (digital ocean) and i noticed that the page is very slow here are the results i logged:
[2024-06-12 22:07:03] local.INFO: select * from w_users where id = ? limit 1 {"bindings":[1],"time":1228.27}
[2024-06-12 22:07:03] local.INFO: select * from w_users where w_users.id = ? limit 1 {"bindings":[1],"time":352.72}
i tried several cloud db vendors but its always extremely slow what can be done? note: both databases (the local and the remote are generated using the same script and both are empty not having data)
my architecture requires several laravel instances behind load balancer accessing a common remote db
I was not able to find a solution, i ended up using a dedicated ec2 with mysql running on it, being on the same network the application now works fast as expected