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

AzizFatkhuRohman's avatar

Setup Laravel for many users and information system complex

What needs to be considered so that Laravel can handle a large number of users and be scalable for routine and complex usage?

0 likes
15 replies
jaseofspades88's avatar

Write well structured queries without n+1 problems, paginate large datasets and use the myriad of tooling available to you. Perhaps use Laracasts and watch some videos to learn techniques.

2 likes
Tray2's avatar

Agree with @jaseofspades88 , a good database model with proper indexes and well written queries, and you should be good for a shitload of users.

3 likes
Tray2's avatar

@AzizFatkhuRohman I would go with MariaDB or MySQL, but you can also use PostrgreSQL, it doesn't really matter.

JussiMannisto's avatar

Agree with the points above. Performance bottlenecks are usually related to DB.

It all depends on what you mean by a large number of users. 50,000 users is very different from 5,000,000 users. A simple CRUD app is also very different from a social media app. But here are some tips:

  • Cache the results of expensive queries to avoid repeating them all the time.
  • If you need full text searches, use either a proper search engine or full text indexes offered by the DB.
  • You can use Redis as the driver for cache, queues and sessions (use the PECL PHP extension because it's way more performant than the predis package).

On the PHP side, you could use Laravel Octane with one of the high-speed application servers like FrankenPHP. I have no real experience with Octance, but it should speed up the PHP part of your app dramatically compared to PHP-FPM. In a few years it'll probably be the recommended way of deploying Laravel apps.

You can scale your app horizontally in many ways. You can create a load balancer with multiple server instances. You can add read-only replicate database servers. You can use CDNs. You can do a lot of things, but none of these are specific to Laravel.

2 likes
martinbean's avatar

@azizfatkhurohman Solve problems you actually have, and when you have them.

This is literally premature optimisation. There’s no point optimising for A if your problem ends up being B.

1 like
AzizFatkhuRohman's avatar

@martinbean so i create information system for internship monitoring, 2 month ago production and normal, but 2 week ago many problem, as example menu review logbook slow in running.

you must know, i build with laravel 10, bootstrap 5, every data make paginate, i using mysql. for write query in model, controller using resource, i has clean code. what do you can give solution concrete to my problem? thanks.

Tray2's avatar

@AzizFatkhuRohman You need to check your queries and that you have the proper indexes.

Here are a few tips.

  1. Never fetch more columns than you need.
  2. Never use php to filter data.
  3. Try to avoid n+1 issues.
  4. Make sure to have indexes on columns that you filter and sort on.
  5. Make composite indexes instead of single column indexes when possible.
  6. Make as many indexes as you need, but as few as you can get away with.
  7. Get a subscription here and watch https://laracasts.com/series/eloquent-performance-patterns
1 like
JussiMannisto's avatar

@AzizFatkhuRohman First you have to figure out why the page is slow; is it DB queries, bad UI code, or something else.

If it's the queries, find out which of them are slow and why they're slow. See if any query is run multiple times per requests (this is the N+1 problem). Really good tools for this are Debugbar and Telescope.

If the page is running aggregate queries over large data sets, then there's a limit to how much they can be optimized. You might have to re-think the solution. You might use caching or create aggregate tables. There's no magic wand that solves every problem. You have to put in the work and figure it out.

1 like
jlrdw's avatar

@AzizFatkhuRohman

every data make paginate

You aren't using something like data tables and loading too many and trying to paginate in the front end are you? If that is the case pagination should take place on the back end.

But just something to check.

Please or to participate in this conversation.