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.
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?
@jaseofspades88 thanks for your answer
Agree with @jaseofspades88 , a good database model with proper indexes and well written queries, and you should be good for a shitload of users.
@Tray2 what do you can recomended DBMS the best for laravel?
@AzizFatkhuRohman I would go with MariaDB or MySQL, but you can also use PostrgreSQL, it doesn't really matter.
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.
@JussiMannisto what do you can share your github for i learn or recomended channel youtube?
@AzizFatkhuRohman You're already on the right website. There's tons of videos here on many topics, including the ones I mentioned.
@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.
@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.
@AzizFatkhuRohman You need to check your queries and that you have the proper indexes.
Here are a few tips.
- Never fetch more columns than you need.
- Never use php to filter data.
- Try to avoid n+1 issues.
- Make sure to have indexes on columns that you filter and sort on.
- Make composite indexes instead of single column indexes when possible.
- Make as many indexes as you need, but as few as you can get away with.
- Get a subscription here and watch https://laracasts.com/series/eloquent-performance-patterns
@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.
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.
@Tray2 thanks brad for your answer
@JussiMannisto thanks brad, i will trying lern more
Please or to participate in this conversation.