Server response time (TTFB - Time To First Byte) - the time until the first byte (network packet) of the site page is received after the request is sent from the client (for example, from the browser).
This is a complex metric, primarily depending on what operations are performed on the server while the request is being processed. Long response times can be attributed to dozens of factors: application logic, slow database operation, routing, software platform, libraries, lack of processor power or memory.
To check that the reason for the increased server response time is the internal processes of the site (scripts, database queries), and not general problems with the server, the easiest and fastest way is to use the most primitive PHP script, for example, displaying results phpinfo.
If you first measure TTFB for a request that assumes the participation of site scripts (usually the main page of the site if it is dynamic), and then TTFB for a request to a primitive script, then the difference between the results obtained will approximately show the net running time of the scripts.
You can make sure that the database itself also works quickly by executing primitive queries to it, or at least simply by checking the opening time of any tables through phpMyAdmin.
To reduce the server response time, the site developer (or an involved third-party specialized specialist) should independently analyze the operations performed on the site when processing requests and explore the possibility of their optimization.
The most direct approach is to log scripts. That is, in the scripts that are executed every time the site is loaded, put down breakpoints in which to mark the time it took to process a particular piece of code. Examples of outputting the processing time of the script can be found in open sources on the network (for example, here).
If there are delays associated with database queries, you should:
On the hosting side, the following tools can help reduce server response time to some extent: