i have a restful project when make stress test with maximum 500 users the route return status:error i tried to optimize laravel query and decrease the amount of data which received at every request but the result of performance not shown
so the question how to optimize my proeject and what are helpfull tools i can use to make best performance as possible
- Replace whereHas and whereDoesntHave with whereIn & whereNotIn
- remove appends from model
- return used data only and remove extra data from responses
CodePudding user response:
There are a few critical parts that you should deeply check and do
- User SQL profiler to check which part of SQL script is slow, etc.
- Check and remove duplicate SQL queries.
- Use caching with Redis everywhere where it is necessary
- Cache the config, routes, etc. you can call the
php artisan optimize
command - Remove unused services from the config
- Optimize the composer
composer install --prefer-dist --no-dev -o
- Cache the results of non-often uneatable queries, e.g. if you have a categories you can cache them, and update the cache when categories are updated.
- Use CDN for static files, like images, JS, CSS files, etc.
- Big jobs move to the queue and use a queueing system where it is possible
- Use laravel Octane for increase performance
I can't suggest more without looking at the code, so I wrote only general things
CodePudding user response:
barryvdh/laravel-debugbar
is a great package for tracking execution time of each single query, memory usage and other information.