The author | Zhao Yuying

The Linux Foundation recently announced the creation of the Reactive Foundation. Reactive is familiar to developers, especially Node.js developers, but few are aware of the impact it has on development. InfoQ was able to get an exclusive interview with Lei Jul, a senior technical expert at Alibaba who has promoted Alibaba to become a founding member of the Foundation, to learn more about the background of the Reactive Foundation and how it promotes development.

What is the Reactive Foundation?

Recently, the Linux Foundation announced the launch of the Reactive Foundation, which aims to accelerate the development of architectures for building the next generation of web applications. The foundation is made up of initial members including Alibaba, Facebook, Lightbend, Netifi and Pivotal. Involves successful open source specifications Reactive Streams and RSocket, as well as programming language implementations. While the Reactive Foundation is new, Reactive, or responsive programming as it is often called by developers, has been developing for years. Reactive has been on the radar since 2011, when Microsoft built support for Reactive into the.NET Framework 4.0, called Reactive Extensions. In 2013, RxJava, as it is known to Java developers, was released. Reactive then took off, with RxRuby, RxJS (reactivex.io/ is available to interested developers), and more. In the process of technology development, major manufacturers have also started to follow up, such as Reactive Manifesto, Akka of Lightbend, Reactor project of Spring, Spring Reactive Web, etc. The emerging micro-service frameworks are basically Reactive. Vert.x, Micronaut, etc. A lot of developers think of Reactive as a development package, such as RxJava integration in Android and Reactive Web in Spring. However, the advent of RSocket extends Reactive to distributed scenarios, allowing all applications to be connected through Reactive and RSockets. In terms of why Reactive has been adopted so quickly by developers, there are two typical values:

  • Non-blocking and high concurrency: Reactive is based on asynchronous message communication, which is similar to the Event Loop design of Node.js. Such applications do not have synchronous blocking and have a high throughput rate, which improves system performance. Previously, developers used thread pools to achieve concurrency, but now through the Actor message model, it eliminates the waiting of acquiring threads, reduces a large number of threads switching, and improves CPU utilization. In addition, non-blocking and high concurrency are particularly important to customers on the cloud, where improved CPU utilization and QPS directly mean lower bills;
  • Functional programming paradigm: Functional programming is becoming increasingly accepted by developers with thread-safe and efficient execution, but connecting these functions together requires paradigms and frameworks, and that’s what Reactive does, such as the standard Reactive Streams specification. The related development framework RxJava, Reactor, etc., can make the function programming easier, and the Code is uniform style, easy to read at the same time, Code Review is also very easy. Just as there are Servlet specifications in Java, there are many Web frameworks to simplify Web application development. If you see filter, map, flatMap, subscribe calls in your code, you are basically Reactive.

The Emergence of the Reactive Foundation will undoubtedly maximize the value of this technology in the future. According to Thunder, the whole thing started at the end of 2018. At the time, Alibaba was working with Netifi, Pivotal, and FaceBook on rsocket-related open source products. Although the word Reactive is often mentioned, relatively few developers are aware of it, and several companies feel the need to get more developers aware of the technology, leading to the idea of the foundation. Thunder roll said:

The whole preparation process took less than half a year, mainly with the support of Netifi and Pivotal. Although many people don’t know Reactive very well, many people in the Linux Foundation have a good grasp of the technical direction. So the Creation of the Reactive Foundation was completed in less than six months.

