Comparison between client-server model and producer-consumer model in data communication

15 Sep 2024 at 23:00
Ixxat
Comparison between client-server model and producer-consumer model in data communication
The client-server model offers central, request-based communication, while producer-consumer provides decoupled, event-based transmission. CAN uses producer-consumer for efficient, scalable, and decentralized communication.

The client-server model and the producer-consumer model play a central role in the data communication and network architecture. Both models offer different approaches to data transmission and data processing, which have their own advantages and disadvantages, depending on the use case. This blog post aims to provide an overview of these models and to highlight their application in the context of Controller Area Networks (CAN).

The client-server model and producer-consumer model are the most important paradigms of data communication. While the client-server model always describes a one-to-one communication relationship between a client and a server (even if several clients are possible), the producer-consumer model describes a one-to-many communication relationship between a producer and one or more consumers. All modern data communication concepts of industrial automation support both the producer-consumer model and the client-server model.

The following image shows the process of a confirmed service in the client-server model in the form of a sequence diagram. The vertical lines symbolize the local or remote layers of the OSI model of both involved participants, while the diagonal lines symbolize the time-dependent transmission of protocol data units via the transmission medium. A service request at level 7 could, for example, be the request to read a variable in a remote participant. In this case, the client participant would be sent the requested variable value with the service confirmation upon successful completion of the service.

 

Sequence diagram of a confirmed service in the client-server model of data communication.

Sequence diagram of a confirmed service in the client-server model of data communication.

 

Communication services where a participant provides other participants with data unprompted or following a
previous, one-time request (subscription), for example in the form of a multicast or broadcast message, are
described by the “producer-consumer” model (see the following figure). The services provided by the producer (generally the provision of data) are offered to other participants via a service notification and can be accepted (consumed) by these participants or can be ignored. Since the producer normally does not know the consuming participants, a service confirmation is not useful. This model describes, for example, the transmission of CAN messages.

 

Sequence diagram of a service request in the producer-consumer model.

Sequence diagram of a service request in the producer-consumer model.

 

Model comparison

Communication flow

  • Client-server model: The communication is often request-based here. In other words, the client initiates the communication via a request to which the server responds.
  • Producer-consumer model: Communication is triggered by the production of data, whereby the consumer is waiting for new data to arrive in order to process it.

Scalability and flexibility

  • Client-server model: Scalability can be achieved by adding additional servers or through load sharing. However, the flexibility is limited by the central nature of the server.
  • Producer-consumer model: This model offers a high level of scalability and flexibility, since producers and consumers can be scaled independently of each other.

Fault tolerance

  • Client-server model: Due to the central role of the server, its failure impairs the entire system. 
  • Producer-consumer model: Decoupling producers and consumers can lead to a higher fault tolerance, since the failure of an element does not impair the entire system to the same extent.


Use in the Controller Area Network (CAN)

For basic communication, CAN uses the producer-consumer model. This allows for an efficient transmission of messages between, for example, different control units (ECUs) or sensors in the vehicle without a central server. Each control unit can function both as a producer and a consumer of data, which allows for flexible and decentralized communication. The data generated by producers (control units or sensors) is sent to the bus without addressing a specific consumer. Consumers (other control units or actuators) listen to the bus and process the data relevant to them. This architecture allows for an efficient and flexible data transmission in vehicle networks, since any node in the network can call up messages that they need. This reduces the level of complexity of data transmission and increases system reliability.

 

Summary

While the client-server model offers a central, request-based communication structure, the producer-consumer model is characterized by its decoupling and event-based data transmission. In CAN systems, the producer-consumer model works well with the decentralized and robust nature of the network by allowing flexible and scalable communication between different components.