There are three main reasons why a Realm trigger would perform slower than expected: the trigger execution limit, event ordering, or insufficient Atlas resources.

NOTE: Even if you experience a reduction in trigger performance, note that Realm adds each trigger’s associated functions to a queue and executes the functions when capacity becomes available.

No triggers should ever be missed. If you suspect a trigger has been missed, contact MongoDB Support.

Trigger execution limit

Realm limits the execution of trigger functions to a rate of 1000 executions per second across all triggers in an application.

If additional triggers fire beyond this threshold, Realm adds each trigger’s associated functions to a queue and executes the functions when capacity becomes available.

Event ordering

Event ordering for a database trigger causes multiple executions of the trigger to occur sequentially based on the timestamps of the change events. Ordered triggers wait to execute a function for a particular event until the functions of previous events have finished executing. As a consequence, ordered triggers are effectively rate-limited by the run time of each sequential trigger function. This may cause a significant delay between the database event and the trigger firing if a sufficiently large number of trigger executions are queued.

You can mitigate this effect by turning off event ordering on the trigger. This allows the trigger to execute functions in parallel if possible, which can be significantly faster depending on your use case. Note that disabling the event ordering does not guarantee that multiple executions of a trigger function will occur in event order.

Insufficient resources

Your Atlas cluster may not have sufficient hardware resources to handle the workload. View your Atlas cluster metrics to determine if you are resource constrained.

Did this answer your question?