This is a creation in Article, where the information may have evolved or changed.
Today is too busy to write a little bit, back to add.
Asynchronous mode
The go language is becoming more and more popular, and many large internet companies are turning to go. The Java Circle well-known service session Framework Dubbo also announces the transition to asynchronous mode. This is a big trend, the asynchronous pattern has been verified and recognized by the market.
On the WEB server selection, a few years ago most people began to choose Nginx, not Apache. Now, with the programming aspect of back-end business development, the technology-strong team has started to switch the technology stack from synchronous mode to asynchronous.
There are many defects in synchronous blocking mode, such as weak concurrency, poor adaptability and slow request, which makes the service unavailable. such as: The background interface calls the third-party API scene, the synchronization mode effect is very poor. In the past, the use of synchronous blocking schema frameworks developed in Java, PHP, C + +, Python, and Ruby languages has been less and fewer.
node. js
Although node. JS is also hot and popular, it is still rare to see the Enterprise Use node. js as the main programming language for the company's backend. The C + +, Java, PHP, Pytohn languages also have similar scenarios, including the Swoole-1.0 is also based on the asynchronous callback pattern similar to node. js.
The essential reason is the technical scheme of the asynchronous callback and some optimization schemes on it, including Promise, future, Yield/generator, async/await and so on, which change the style and habit of the program development. To use these technologies, engineers need to learn more about how to use these keywords and functions.
The use of these technical solutions is not compatible with existing programs. It can be said that research and development costs are huge, difficult to smooth transition. Affects the application of asynchronous callback technology stack. It is difficult for everyone to accept.
Co-process
And the co-mode, which takes into account the maintainability of synchronous blocking and the high concurrency capability of asynchronous non-blocking. will be a mainstream technology solution for future backend development areas.
Most importantly, the co-mode requires only a small amount of adjustments to the existing project code to run and can even be fully compatible with the old project. Only the frame layer is required for compatibility. This allows the team to smooth the transition.
Using the co-mode, developers do not need to learn additional keywords and function usage at all. The coding style is exactly the same as in synchronous mode.
In the process technology, of course, the GO language is the most dazzling one. Co-op, channel, Static language, performance, rich compilation, standard library rich, ecological integrity, Google and so on, there are too many advantages. The GO language, personally, is considered to be the most worthwhile learning in all programming languages .
Swoole-2.x makes PHP the more than 20-year-old background programming language can also have the ability to co-process. Compared to the technology of Go, PHP + swoole technology stack, more suitable for rapid development, fast iteration of the scene. After all, dynamic languages are more flexible and more efficient than static languages.
2018 I reconstructed the Swoole framework, a very old project, with the underlying support for the Swoole 2.x process mode. The main reason is that there are many projects within the wheel company based on this framework, especially the service layer is all used swoole framework. We want the business code line to be unchanged, you can switch to the co-mode in one click. In theory, other synchronous blocking PHP frameworks, such as Laravel, YII, can be implemented only to modify the underlying compatible Swoole 2.x, to achieve the project code seamlessly switch the co-process mode.
The performance, concurrency and stability of the whole system are greatly improved after using the co-process. In the past, a slow request on the wire often caused the problem of the entire server to get stuck.
PHP & Swoole
Although Swoole 2 has a history of less than two years, there is still a long way to go in comparison to the 10 years of the go language. However, compared to the static language GO, PHP + Swoole has a lot of advantages, PHP is more simple to use, PHP is a dynamic language, use more flexible.
Of course, if it is a new project or it is recommended to use Swoft, which is specifically for the Swoole 2.0 framework, it has less historical burden and therefore better stability.
Now with the Swoole 2.0, we are still confident about the future of PHP.