-3

I have been given the job of a colleague who has resigned and I don't know where to start. I hope you can give me some hints:

It is about a CMS made from scratch (Javascript/jQuery/PHP/MySQL) which Lighthouse (Google Devtools) has given a performance score of 43 out of 100.

The page after logging into the CMS takes about 14 seconds to load. Following the Lighthouse report, I have made some changes that improve the loading speed but not too much. When I run the SELECTs directly on the database the response speed is good so I am starting to think that maybe it is the response of the server where the CMS is hosted that is slow. How can I check if the problem is in the performance of the hosting services or not?

Right now, the database does not have a lot of data but it is expected that in a few months it will have a lot more data because there will be many more users using the CMS. That is why I need to solve this loading time problem so that the CMS does not freeze when there are many more users. Knowing this, how do you detect in advance if the CMS has become obsolete and you need to change to something more sophisticated?

I know it's a lot of information to give but I would really appreciate your opinion. If you would also like to hand me the link to an article or discussion thread in addition to your opinion, that would be great.

Thank you very much!

1 Answer 1

1

A 14 second load time is indeed abysmal. Before you take any actions like switching the CMS, it would be good to identify why it is so slow. There might be hardware or software causes.

  • does the server code have unnecessary loops or similar inefficient algorithms?
  • is the server hardware overloaded? (e.g. high CPU usage, swapping, too many disk IOPS, saturated bandwidth)
  • is the server hardware failing? (e.g. a bad HDD)
  • are the database queries slow? (you already mentioned individual queries)
  • are there excessively many queries?
  • does the server code depend on other external service, or does it dispatch recursive requests to itself?
  • does the frontend code issue many sequential requests to populate the page instead of working asynchronously/concurrently?
  • does the frontend code have unnecessary loops or similar inefficient algorithms?

You already applied one strategy to locate the problem: testing parts in isolation. Another strategy is to run the software with a profiler: a tool that records how long every function is executed. This will let you locate those functions where most time is spent. Sometimes this is expected (e.g. functions that wait for a response from an external service), sometimes this suggests that the function is written very inefficiently.

If your frontend behaves like a SPA (in the sense that it issues requests to the backend in order to populate the user interface with data), you can use your browser's built-in profiling tools to take performance measurements. For your PHP backend, you can use extensions like Xdebug to collect profiling measurements. The profiling data is typically visualized as a flamegraph or aggregated as a table.

Debugging potential hardware issues is more of a sysadmin thing. My first step would be to SSH into the server and to watch the htop output while issuing a few requests. E.g. if these requests cause a CPU core to go for a sustained 100% load, that would indicate either that the CPU is too weak (unlikely unless its 10 years old or an old RasPi), or that the server code is written extremely inefficiently so that profiling should be used to locate the problem. If CPU load remains low during the requests, that would indicate that the problem is somewhere else, that the server software is spending time waiting for something to complete. That something might be disk I/O, network I/O, or a request/query to an external service.

That said: home-brew CMS are often something of an anti-pattern. Those are somewhat complicated software projects, so it usually makes little sense to develop your own solution, unless you have highly unusual requirements. In most cases, using an existing engine like Wordpress is the better choice, especially if the unusual requirements are negotiable or can be satisfied via a plugin.

1
  • whoah! thanks a lot!! I'll take a look at all that you say. You've given me a great starting point, thanks again.
    – ADM
    Commented Jan 13, 2022 at 15:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.