The use of this law in the design of composable architectures can significantly improve the interoperability, scalability, maintenance, and resilience of composable architectures. This is especially valuable in architectures that require high precision and adaptability, such as in industry or urban management.
Table of contents
Open Table of contents
Context
Postel’s Law, also known as the Robustness Principle, bears the name of its creator, Jon Postel, a pioneering American computer scientist. During the fledgling years of the internet, Postel was tasked with developing a rule that could ensure its stability and growth. His profound solution took the form of a simple yet influential principle:
Be conservative in what you do, be liberal in what you accept from others.
A Digital Twin must be designed to send or input data in a well-defined, standardized format. For example, when the system sends data requests to traffic sensors, it should specify the exact format and type of traffic data needed (like vehicle count, speed, etc.). This ensures that the data received is accurate and suitable for analysis. The system might also use standardized communication protocols (like MQTT or RESTful APIs) for these data exchanges.
On the receiving end, the Digital Twin should be flexible and robust enough to handle variations in data formats and structures from different sources. For instance, weather data from various stations might come in different formats or with varying levels of detail. The Digital Twin should be capable of parsing and integrating these diverse data streams, adapting to missing fields or different date formats, much like the online form that can handle various user inputs.
Apply Postel’s Law to composable architectures
Modularity and Flexibility
Composable architecture is based on the idea that systems should be modular, that is, built from independent components that can be combined in various ways. Using standard and well-documented data protocols and formats for sending data facilitates interoperability between different modules or components of the system. This allows the various elements of a composable architecture to communicate effectively, maintaining coherence and compatibility.
# Definition of independent modules
class SensorModule:
def collect_data(self):
# Code to collect data from sensor
pass
class ProcessingModule:
def process_data(self, data):
# Code to process data
pass
class CommunicationModule:
def send_data(self, data):
# Code to send data using a standard protocol
pass
# Integration of modules in a composable system
class ComposableSystem:
def __init__(self):
self.sensor = SensorModule()
self.processor = ProcessingModule()
self.communicator = CommunicationModule()
def operate(self):
data = self.sensor.collect_data()
processed_data = self.processor.process_data(data)
self.communicator.send_data(processed_data)
# Creating and implementing the system
system = ComposableSystem()
-
Conservative in sending: each module, when sending data to another module (for example, the SensorModule sending data to the ProcessingModule), must ensure that the data are well-formatted and follow agreed specifications. This ensures that the receiving module can process the data without issues.
-
Liberal in receiving: each module should be prepared to handle variations in the received data. For instance, the ProcessingModule should be capable of handling slightly off-format or incomplete data in a way that does not cause system failures.
Integration of Various Data Sources
A key feature of composable architecture is its ability to integrate and process data from multiple sources. The approach of being “liberal in receiving” aligns perfectly with this need, as it implies that the system’s components must be able to handle different data formats and adapt to variations in the received data. This is crucial to ensure that the composable architecture can incorporate and use data from various sources without compatibility issues.
def integrate_data(*data_sources):
integrated_data = {}
for source in data_sources:
# Merge data from different sources, handle variations
integrated_data.update(source.get_data())
return integrated_data
# Assuming we have different data sources
class WeatherData:
def get_data(self):
return {'temperature': 22, 'humidity': 60}
class TrafficData:
def get_data(self):
return {'vehicles': 200, 'delays': 5}
# Using the function to integrate data
weather = WeatherData()
traffic = TrafficData()
combined_data = integrate_data(weather, traffic)
-
Conservative in sending: when the composite system sends data requests to the sources, it should do so using well-established protocols and formats, thus ensuring that the sources understand the request and respond appropriately.
-
Liberal in receiving: the system should be able to accept and handle data in various formats or structures coming from different sources, like WeatherData and TrafficData, effectively integrating them without errors.
Robustness and Resilience
Composable architecture must be robust and capable of handling unforeseen scenarios. Being liberal in data reception prepares the system’s components to handle imperfect or incomplete data, which increases the system’s resilience. This ability to adapt and function efficiently in the face of data variations is fundamental in a composable architecture, where flexibility and responsiveness are essential.
def process_data(data):
try:
# Process data, handle possible errors or incomplete data
processed_data = complex_processing(data)
return processed_data
except (DataError, IncompleteData):
# Error handling to maintain robustness
handle_error()
return default_data()
data = collect_data() # This function could return imperfect data
safe_data = process_data(data)
-
Conservative in sending: the system should ensure that any data it sends to other systems or components are in a correct and complete format.
-
Liberal in receiving: the system must be capable of handling and correcting imperfect or incomplete data, as seen in the exception handling in process_data, which increases the system’s resilience.
Simplicity and Maintenance
Using standard protocols and formats simplifies the design and maintenance of systems. In a composable architecture, simplicity in communication between components is vital to facilitate the incorporation, removal, or updating of modules without negatively affecting the overall system.
import json
import requests
def send_data(data):
# Convert data to a standard format (JSON)
json_data = json.dumps(data)
# Send data using a standard protocol (HTTP REST)
requests.post('data-service/api/data', data=json_data)
data = {'sensor_id': 1, 'value': 75.6}
send_data(data)
-
Conservative in sending: when sending data, as in send_data, the system uses a standard format (JSON) and known protocols (HTTP/REST), ensuring that the receiver can easily process the data.
-
Liberal in receiving: although not explicitly shown in this example, the system should be able to accept responses in a variety of formats or even partially complete or erroneous responses, and process or handle them appropriately.