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

anas-k's avatar

Laravel website with 1500000 users at the same time

I have to build website with worst scenario there is 150000 users will use the website at same time for 5 hours. All my previous projects don't have this much traffic. Previously I used Heroku to deploy Laravel websites.

***NOTE *** Hosting must be on Amazon AWS.

What things I should use in Laravel and in AWS and what is the best AWS plan to handle this traffic?

0 likes
16 replies
Cronix's avatar
Cronix
Best Answer
Level 67

For something like this; load balancing. The app can be running on many servers distributing the load. Once that is achieved, it's literally trivial (a few button clicks) to add/remove servers, or have AWS do it automatically with auto-scaling. Like maybe the bulk of your load is during US business hours. You could have 4 (or whatever) app servers running during those times, and only have 1 or 2 during off peak times.

This setup also helps with failover, as there isn't a single point of failure if you set it up right. If an app server goes down, the other servers just pick up the load. You destroy the bad server and bring up a new one with no downtime to your app. That can also be automated.

This type of setup is different from a typical setup. You'd have a separate db server that the other webservers share. You'd use S3 for storing all assets instead of on an individual server, so that all servers (acting as one) has access to the same data. If user A uploads a file to Server A, it needs to be accessible by servers B, C and D as well, so it can't be stored on the individual webserver.

The same goes for sessions. A user might login to server A, but the next request gets served from server B. So you need a common session store that all servers use, like redis.

Now you're just left with dumb webworkers, so you can just add new ones to increase capacity and scale.

Here's a good place to start learning: https://serversforhackers.com/c/so-you-got-yourself-a-loadbalancer

You can also use the Laravel Forge service to manage it all (and set it up). It can create load balancers along with servers.

4 likes
jlrdw's avatar

Cronix is right with load balancing, but you have to remember one thing, if that much usage at one time, there will be delays at times. For example when you have 100 users at once no big deal, but a huge number there are going to be auto response wait times.

Just saying all won't happen in that micro second that everyone seems to expect. But hopefully with the right setup the delays will be 2 or 3 seconds at most.

I remember when I worked for the State of Texas years ago, sometimes a page would load very quickly, other times you could wait several seconds, I mean 5 to 10 seconds.

Also speed is also determined by how many others are on the internet in a given area also.

User A may have a page load quick, but user B, 2 or 3 seconds. A densely populated area affects this stuff.

You could have 4 (or whatever) app servers running during those times

I'd go with the whatever, you may need more than 4, you may need a whole bank of servers. Maybe not.

Edit: I read that above article, if you are at a company doing this, I'd get a pro to help with such a setup. Many companies offer this help with dedicated servers.

1 like
Cronix's avatar

@anas-k You're welcome!

One more piece... I'd build up a few aws servers of different size and load test them to about 80% peak usage. Once you determine how many users a single server of each type can handle, it's just basic math to see how many you need, and to see what would be better/cost effective in terms of A) having fewer larger servers or B) more smaller servers.

Then after your app has been running for a few weeks, you will start to be able to see your traffic patterns and adjust usage/servers.

1 like
anas-k's avatar

@CRONIX - Based on this answer and I watched some videos on how to scale with Forge. I see that me who will decide number of servers I need. As a developer with no previous experience with this Amazon or digital Ocean servers. how I decide which to choose A or B option? Because there is no daily traffic on the website. The website is online contest where expecting worst scenario to be all 150000 users will use the website at the same time for maximum 5 hours only.

Meaning I need test the load balancing server and application servers how they act with 100000 or 150000 users using it before the real users start the contest. Is there a way to achieve this test?

anas-k's avatar

If I use a server with large CPU speed and RAM. Can it handle such large number of users?

Dalma's avatar

Hi your subject line mentions 1.5 Million whereas your body mentions 150K users.

You wont be able to manage either of these concurrently with a single server you will need to look at load balancing. Another issue is related to the database traffic as you wont be able to have 150K or 1.5 Million concurrent hits to your database.

shedcollective's avatar

loadbalance is one thing - but in my previous job we had a high traffic events and PHP/Laravel would keel over - we maxed our servers before those events (4 servers B/E) + 1 DB server + 1 Server (F/E)

Caching/Varnish/CDN would also go a long way to reduce the need to spin up more server than is necessary.

anas-k's avatar

@DALMA - Oops, title is wrong. It is 150k users. Goning with load balancing option using Forge. How can I decide how many application servers I need? Is there a way to test how many requests a server can handle at maximum?

For databse server how RAM and CPU needed so it can handle this much traffic?

anas-k's avatar

@SHEDCOLLECTIVE - I am newbie for load balancing stuff. What do you mean by server B/E, and server F/E?

What server options RAM and CPU you go with for each server?

Cronix's avatar

Is there a way to test how many requests a server can handle at maximum?

Yes, and that's what you need to do. "Load testing"

For databse server how RAM and CPU needed so it can handle this much traffic?

That will also be revealed during load testing. It's a crucial step when building something of this size. You need to know what the hardware will handle. This is why I suggesting on testing against several different machines of different sizes. Often having multiple smaller servers will outperform a larger server. You don't want to test them to 100% usage (using 100% cpu/memory/etc). Test them to about 80% capacity and don't let your servers run higher than that. You never want to peg a system to 100% as it becomes inoperable.

Once you have the numbers for different server options, you can then decide on the most economical way to go (many smaller servers vs fewer larger servers).

https://www.guru99.com/load-testing-tutorial.html

The questions you're asking here doesn't have a one size fits all answer. There is no "Oh, for 150k users, you need x cpu and y ram." Because every single app is different. A "to-do" list type app would need very few resources compared to something like facebook. You could probably get 3x as many users on the to-do list app using the same hardware vs a FB type app. You need the actual data that only load testing would really provide, by running your specific app code on it.

https://www.sitepoint.com/stress-test-php-app-apachebench/

1 like
anas-k's avatar

@CRONIX - Thank you a lot. And your last point and example make it clear to me, i am wrong to think in this way.

webjobs's avatar

@anas-k did you finally find the right setup and solution, if yes please share what worked out for you in the end

shedcollective's avatar

@anas-k

What do you mean by server B/E, and server F/E?

i mean having separate servers for backend & frontend

Dont forget VARNISH/Caching will probably reduce the need to have lots of servers (you will still needs servers but without these you might have needed 8, with these you might only need 5/6 etc)

1 like

Please or to participate in this conversation.