Introduction
Modern distributed applications rely heavily on publish/subscribe (pub/sub) systems to facilitate asynchronous communication between decoupled components. However, maintaining a scalable and reliable pub/sub broker traditionally requires significant operational overhead, including managing server clusters, load balancing, and fault tolerance. This paper explores a novel approach: building a pub/sub broker entirely on a serverless architecture using IBM Bluemix. By leveraging Function-as-a-Service (FaaS), the system achieves high elasticity while offloading infrastructure management to the cloud provider.
System Architecture
The proposed broker is implemented using three core cloud-native components:
- IBM Cloud Functions (FaaS): These execute the core matching logic. While FaaS is inherently stateless and short-lived, the system utilizes them for their rapid scalability.
- Cloudant NoSQL DB: This serves as the persistent state store, maintaining records of active subscriptions.
- IBM Watson IoT Platform: This acts as the underlying communication channel for delivering matched messages to subscribers.
To mitigate the latency inherent in database lookups, the authors implemented a local caching mechanism within the FaaS containers. By exploiting the "warm start" behavior of FaaS providers—where containers are reused for a short duration—subscription data is cached for 10 seconds, significantly improving performance for high-frequency matching tasks.
Matching Mechanisms
The system supports three distinct matching paradigms:
- Topic-based Matching: The standard approach where messages are routed based on predefined subjects.
- Content-based Matching: Messages are filtered based on specific key-value pairs within the payload (e.g., routing only if
temperature > 30). - Function-based Matching: This novel contribution allows subscribers to submit Turing-complete code to the broker. When a publication arrives, the broker executes the subscriber's custom function to determine delivery. This enables complex processing, such as Natural Language Processing (NLP) or image analysis, directly within the routing logic.
Evaluation and Results
The system was evaluated using a synthetic workload of 1KB publications across up to 352 subscribers. Key findings include:
- Elasticity and Cost: The broker scaled automatically to handle varying workloads. The entire evaluation, involving hundreds of thousands of function executions, cost approximately 4.23 Euro, demonstrating the economic efficiency of the serverless model.
- Performance: Average latency ranged from 5,000ms to 8,000ms. While higher than dedicated server-based brokers, this performance is suitable for many asynchronous use cases.
- Infrastructure Constraints: The primary performance bottlenecks were vendor-imposed limits, such as concurrent function execution caps and database lookup rates, rather than the architectural design itself.
Conclusion
This research demonstrates the feasibility of building complex, stateful messaging systems using stateless serverless primitives. While challenges such as vendor lock-in and unpredictable caching remain, the benefits of automatic scaling and extreme cost-effectiveness make serverless pub/sub a compelling alternative for modern cloud applications. Future work will focus on cross-provider portability and the integration of centralized, high-performance caches like Redis.
Summary updated