: Is the time PHP takes to render a page and serve it to the client ever a problem? PHP is a ubiquitous language that among other things allows a server to render a webpage on request and
PHP is a ubiquitous language that among other things allows a server to render a webpage on request and serve the resulting HTML to the client.
For example, the served page might be different for different clients and the server "builds" the HTML per request.
I assume that this in general is practically instantaneous.
But can this be a problem for more complex webpages?
(Example: if by rendering a page the server needs to acess a third party service that may have its own latency)
If so, what solutions can we implement to avoid this problem?
More posts by @Steve110
3 Comments
Sorted by latest first Latest Oldest Best
This was an issue...20 years ago.
Sure, if you have other major issues such as poorly written php code or a server that has some serious problems with load and resource management it will eventually be problematic and manifest itself as "slow loading php pages". But the same would be true if you were using any server side scripting or calls to the databases; or really serving ANYTHING at all under those conditions.
I code exclusively data-driven php webpages on everything right now; and the php compiling and execution is NEVER an issue or slowdown for me.
Loading large resources such as jquery, css libraries, bootstrap, etc can possibly be an issue. But if you load them using async (whenever possible) then your page will continue to load and not wait on them either. And they will most likely be cached after the first time they're loaded, so zero time after that as well.
In short: While there are a lot of things to worry about when designing your web site and user interface, properly written PHP code is not one of them.
PHP can indeed be slow at times depending on what kind of PHP is being used server side.
Computers can compute and render data very quickly, but there can be latency in the event that the server speed is not quick enough to instantaneously compute the request.
This can happen when the amount of variables stored uses up a substantial amount of RAM, or when there are simply too many processes and requests for the CPU to be able to handle all of the information.
It's also very common for PHP language to be utilizing various file_get_content and file_put_content requests. And the PHP script cannot continue processing further code until the server delivers or receives the file_get_content or file_put_content request. In other words, if it takes 2 seconds to load a page through file_get_content, that will be an extra 2 seconds that is required for your site to render and load.
Is the time PHP takes to render a page and serve it to the client ever a problem?
Without finishing reading the body of your question, I have the perfect answer.
YES
This is because all of the processing time required to present the page to the user from the moment the user hits the enter key (from typing in a URL or clicking a link) is of supreme importance. It's so important that if the amount of time is too long, the guest will think the site is broken.
The process time can worsen when alot of people are connecting to the server at once because the computer will have to handle each request along with the processing of each request and if there are way too many people connecting, then some people might experience delays before any part of their request is processed. This depends on the processing power of the server.
There is a term that is valuable to you. It's called "Time to First Byte". It means the amount of time it takes for people to see any part of the page from when they first request it. webpagetest.org can measure this value for you when you run any website through them. You want to keep the value as small as possible (roughly 20 to 50ms if pages are served locally, or up to 1ms if pages are served to a far away place with poor internet connection).
Now if you're looking for a way in which the time the PHP processor takes to render a page is meant to not be an issue, then you can either:
Ditch PHP and use another server side scripting language, but then you'll have to factor the processing time of that language.
Look at other factors that could cause significant rendering times, such as the javascript used in todays sites to change the entire appearance and/or functionality of the site.
Even if you take one of the above two options, you still will want to factor the time the server processes requests as a whole, even if it means the PHP and/or any other server scripting languages that are used to process the requests for the guests.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.