Most developers are familiar with these startups, such as Pivotal, which maintains development for the Popular Spring Framework in the microservices space. After that, the companies will work together with the foundation. Pivotal is focused on blending RSocket with the Spring ecosystem, Leroll said. Netifi is the core development team of RSocket SDK and has its own commercial product of RSocket Broker. Facebook is also committed to the development of RSocket. Rsocket-cpp and Rsocket-JS are mainly maintained by Facebook engineers. Meanwhile, Facebook is actively promoting the implementation of RSocket. Lightbend may be a stranger to many developers, but it is the company behind the Scala language and a pioneer in responsive programming behind the Akka platform. Alibaba mainly focuses on the development of RSocket and pushes the distributed development to the next level based on Reactive and RSocket. Meanwhile, Alibaba is actively developing its internal RSocket product, which will provide services for customers on the cloud. The starting point of the Establishment of the Reactive Foundation is to promote the development of Reactive Streams and RSocket, which has great guiding significance for the subsequent development of Reactive products and ensures that these Reactive products are compatible in TERMS of API and protocol. This is very important for the end developer. Specifically, the Reactive Foundation will first promote the implementation of the RSocket 1.0 specification, including SDK development for various languages, which is a huge and tedious work that requires the coordination of various languages, testing and performance. For developers, the Reactive Foundation will bring a lot of value, such as continuous specification evolution, SDK development, documentation, conference support, as well as being a window into the development of Reactive products.

Is Reactive changing the way we do development?

In fact, the emergence of Reactive has impacted many existing architectures, such as event-driven design, streaming processing, Service Mesh, no network dependency, security, etc. Accordingly, the development mode will also change. More and more frameworks are starting to fully support Reactive, such as Spring WebFlux and Spring Data Reactive Repository. Database operations are fully Reactive through R2DDBC. Various NoSQL products, such as Redis and MongoDB, already support Reactive; RPC and HTTP REST apis under the influence of RSocket may also change the way developers think about distributed communication. The most typical of these changes and impacts are code writing and distributed communication.

  • Code writing: Our previous procedural code will be replaced by functional programming and Reactive paradigm. A large number of if else, NULL judgment, for loop, try/catch, etc. in the previous code will be greatly reduced, and various standard operations of Reactive will be replaced by simpler and clearer. The amount of code is also significantly reduced.
  • Distributed communication: Before distributed development, we paid much attention to communication details and concurrency processing. This is the core, and the intervention of Reactive and RSocket will reduce the development threshold to a minimum. You hardly need to care about the low-level details of communication, the number of concurrent threads processing, break protection, etc. Reactive allows you to do all of this with rsockets. You might just need relational interface design and data serialization. Now the application is more and more pursuit of extreme performance, CPU, GPU and FPGA all on, if there is no matching efficient communication protocol, then the performance will be discounted a lot, and all this RSocket can help you do, and more simple and elegant, we will introduce RSocket later.

Even if developers aren’t looking at Reactive at the moment, the tide is already rising. At the same time, there are a number of technologies that are integrated between Reactive and Java that make Reactive more mature and stable:

  • Reactive Frameworks: RxJava, Reactor, Akka, Kotlin Coroutines & Flow
  • Web Frameworks: Spring WebFlux, vert. x, Micronaut, Helidon
  • Data layer: Spring Data Reactive supports database, Redis, Cassandra, MongoDB and so on
  • Communication layer: RSocket, Reactor Netty, Reactor Aeron, Reactive Dubbo
  • Integration: Reactor Kafka, Reactor RabbitMQ, RocketMQ, etc

