In our previous blog post on Salesforce Pub/Sub API, we explored how this API enables developers to build scalable and controllable integrations by leveraging event-driven architecture. The post also highlighted how Data Cloud leverages Pub/Sub API to solve large volume replication needs at scale, along with key features, benefits, and use cases when implementing Pub/Sub API for various integration scenarios.
In this blog post, we will analyze the performance of the event-based Salesforce Pub/Sub API compared to other API-based approaches. We’ll uncover why Pub/Sub API is the recommended method for scaling your system integrations.
When it comes to performance, the loose coupling of event-based architecture enables Pub/Sub API to scale easily and efficiently. By decoupling producers and consumers, each can scale independently, which enhances flexibility. Furthermore, events can be stored and processed later if a consumer experiences downtime, making the system more robust and resilient compared to tightly coupled systems. Additionally, support for features like bidirectionality and subscription flow control make Pub/Sub API even more appealing.
Bidirectionality and asynchronous processing: Clients can handle a large number of events without waiting for all events to be processed, improving throughput and resource utilization.
Subscription flow control: This allows flexibility in processing rates and the addition of more consumers without requiring changes on the producer’s end. Clients drive the rate of responses and can request more events at their preferred speed.
Pub/Sub API is ideal for large-scale systems with variable load patterns, enabling efficient system-to-system integration at massive scale through asynchronous communication. REST API and Streaming API are browser-adjacent APIs that are better suited for CRUD and data transfer operations. To provide concrete evidence, we went beyond theoretical concepts and tested the performance of different publishing options. We compared the publish endpoints of Pub/Sub API against REST API-based publishes to see how Pub/Sub API performed.
Test setup and system configurations
The tests were conducted using a custom load driver on Amazon AWS instances within the U.S. region to minimize latency and accurately measure server response times. The load driver was configured to run platform event publishing via Pub/Sub API. A single user published events concurrently with subscriptions using the same client, with events sent as quickly as possible with no delay, and event size set to 1KB. The number of events per batch was varied to assess the impact of larger batches and payloads.
Publish results and analysis
For publishing comparisons, we compared publishing events with Pub/Sub API vs REST API. There’s a clear win with Pub/Sub API from a functional standpoint when it comes to publishing, even before looking at the results: it supports a higher batch size. REST API has a maximum batch size of 25, which means REST API-based clients are inherently limited in their scalability.
Our results show that Pub Sub API clients are able to publish far more events per second than REST API clients. As batch publish sizes increase, REST API clients see a small increase in publish throughput before leveling out at 32 events per second. This is in contrast to Pub Sub API’s ability to scale throughput with increasing batch sizes. At the maximum batch size allowed by REST API, Pub/Sub API clients achieve a publish rate over 14x higher that REST. Comparing the maximum throughput between these two APIs, Pub Sub API clients can publish almost 35x as many events per second as REST API. Pub/Sub API also boasts faster response times, enabling it to scale more effectively and publish significantly more events in larger batches with greater efficiency. Ignoring the reliability benefits of Pub Sub API’s real-time publish acknowledgements, Salesforce developers should strongly consider using Pub Sub API to take advantage of the significant performance improvement in publishes.
Conclusion
Our analysis demonstrates that Salesforce Pub/Sub API significantly outperforms REST API in terms of scalability and efficiency, especially at higher batch sizes. Pub Sub API is designed to handle large-scale systems where the load patterns are variable and can change rapidly. Therefore, it is ideal for integrating different systems that need to communicate with each other at a massive scale. It allows for asynchronous communication, meaning that the systems do not need to be directly connected or synchronized in real time.
Pub/Sub API is a single API that enables event publish, subscribe, and schema retrieval. Clients don’t need to juggle between different APIs to be able to support these integration needs if they are written using Pub/Sub API in any of the many supported languages. From both a functional and performance perspective, Pub/Sub API is the recommended Salesforce method and should be your preferred choice for writing an event integration client.
Resources
Blog: Build Controllable and Scalable Integrations with Pub/Sub API
Trailhead: Pub/Sub API Basics
Documentation: Pub/Sub API Developer Guide
About the Author
Neha Ahlawat is a Product Management Director in the Einstein 1 Platform organization at Salesforce, where she is focused on the product areas of Metadata API, Tooling API, source tracking, and change sets. Follow her on X and LinkedIn.
The post Scale Publishing Seamlessly with Pub/Sub API appeared first on Salesforce Developers Blog.