Hi everyone, I'm Codemaster Pioneer.
In most business scenarios, PHP has not yet reached a performance bottleneck, and yet the MySQL database has collapsed. But we are always indiscriminate, a brain attributed to the reason is that the PHP language does not work, whenever I encountered this situation I will sigh to PHP's life is really bitter ah. PHP as a good open-source programming language, in the programming language community has been enjoying the reputation of "PHP is the world's best language," which makes PHP pretty boy to raise a family and live a well-off life, but when encountered some performance problems, it was crazy spit out. However, when it comes to performance issues, it gets a lot of flak, and it's really a thankless job. Of course, I believe that this kind of criticism is in the minority, and that the vast majority of people will still look at the PHP language in a rational and fair manner, and when they encounter a problem, they will carefully analyze the cause, find out what the problem is, and solve it, so that PHP can shine in its own light.
I remember in my previous work experience, using ThinkPHP framework to develop the company's internal ERP background system, many cases are the database slows down the user's access speed, such as the development of a number of financial data reports, these interfaces are often aggregated data from several data tables, the left connects to a table, the right connects to a table, not moving, but also to engage in a full connection, which can not be slow it. Not only that, there is a SQL statement in an interface to the query are nested in several layers, a variety of sub-queries flying all over the place, so the current state of the code is simply miserable, the amount of data is small when it can be used will not affect the user's experience, when the amount of data up the interface is often to engage in a timeout, the database logs are full of slow hit. In my impression there is a most impressive example, there is a speed sell pass product editing function, a page needs to be able to edit dozens of products at the same time, this is the so-called batch editing, and each product details of the data in particular, but also includes a lot of pictures, each time to load these data and pictures on the half-day, this function is the most used by the largest number of people, the number of times used the most frequently, but also the most being spit on the most. If there are friends who have developed similar features, they may have a more profound feeling.
There is also a script to run asynchronous task scenarios, due to some reports with the interface is really can not get out of the way, then the way to use the script to calculate the timing. But at that time, because of our data volume is relatively large, are millions of millions of levels, single-process running data is too slow, in order to enhance the efficiency of the direct dry on the PHP multi-process. At that time, we were still full of joy Fork process, a start script is concurrent dozens of processes, the results of the reality is to give us a blow to the head, AliCloud MySQL database monitoring system alarms one after another, on the cloud console to take a look at the eye, the CPU directly dry to 100% of the full-loaded operation, ERP backend system can not be accessed normally. We were scolded by the technical boss for what kind of airplane you are doing, and we were scared to kill the script process by Kill command. Now, some of you may wonder why asynchronous scripts can affect the ERP backend system. The reason is that most of the PHP guys have the habit of modifying the code directly on the online environment, of course, this kind of thing is not an exception in our case haha, and sometimes even become the norm, the feeling is how to facilitate how to come. All businesses share the same database, which affects the ERP backend system.
Talking about my previous experience, I can see that it's not that PHP doesn't work, it's that the database is broken because I didn't use PHP correctly, and it doesn't make sense to blame the language itself. Often performance bottlenecks occur first at the database level, such as certain queries not hitting indexes, too many nested subqueries, long transactions causing deadlocks, too much load from concurrent operations, etc. In general, in my experience, it was not PHP that was the problem. In short, in my experience, the PHP language out of the performance bottleneck scenarios still account for a small number of exaggeration can be said to be almost no ha ha, may be my seniority is not yet shallow, but then again, everyone's experience and my experience should be similar. Finally, I hope that you can spend some effort in the database level, rather than dwell on the language in the end, if the database is not, then what language is a waste of time, I hope that this point we can have the appropriate consensus. The content of this sharing ends here, I hope you can be inspired.
Thanks for reading, personal opinion is for reference only, welcome to express different views in the comment section.
Welcome to follow, share, like, favorite, in the watch, I'm the author of WeChat public number "code farmer forefather".