(1) Introduction
This article attempts to explore various aspects of PHP program acceleration, including necessity and specific measures to be taken from different angles. I hope it will help readers understand PHP program acceleration and apply it in practice.
(2) Does it need to be accelerated?
This question sounds a bit silly. In this day and age, few people would doubt that time is the most valuable asset, especially in the business market. The faster the program executes, the more time users save, so that your program can use less time and server resources to serve users, thereby generating more benefits.
I think for most people (including myself), many WEB projects are completed in a very tight time, usually without careful thinking and rigorous testing. When starting a new WEB project. Many people are building "fast and messy" applications and lack the necessary time to adjust and improve the code. At this time, optimization and acceleration are the measures we must take.
However, it should be noted that not all programs need to be accelerated.
Optimizing the completed code is a waste of time. The best way is to pay attention to the efficiency when writing the code, and then only optimize the parts that really need to be optimized after completing the project. Generally, a program will only have a few bottlenecks that affect speed. If you find them and solve them, the program will run well. In addition, when encountering low execution efficiency, you must first use a big-picture perspective to find out the main factors affecting efficiency, rather than sticking to the details - such as excessive data volume, insufficient server bandwidth, or low hardware configuration. In cases where optimizing the code won't help.
In addition, when you don’t find any obvious signs of slow execution in the program, don’t be too picky and waste time trying to improve some very detailed code. You can use this time to complete another project or complete an extension to the original project. Of course you can laugh at me for not being responsible enough and not doing my job to the best of my ability, or I can say that you are a perfectionist.
To sum up, before you decide to speed up your PHP program, ask yourself whether it is necessary.
(3) How to speed up?
Before answering the question "How to speed up", you need to answer the following two small questions:
1. Which part of your program is slow?
2. From what aspects can PHP be considered for acceleration?
Obviously I can't give you the answer to the first small question, but I suggest you use the "test script execution speed" method to solve it. Only by identifying the bottleneck that limits speed can we consider how to solve it.
My approximate answer to the second little question is: code optimization, compressed output, content cache output, function cache output, acceleration/caching tool software. If you know more please tell me.