Docs Menu

Docs HomeAtlas App Services

Atlas Triggers

On this page

  • Trigger Types
  • Limitations
  • Atlas Function Constraints Apply
  • Event Processing Throughput
  • Number of Triggers Cannot Exceed Available Change Streams

Atlas Triggers execute application and database logic. Triggers can respond to events or use pre-defined schedules.

Triggers listen for events of a configured type. Each Trigger links to a specific Atlas Function. When a Trigger observes an event that matches your configuration, it "fires." The Trigger passes this event object as the argument to its linked Function.

A Trigger might fire on:

  • A specific operation type in a given Collection.

  • An authentication event, such as user creation or deletion.

  • A scheduled time.

App Services keeps track of the latest execution time for each Trigger.

App Services supports three types of triggers:

Triggers invoke Atlas Functions. This means they have the same constraints as all Atlas Functions.

Learn more about Atlas Function constraints.

Trigger events are added to a queue and processed when capacity becomes available. The rate at which a Trigger processes events depends on the Trigger's configuration as well as the logic in the Trigger function.

Ordered triggers process events from the queue one at a time. An unordered trigger can process up to 10,000 events concurrently.

To increase the throughput of a Trigger, you can try to:

  • Optimize the Trigger function's run time. For example, you might reduce the number of network calls that you make.

  • Reduce the size of each event object with the Trigger's projection filter. For the best performance, we recommend limiting the size of each change event to 2KB or less.

  • Use a match filter to reduce the number of events that the Trigger processes. For example, you might want to do something only if a specific field changed. Instead of matching every update event and checking if the field changed in your Function code, you can use the Trigger's match filter to fire only if the field is included in the event's updateDescription.updatedFields object.

App Services limits the total number of Database Triggers. The size of your Atlas cluster drives this limit.

Each Atlas cluster tier has a maximum number of supported change streams. A Database Trigger requires its own change stream. Other App Services also use change streams, such as Atlas Device Sync. Database Triggers may not exceed the number of available change streams.

Learn more about the number of supported change streams for Atlas tiers.

←  JavaScript SupportDatabase Triggers →
Share Feedback
© 2023 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.