Hi All,
I am quite new to Laravel, I have a simple Laravel application which has 19 REST service endpoints which will be consumed by Mobile Application. I have tested the REST endpoints using J Meter to identify the concurrent users that I can have in my server. I have tested in two servers one had 512 MB RAM & Single core processor and I have ran the same load test on my local windows machine which has 8 GB RAM & 4 Core Intel i5 Processor. I am continuously facing different issues when I start the load test. My aim is make sure that application should work for at least 100 concurrent users. Below are the errors I got when I ran load test for a single endpoint - which always fetch one row from DB.
1. 100% CPU Usage - When I start the load test CPU usage spikes up to 100 % always
2. Throttle Values exceeds 50 - When I set concurrent users to 50 then I am getting Too many connections issue.
3. For 100 User - No Database selected - Some times I am getting error states "No Database is selected"
4. For 100 User - Failed to open stream
5. Some run has issues stating "Access Denied for the user to Database Forge" - I am not having any database called Forge, and not sure why the call is going to that database.
Can you please help me to pass this load test ? Happy to provide more information as well.
https://github.com/barryvdh/laravel-debugbar - check all your queries, make sure you use eager loading when needed rather than doing n+1 queries, check memory usage per request, nr of models loaded, etc.
Also make sure your server is configured correctly. There are plenty of tutorials out there. Use Redis for caching whatever you need. The list goes on.
What have you done to prepare Laravel for production? There are things you can do to give it a speed boost that you wouldn't want to do in development, such as caching the config files, routes, etc. There are artisan commands to do these things. https://laravel.com/docs/6.x/deployment
Do you cache queries/data, or is everything queried from scratch each time requiring full resources?