[SalesForce] Clear platform event limits

Where can I find clear docs on the API limits for sending platform events IN to sfdc?

The platform events basics trailhead notes that:

provides allocations for how many events you can define in your org, and how many event records you can publish in an hour. Also, because event publishing is equivalent to a DML insert operation, DML limits and other Apex governor limits apply

The DML part makes sense to me because creating an event is a DB insert.

HOWEVER – where are the docs that clearly cover "how many event records you can publish in an hour". The trailhead points you to Execution governors and limits, but this is where it gets muddy.

Total number of DML statements issued: 150. Does this mean only 150 platform events can be raised across an org per hour?

Or for each Apex transaction, 150 platform events can be raised? Do the producers also get charged 1 Apex Rest API call per event raised?

Given the concrete example below, can someone help me answer ALL the limits that are associated with this flow?

  1. I have a SPA that uses JSForce .sobject().create() to hit /services/data/v40.0/sobjects/Cloud_News__e with the request body defined here. This API call is invoked under a token from a salesforce user with a Enterprise Edition:Partner Community license.
  2. The Apex controller in my SFDC org, handles the event (1 Apex transaction) and updates a custom object.

What are the specific limits associated with this flow?

Best Answer

Total number of DML statements issued: 150. Does this mean only 150 platform events can be raised across an org per hour?

No, it means that every single Apex Transaction can do 150 DML statements. It has nothing to do with Platform Events directly (but publishing events costs DML statements for that transaction).

Or for each Apex transaction, 150 platform events can be raised?

You can call EventBus.publish up to 150 times per transaction, but those are shared with all other DML operations, like inserts, updates, deletes, converts, etc. There's a list version of this method that can theoretically publish up to 10,000 events per call (the maximum DML rows limit). As Adrian pointed out, you only get 100,000 events per hour, though.

Do the producers also get charged 1 Apex Rest API call per event raised?

Yes, if you use the REST API, it counts towards your org's daily API limits. This isn't the same as publishing events, however. When possible, use the Composite resource to submit up to 25 events in a batch to reduce the number of API calls you consume.

I have a SPA that uses JSForce .sobject().create() to hit /services/data/v40.0/sobjects/Cloud_News__e with the request body defined here. This API call is invoked under a token from a salesforce user with a Enterprise Edition:Partner Community license.

The Apex controller in my SFDC org, handles the event (1 Apex transaction) and updates a custom object.

It sounds like one event per transaction, then. It would be possible for the Apex Code to publish more events in response to an event, in which case the count would increase.

Related Topic