Evolution of Middleware
2024-12-01

What is Middleware?
Middleware is a system for transmission and temporary storage of data. Essentially it's the embodiment of a communication algorithm. Middleware is everywhere:
- In programming languages, the call stack is middleware
- In physical networks, the network switch is middleware
- E-mail is middleware too
Middleware sends messages between endpoints over transport using temporary storage. There are many combinations of the above, which means that the design space is very large. We'll briefly visit some interesting points in this space which correspond to successful designs.
Synchronous Middleware
Synchronous Middleware connects endpoints, attempting to hide messages and transport. The classic function call is synchronous middleware and RPC (Remote Procedure Call) are examples. RPC tries to make the request-response hidden and transparent to the application. NFS, SunRPC, CORBA, and gRPC are examples. The request-response can be explicit, as with REST, curl.
Here, the communication pattern is point-to-point and the application waits until the request completes. This can create big cumulative delays and even deadlocks. Also, the other side may be unavailable, which affects application logic. For correctness, every call site (if you are even aware of it) needs retry logic.
Asynchronous Middleware
Asynchronous middleware is more explicit. Both messages and transport are exposed to the application and the system focuses on routing messages. This approach offers more communication patterns, such as many-to-one and one-to-many. Messages can be routed, copied and stored, and asynchronous systems have much higher throughput and lower latency (due to pipelining).
It's conceptually easier to develop applications using RPC, but asynchronous middleware is more general and capable: you can implement RPC using it, but not the other way around. All of message-oriented middleware systems built over the years are an attempt to explore this part of the design space.
Message-oriented Middleware (MOM)
Message-oriented middleware (MOM) was developed around the 2000s in response to financial companies' needs. The main idea is to publish a message to a Message Queue (MQ) as temporary storage, from where it's delivered to subscribers. Once a message is sent to the subscriber, it's deleted from the queue. These systems have message rates in the ~100K msgs/sec range, with latency in 10s of microseconds. Typically, delivery is not guaranteed, so message queue should be viewed as a message switch. Successful designs were produced by TIBCO, Solace, RabbitMQ, IBM MQ, ActiveMQ, ZeroMQ, AMPS, 29West, the list goes on.
The limitation of MOM designs is usually found in lack of scalability, a single point of failure (the broker which keeps the queues), and in the somewhat unfriendly semantics of message queues which bind publishers and subscribers. This is where Data Streaming Platforms come in.
Data Streaming Platforms
Data Streaming Platforms appeared, in 2010s, developed in response to web-scale companies' needs. The main idea is to create a "dumb" broker that writes messages to append-only journals. The broker is not a "message exchange" and doesn't have "congestion policies". Instead, the data is reliably replicated to several locations, kept there indefinitely, and can be retrieved multiple times, until a retention policy forces its deletion. Such systems have many hosts, no single point of failure, message rates in the 1M-100M msgs/sec range. Latency is typically in single milliseconds to hundreds of milliseconds. The 800lb gorilla of this design pattern is Kafka.
A Data Streaming Platform represents in some sense the ultimate middleware because it has no arbitrary limitations, and it's very simple conceptually: it's just a set of append-only files. The simplest data streaming platform is just cat >> filename
on the publishing side and tail -f filename
on the subscribing side.
The main barrier to the use of data streaming platforms for applications is the complexity of implementation, not the complexity of the concept.
The "Holy Grail" of Data Streaming Platforms
So, what does a "holy grail" data streaming platform look like (other than cat/tail -f)? It has to have:
- Wire-speed throughput
- Be fast as a switch (single-digit microseconds)
- Support millions of topics and thousands of publisher/subscriber pairs in any combination
- Be available in multiple form factors (appliance, BYOC, container distribution)
- Support multiple standard protocols to work with existing ecosystems
- Have minimal knobs to tune