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

swist's avatar
Level 11

Forge Load Balancer response status code statistics

Hi,

I use Forge Load Balancer, but I was wondering if there is a way to check how many requests receives which status code (200 vs errors 5xx). DigitalOcean offers charts for this but I can't setup SSL there because my DNS are set to CloudFlare and I don't to change that.

Do you guys have an idea how to monitor status codes (% of 5xx errors)?

0 likes
7 replies
bugsysha's avatar

Yes, just create a global middleware that is applied to every route and write status code and URL to a log file.

swist's avatar
Level 11

How can I setup middleware for a Load Balancer? When i SSH into it /home/forge directory looks empty (only couple of hidden files).

bugsysha's avatar

The load balancer will switch between multiple app instances, right? So those errors occur on one of those app instances. If it gets there it will allow you to log it within Laravel.

swist's avatar
Level 11

I mean for example 502 bad gateway or 408 timeout errors. Errors that can occur when the server is overloaded (and when this happens server might miss some % of requests).

The DigitalOcean load balancer has charts where you can see all requests in time separated by a status code. I was wondering how can I reproduce that chart on Load Balancer itself. Maybe using some Linux extension.

bugsysha's avatar

Are you saying that the load balancer will get overloaded and cause those errors? I think that the chances of that happening are probably zero. If not, I have that setup for years on DO and haven't noticed them.

swist's avatar
Level 11

No I mean errors on servers (child servers). I have a load balancer spreading traffic to 2 droplets. On high load both can be not enough to handle the traffic. In that scenario both might not be able to respond to all users.

I would also love to see url's of 5xx errors. I had that situations before and I want to know what happened when there was a large increase in traffic.

bugsysha's avatar

Damn, I never had that issue or I've missed it, and I had some seriously underpowered servers handling a high load. I think that you are wasting your time on irrelevant issues. Consider moving to Vapor if you have those issues with your servers.

Please or to participate in this conversation.