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

wheeler's avatar

Forge high availability setup

I have 6 websites running the same app, deployed on Linode. 2 of the websites receive quite a lot of traffic.

The setup is:

  1. 6x load balancers (one per site) w/ SSL termination
  2. 2x 2GB app servers
  3. 1x 32GB "utility" server, does media storage, image manipulation, video encoding, database slave replication
  4. 1x 16GB dedicated db server
  5. CDN for media hosting (after initial processing)
  • All servers run Debian 8. I don't mind whether i'm running Debian or Ubuntu going forward.
  • Although quite stable, this setup is kindof overkill for our requirements. I think switching to nginx and php 7 plus utilising queues and 3rd party services more would exacerbate the amount of spare capacity even further.
  • I've looked at AWS & Rackspace and it just seems insanely expensive when it comes to running databases in the cloud.

I am looking at becoming a bit more agile in terms of deployments, reducing sysadmin overheads, and adding or removing sites more easily, so i'm looking specifically at Laravel Forge.

Some of the questions / challenges are:

  1. Can I get away with potentially 2x 16GB all purpose servers?
  2. Should I run Master Master replication on the app servers instead and ditch the dedicated db server?
  3. Are there any tools or Forge recipes for managing replication for a mere mortal web developer like me?
  4. Does it make sense to keep scaling "all purpose" servers horizontally?
  5. Should I run 1 or 2 app servers per site and scale down the app servers?

What are people doing these days? When we setup our current environment, splitting off the db for example was a no-brainer; nowadays i'm not convinced it is as common as it used to be with 4-20+ cores, SSD storage, KVM, PHP7, and better queue and cache tooling.

Has anyone deployed a mission critical app (especially ones involving multiple websites) in Forge? Does my plan make any sense?

0 likes
2 replies
gMagicScott's avatar

It's really hard to prescribe a solution without a lot more knowledge on what these apps are, what the load averages, what kind of spikes, etc.

Two special notes:

  1. I haven't tried Forge
  2. I have never worked with video encoding outside of some personal stuff that I've rendered on my own computer. I have no idea how it works on a server or what resources it will take.

Some general recommendations:

  • If an app needs multiple machines, use a stack per app.
  • Start with two load balancers. I prefer haproxy. All traffic goes through one, the second balancer sits at the ready to steal the primary's IP should it become unresponsive. I balance using least connections and pass through the SSL termination to the app server.
  • If you need multiple database servers either for redundancy or load, keep them off by themselves.
  • One server could potentially serve as "utility" maintaining the cache, php sessions (this needs to be off the app servers if you don't use sticky sessions, and I don't recommend using sticky sessions), and a background queue list.
  • One final server could serve as the queue worker. That's where you can do your image manipulation, video encoding, etc.

The single "utility cache" and "worker" are single points of failure in what I just described. You might want to have everything in twos if you want to increase your reliability and minimize the odds of you needing to wake up at 3am to reset something.

If you need more info, including some sample configuration code, check out Steve Corona's book Scaling PHP (no affiliation, I just think that its a good book)

snipdata's avatar

I was using Linode for some time, 4 months ago I switched to DigitalOcean.

My setup is: 2 x Main Load Balancers 512MB 3 x Web Server 2GB (Using Forge) 3 x Percona Cluster XtraDB (Galera Database) 8GB 2 x Redis 1GB (session) 2 x DB Load Balancers Database & Session 512MB

All my websites has HAProxy SSL termination at the load balancers, i'm using floating ips. I'm using CloudFlare as a simple caching (since 95% is a dynamic content)

Scaling DB is for me is take down one done at a time, resize and done. It takes like 5 mins per server. Scaling Web Servers takes me like 5 mins (create a new server), If I need to scale up I just resize to 4GB the the time needed (normally it takes 1 minute)

How do I deploy? I have a bitbucket repo for production ready. I just push all changes and forge do everything for me and replicate in all servers at same time.I have quick deployments enabled in forge.

If helps, I have everything in New York DC but one DB (low priority in DB LB) and a Web server are in Los Angeles.

1 like

Please or to participate in this conversation.