Talk about back-end technology trends in 2018

  coroutine, golang, node.js, php, swoole

Today is too busy, write less and add later.

Asynchronous mode

The Go language is becoming more and more popular, and many large Internet companies are turning back to GO. Dubbo, a well-known service framework in Java, also announced the transformation of asynchronous mode. This is a big trend. Asynchronous mode has been verified and approved by the market.

On the choice of Web server, most people began to choose asynchronous non-blocking Nginx rather than synchronous blocking Apache several years ago. It is because asynchronous programs like Nginx have better adaptability and concurrency. Now in the back-end business development and programming, the team with strong technical force has begun to switch technology stack from synchronous mode to asynchronous mode.

There are many defects in synchronous blocking mode, such as weak concurrency, poor adaptability and slow requests, resulting in unavailability of services. For example, in the scene where a third-party API is called in the background interface, the effect of synchronization mode is very poor. In the past, fewer and fewer people used synchronous blocking mode frameworks developed in Java, PHP, C++, Python and Ruby languages.

Node.js

Although Node.js is also very popular and popular, it is still rare for enterprises to use Node.js as the main programming language for the back end of the company. C++, Java, PHP, Python languages also have some similar schemes, including Swoole-1.0, which is also based on asynchronous callback mode similar to Node.js

The essential reason is the technical scheme of asynchronous callback and some optimization schemes made on it, including Promise, Future, Yield/Generator, Async/Await, etc., which have changed the style and habit of program development. If these technologies are to be used, engineers need to learn how to use these keywords and functions.

Using these technical solutions is incompatible with existing programs.It can be said that the research and development cost is huge and it is difficult to make a smooth transition. This has affected the popularity of asynchronous callback in technology stack. This programming model is difficult for everyone to accept.

coroutine

The synergetic mode takes into account the maintainability of synchronous blocking and the high concurrency of asynchronous non-blocking. It will become the mainstream technical scheme in the future back-end development field.

Most importantly, the synergetic mode can run with only a few adjustments to the existing project code, and even can be fully compatible with the old project. Only the frame layer is required to be compatible. This allows the team to make a smooth transition.

Using synergetic mode, developers do not need to learn additional keywords and function usage at all. The coding style is exactly the same as that in synchronous mode.

Of the various synergetic technologies,GOIs the most dazzling one. Synergy, channel, static language, performance, rich compilation, rich standard library, ecological integrity, Google, etc., have too many advantages.GO language, I think, is the most worth learning among all programming languages at present..

Swoole 2.xLet PHP, a 20-year-old backstage programming language, also have the ability to collaborate. Compared toGoThis kind of technology,PHP + SwooleThe technology stack is more suitable for fast development, fast iteration and business-driven scenarios. After all, dynamic languages are still more flexible and efficient than static languages. AndGoIt is more suitable for writing system-level software and core business.

In 2018, I refactored the swoole framework, a very old project with low-level support.Swoole 2.xConcorde mode. The main reason is that many projects within the wheel company are based on this framework, especially the service layer all uses the swoole framework. We hope that the business code will not change line by line, and we can switch to the coordination mode with one click. Theoretically, other synchronization blocking PHP frameworks, such as Laravel and YI, can only modify the underlying compatibilitySwoole 2.xCoordination, to achieve seamless switching of project code coordination mode.

After using synergetic process, the performance, concurrency and stability of the whole system have been greatly improved. In the past, the problem that the entire server was stuck due to a slow request on the line did not exist.

PHP & Swoole

Although Swoole 2.0 has a history of less than two years, it is still a long way to Go compared with the 10-year cultivation of GO language. However, PHP+Swoole still has many advantages over static languages such as GO. PHP is simpler and easier to use. PHP is a dynamic language and is more flexible to use.

Of course, if it is a new project or recommendedSwoftThis is specifically forSwoole 2.xThe framework, which has less historical baggage, has better stability.

Now that we have Swoole 2.0, we are still confident about PHP’s future.