Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Annaro's avatar

Database server with a load balancer

I have an app with a database containing users as well as other tables. Logged in users can start jobs. Jobs can be demanding, and i want my app to be able to handle any number of users / jobs, which is why i'm looking into load balancers now. I am thinking about Laravel Forge (even though i am unsure if configuring a load balancer directly with Digital Ocean might be a good alternative too).

Would this be a good configuration?

Server 1: database
Server 2: load balancer
Server 3: app
Server 4: app

In that case, should my .env files on Server 3 and Server 4 indicate something like this?

DB_HOST= {{ ip address of Server 1 }}

So the deployment script for Server 1 would say: php artisan migrate but the deployment scripts for the other servers would not contain that line, is that right?

Is there anything else to configure to make the whole thing work with my database on a different server than my app?

Should i link the domain name to Server 2, 3 and 4, but NOT to Server 1, right?

Thank you!

0 likes
4 replies
Annaro's avatar

@martinbean Sorry about that. It is the same topic, but i feel like it's 2 different questions though. This one focusing on how to deal with the database in the context of load balancing, and the other one asking general advice regarding which provider to use.

Annaro's avatar

@aleahy Thank you so much, it seems really useful, i'll see where it leads me :)

Please or to participate in this conversation.