My website is slow and clicking on each menu takes a few seconds to go to the next page. What solution do you suggest? Is there something wrong with the Docker configuration?
What a few seconds mean?. 4 secs, 2 secs?. What is the speed that is supposed to be good for you?.
Did you check your host CPUs and memory activity?. Everything is good in that front?.
Next you need to profile. You have frontend, backend, Database. Where is the slowness? A query to the database?. Some processing in your lavarel, too much interaction in the frontend?. Network latency?
Hello,
Thank you so much for your reply.
It might take 10 seconds for a page to load. Also, no one is connected to this website yet and it is not overloaded with traffic. My server has 16 gigabytes and 4 CPU cores. When the container is running:
$ free
total used free shared buff/cache available
Mem: 16376552 2400212 7280180 1020 7034668 13976340
Swap: 998396 1328 997068
How do I know if this slowdown is related to querying the database or processing related to Lavarel or React?
Sometimes I get the following error when opening some pages, which is resolved by refreshing the page:
Yes, 10 secs is very slow, and once users start getting coming in, forget about it.
To find slowdown on the server side you can do a good old console log. Print the time to take to do a query call to the DB. Once is back if you are doing some processing with the return data, again measure the time of that processing. Also measure the time the request came to the server and return.
That should give and idea of any slowness on the server side, and tackle that issue.
On the client side, I don’t know very well react, but I heard it can slow down if there is too much re-rendering (a component change, made another component to re-render, that make another component to re-render, etc).
You’ll have to google how to profile react apps
Hello,
Thank you so much for your reply.
I have installed the MariaDB on the host and am using network_mode: host to connect to it. Does this affect the speed much?
You have to work with your developer if you wan to resolve the issue (no blaming). I mentioned doing a Profiling, but you will need a developer help for that.
Do an actual call that an application will do. For example calling this page I get this:
Notice that this speed will be much faster if you run the browser, since almost everything (specially javascript) will be already cached in the browser.
Use your browser Developer and show us an image of the network request.
Looking at your CPU image, why is Next.js together with PHP?. Next.js is a Node.js framework it does not need PHP. Next.js seems to be pretty busy doing something, it is calling PHP ?
Also I see MariaDB docker container and MariaDB in the host; which are you using?
Hello,
Thanks again.
Their website’s front-end uses React and their back-end uses Laravel.
I opened the website login page and waited a few minutes but nothing loaded:
You call to the login page, seems to worked fine. It made an ajax api request and return 200. The speed was 531ms which tell me your server is fast.
The second image is more interesting. You server is serving 2 javascripts files which are big in size main-app…js and layout.js taking 5.11s and 4.86s respectively. If I have to make a educated guess these are the files that your browser is processing before the user can see anything on the screen.
Notice like I said serving your server is just taking those file and delivering to the browser (no processing whatsoever). My understanding ideally those files shouldn’t be that big, ideally not more than 500k. I am not a React developer but I believe a developer can use tools to decrease the size of the files, and gzipped it.
Perhaps people here can give it some point how to to it.
Your server made another api call this time to user-current, returning 401 since probable you don’t have access to the app, taking 106ms of response time.
Your server is fine, a least for a single user. For multiple users you will have to do a load test to see how it behaves (number of users depend on the specification).