Middleware

Middleware Overview

The middleware is a software layer which goal is to enable communication and management of data for distributed applications. In the case of the deepsy platform the middleware performs a key role allowing to communicate and share different types of information between the services and the client applications. The middleware provides an abstraction layer ensuring a fast and easy communication between the different actors. The challenges that may arise when performing this communication are listed hereunder:

  • There can be a large set of client applications.
  • Client applications may join and leave the network arbitrarily.
  • Client applications must share a single eventually-consistent state.
  • Any client application can get/set any parameter or configuration at any point in time.

Taken into account these considerations, the middleware approach that has been designed for the deepsy platform is shown in the next schematic:

middleware.png
Middleware Schema


Client

The client side, represented by the API, has two critical components that handle requests and responses:

  • Dealer:

The Dealer component is responsible for initiating requests to the server and processing the responses it receives. Whenever an API needs information or wants a specific action performed, the Dealer sends a structured request to the appropriate service.

  • Subscriber:

The Subscriber component, on the other hand, is tasked with processing any publications or notifications sent by the server. Instead of waiting for a direct request, the server can publish data updates asynchronously, which are then received by the Subscriber component of the client API. This allows clients to receive real-time updates on specific events or data changes without needing to repeatedly request information. Service (Server) Components:

Server

On the server side, each service also has two essential components that manage communication with clients:

  • Router:

The Router component handles incoming requests from the clients. It processes these requests and, depending on the type of request, either retrieves or generates the required data, then sends the appropriate response back to the requesting client. This ensures that every client’s request is efficiently processed in a controlled and organized manner.

  • Publisher:

The Publisher component allows the server to send information asynchronously to clients that are subscribed to specific updates. This is particularly useful for broadcasting real-time data, like status updates or event notifications, to multiple clients simultaneously without waiting for individual requests. The Publisher thus enables efficient, one-to-many communication, allowing clients to receive critical updates as soon as they are available.

middleware_clients.svg
Interaction of several applications using a API to communicate with a service

Technologies

As it can be observed in the previous figure, the communication is performed via TCP/IP protocol, which in this case is carried out by means of the ZeroMQ library. ZeroMQ is a high-performance asynchronous messaging library that serves to communicate separate and often complex programs beyond the services available from the operating system. This philosophy favours the creation of a customizable middleware, which is the case.

The middleware’s communication relies on two key technologies:

  • Protocol Buffers (Protobuf):

Protocol Buffers, or Protobuf, is used to serialize messages. This means that the data being sent is converted into a compact, efficient format that can be quickly transmitted and easily decoded by the receiver. Protobuf ensures that the content of messages (i.e., "what is sent") is structured and consistent across various services, which is essential for interoperability and data integrity.

  • ZeroMQ (Zeromq):

ZeroMQ, often referred to as Zeromq, manages the communication protocol itself, dictating "how messages are sent" across the platform. ZeroMQ is a high-performance messaging library designed to support scalable and flexible communication patterns. In deepsy, it enables efficient and asynchronous data exchanges between clients and servers, supporting both request-response interactions and asynchronous updates.