Today, more and more developers are getting used to developing applications based on cloud platforms. As mentioned above, the growth of Reactive will also play a big role in the growth of the cloud native space. In the interview, Lei revealed that cloud native allows applications to be independent of the underlying architecture and remain neutral, thus running on the underlying architecture of different cloud vendors. However, this approach does not solve the problem of how applications communicate with each other. While there is API-based collaboration, there are no specific API requirements, especially for message-based asynchronous communication. The most common communication between applications today is RPC and HTTP REST apis. Both are perfectly fine for request/ Response communication, the HTTP REST API has some performance issues, but overall is fine. However, these technologies are also moving to Reactive. For example, Spring’s RestTemplate is moving to WebClient, and gRPC has its counterpart Reactive gRPC. For new architectural designs such as Streaming, Event Driven, IoT, and two-way communication, traditional RPC is a bit inadequate, which is exactly what RSocket is good at. The RSocket protocol was developed over a very long period of time and, of course, borrowed ideas from other protocols, culminating in the 1.0.0 version that developers see today. RSocket protocol can be said to be a perfect version of binary asynchronous message communication, which overcomes some problems in the previous protocol design, such as the way of Client/Server conversion to role equivalence; Pub/Sub changed to more flexible Request/Stream; Metadata and data separation to provide more flexible message routing and message encoding; Pluggable transport layer, support TCP, WebSocket, UDP/Aeron, RDMA, etc. Supports multi-language access, such as Java, Kotlin, Node, C++, Golang, Python, Rust, etc. RSocket will be built into the Spring Framework in version 5.2. Spring Boot version 2.2.0 is also the first to support RSocket. Spring Security and others support RSocket. As Michael Dolan, vice president of strategy at the Linux Foundation, points out, Reactive’s message-driven approach enables the resilience, scalability, and responsiveness required by cloud native applications, all without being affected by their underlying infrastructure. In other words, by leveraging the capabilities of Reactive, developers can achieve the flexibility, scalability and responsiveness that Reactive claims to achieve without relying on cloud vendors or the Infra layers. It can be said that cloud native focuses on the external aspects of the application, such as packaging, deployment, operating environment and monitoring, while Reactive focuses on the internal aspects of the application, such as more efficient code operation, more natural communication between applications, flexibility and self-recovery.

Alibaba Reactive practice and open source plan

As a founding member of the Reactive Foundation, Alibaba has been known to use the Java programming language internally and to accumulate a large Java technology stack. However, According to Lei Jul, some of Alibaba’s internal products have been Reactive for a long time, such as Dubbo, known to developers, which is integrating Reactive and RSocket. However, there are still many problems to be solved in the process of Reactive, such as SDK bugs and adaptation to various internal architectures. The biggest problem, according to Leipzig, is how to adjust blocking to non-blocking methods, such as database operations and non-asynchronous RPC calls. As a member of the Foundation, Alibaba will share its experience in internal Reactive with the developers who need it. The main contribution will be RSocket, mainly the integration of distributed Reactive with the cloud, because Alibaba has made a lot of contributions in security, performance testing and SDK development. At the same time, the features and multi-tenant support on the cloud make it easier for users to use the cloud. Internally, Alibaba also actively promotes product Reactive and adds support for RSocket. At the same time of technological innovation, Alibaba is also focusing on solving the cost problem. If developers have listened to the RSocket speech at QCon 2019 Beijing Conference, they may be interested in Netifi’s RSocket development to help enterprises achieve micro services. Under the scenario of 40,000RPS, While Istio costs $3,495 per month, Netifi costs $388 per month and has impressive 10-fold performance improvements, which is certainly attractive to any enterprise. Six months since that presentation, the newly launched RSocket Broker now supports multi-tenant features rather than an exclusive approach, reducing costs by another 50% to 70% to less than $200 per month for a 40,000 RPS scenario. While Alibaba’s Reactive process is ongoing, the cost value is already being realized. Lei said that the overall performance of the application is improved and the direct change is less cost, which should be the same for other users.

conclusion

For Node.js developers, it’s all about Reactive right now, and for Java developers, especially the back end, it’s still early days. The biggest problem is that Reactive requires users to adjust their code. That’s the biggest problem, and it takes a long time for developers to get used to it, understand it, and use it. The integration is also incomplete, and although Spring 5.0 includes Reactive, not all of it is supported. Spring 5.2 will have full support for Reactive from the ground up, and developers will see how easy it is to develop Reactive and RSocket once the release is released, According to Ray. On the open source side, Alibaba is developing an RSocket Broker product, which it hopes to launch soon. This product will enable more developers to use Reactive to help cloud native applications solve asynchronous communication problems, making it simpler, more efficient and secure for all organizations and developers, while greatly reducing costs. Lei Juan is a senior technology expert at Alibaba, currently working in Alibaba’s Silicon Valley office. I have worked in Alibaba for more than 10 years and have 20 years of Java development experience. I have participated in many internal projects, from logistics and Wangpu to middleware of international department. At present, the main research method is Reactive and RSocket, which can be brought into application development to build a simpler and more efficient architecture design. Ray volume is also the developer of RSocket, focusing on RSocket Broker development.