A newer version of this documentation is available.

View Latest

Eventing Service: Fundamentals

      The Couchbase Eventing Service is a framework to operate on changes to data in real time. Events are changes to data in the Couchbase cluster.

      The term 'mutation' generally refers to document changes happening in the Couchbase cluster. The Couchbase cluster considers create, update, expiry, or delete operations as data mutation. Natively integrated with the Couchbase Data Platform, the Eventing Service does not require any third party solutions to manage data mutations. In an event-based architecture, all data changes are reactive and in real-time.

      For example, consider the number of mutations in the data cluster of an e-Commerce application when a customer places a new order. You can observe that: a new transaction record gets created, a new purchase-transaction gets appended to the User’s account, sellers stock-inventory gets updated with a new purchase order. Each of these data mutations qualifies as an event in the cluster.

      A few sample events are listed below:

      • Capturing the sensor output from a patient

      • Placing an order in an e-Commerce application

      • A customer’s order causing a drop in the inventory

      • Change in the status of a project

      • Removing a user from a transaction scoring application

      • News article expires after a certain period of time

      Using the Eventing Service, you can:

      • Set alerts in a document when a preconfigured threshold is breached

      • Monitor specific parameters in a document

      • Propagate changes to other systems

      • Enrich a document in real time

      • Cascade deletes to avoid orphaned documents

      Why use the Eventing Service?

      The Eventing Service helps you to streamline your business workflows. Using the Couchbase Eventing Service you can:

      • Manage a data-driven business logic across business-critical applications in a timely manner, thereby increasing your customer engagement.

      • Handle inconsistencies in business logic while working with multiple client applications across domains.

      • Design newer data products by leveraging lower technical barriers in the Eventing Service.

      • Develop a reliable infrastructure that can execute your business logic in a rapidly changing data platform.

      • Scale your throughput without making changes to your data configuration and infrastructure.

      • Maximize your return on investment by minimising your TCO.

      Eventing Service versus Message Queue and Polling Implementations

      The following table compares the implementation of the Eventing Service with the message queue method that is used to solve the tracking of data mutations.

      Message Queue or Bus Implementation Eventing Service Implementation

      Needs an additional layer to propagate data changes.

      Inherent to Couchbase Server and does not need a new layer to propagate data changes.

      Encounters dual-write problems. Every write operation gets pushed twice; once to the message queue and the second time to the cluster.

      Eliminates the dual-write problem. Multiple application servers can perform simultaneous write operations.

      At any point, a write-failure condition can happen.

      Eliminates the write-failure condition; no transaction semantics.

      No easy debug option during troubleshooting.

      Integrated with native debugger support.

      Leads to inefficient data governance and data leakages.

      Provides a centralized control for aspects such as data auditing and data governance, thereby reduces data leakages.

      With the added license, infrastructure, and deployment expenses, the Total Cost of Ownership (TCO) increases many folds.

      No additional expenses, the TCO is reduced.

      The following table compares the implementation of the Eventing Service with the polling method that is used to solve the tracking of data mutations.

      Polling Implementation Eventing Service Implementation

      To record and propagate data changes, multiple applications are needed.

      Can record and propagate data changes to a database, message queue, an end-point, or to another bucket inside the Couchbase cluster.

      Batch systems are highly inefficient and are not reactive.

      Handles data mutations in real-time.

      Consumes a lot of CPU resources.

      Implements as a state-less compute operation and utilizes latest trends in compute (multi-core CPU).

      Leads to code duplications across multiple infrastructure applications.

      No code duplication.

      Difficult to scale. You need to scale for applications and also scale for transport layer requirements.

      Provides easy horizontal scaling options.

      Couchbase Functions

      Couchbase Functions, also referred to as Functions, offers a computing paradigm that developers can use to handle data changes. In the Couchbase cluster, you can use the Functions to handle data-changes according to an Event-Condition-Action model.

      For Application developers, the Functions offers a platform using which you can focus on building the business logic, than over configuration or infrastructure. Functions handle the event that is generated when a document is created, updated, or deleted. The serverless computing infrastructure gets closer to the datastore as the Couchbase Functions integrates with the Couchbase Data Platform.

      Features of Functions

      You can configure Functions to generate threshold-based alerts. If your business logic requires you to monitor specific parameters inside a document, then you can use Functions to trigger an alert upon a threshold breach.

      Apart from notifications and alerts, Functions provides an option to propagate data changes. You can propagate data changes and move documents to a different bucket inside your Couchbase cluster. Since Couchbase is a NoSQL document-oriented data platform, Functions provides an easy option to perform cascade deletes.

      Benefits of Functions

      • Improves customer experience and engagement

        • Data enrichment: Before the introduction of the Eventing Service, data enrichment was accomplished through batch jobs. These batch jobs were not in real-time and often resulted in increasing the cost of infrastructure and management. Using the Eventing Service, the data enrichment capability was achievable in real-time. Functions involve moderate coding effort, time to market and restart capabilities can be achieved easily.

        • Simple to use: Since Functions are developed within the Eventing Service framework, tracking data changes in your cluster is manageable.

      • Faster innovation

        • With a focus on business logic, development cycles are reduced. The Eventing Service platform offers a developer-friendly environment which in turn aids the faster creation of Minimum-Viable-Products(MVPs).

        • Using Functions, Application Developers can rapidly remodel their business workflows and thereby stay in-sync with any business change conditions.

        • Functions offer a lower barrier to technology-adoption by emphasizing on business operations.

      • Reducing infrastructure and operations-cost

        • Since the implementation of the Eventing Service is intrinsic to the Couchbase cluster, it offers a simple way to deploy working model.

        • The Eventing Service provides optimum utilization of resources and controls essential aspects such as data auditing, data governance, and node scaling.

      Use Cases

      As an Organization, you can use the Eventing Service in a wide variety of use cases. Be it in domains such as retail, healthcare, telecommunications, media, or travel; you can leverage the Eventing Service to track data mutations.

      For an easy understanding, consider a sample use case in the banking and financial domain. Let us say the user performs a credit card transaction. Using the Event-Condition-Action model, you can design a custom workflow based on factors such as user’s credit limit, usage currency, and risk propositions.

      As another sample use case, consider an organization operating in the Supply Chain Management domain. As a developer, using the Function’s Event-Condition-Action model, you can design a custom workflow in your inventory for stock replenishment. Functions help you to construct a business workflow that automatically triggers new stock replacements and maintains a set stock threshold.

      The tabular column below lists popular scenarios where the Eventing Service across domains can be used.

      Table 1. Eventing Service - Use Cases
      Domain Eventing Trigger Condition Check Sample Workflow

      Banking & Financial Services

      Card transaction

      Transaction threshold

      Generate risk alerts and quarantine user upon threshold breach.



      New sales voucher

      Stock availability

      Generate invoice for stock replenishment.

      New purchase order

      Saved wishlist/cart

      Notify price alerts for wishlist items.


      New booking

      Booking history

      Enroll for frequent flyer program and notify special promotions


      User profile

      Notify price drop alerts


      New report

      Check for vitals

      Schedule an appointment.



      New user creation

      User profile

      Generate notification about leaderboard and other statistics.

      Media/ Entertainment

      Breaking news

      Query archives

      Enrich existing news with archival information.

      Eventing Service - Onboarding Information

      In your organization, if you are using the Couchbase data platform, then the Eventing Service is a good fit for managing data mutations. The Multi-Dimensional Scaling (MDS) service enables workload isolation and independent scalability in a Couchbase cluster. Using the MDS service, the Eventing Service is in line with your real-time data tracking requirements and integrates seamlessly with your existing Couchbase nodes such as the Query, GSI, and FTS nodes. Adding a new Eventing node is a simple and repeatable process.

      eventing service onboarding information
      Figure 1. Eventing Service Onboarding Information

      Following are a few aspects during the onboarding process:

      • The Eventing Service is intrinsic to Couchbase Server; unlike Polling and Message Queue based external systems, it eliminates the need for an additional layer without involving multiple applications for tracking data mutations. All data mutations are handled in real-time, and the Eventing Service offers a centralized control for data governance.

      • When you transition to leverage the Eventing Service, application developers can use Couchbase Functions to manage business workflow changes swiftly. Application developers can program, test, debug and troubleshoot on a single Eventing Service platform, instead of managing multiple application across different network layers.

      • After onboarding, you can manage and optimize the system throughput efficiently. If your data resides in the Couchbase cluster, based on aspects such as data workload, data mutation rate, and Function execution latency, you can either use the scale out option by adding additional workers or use the elastic scaling option by adding another node.

      • The Eventing Service provides an export and import option for code portability. Using this option, you can reuse the Function handler code to validate the execution logic in different environments with workload variations.

      • The Eventing Service is highly performant during the recursive restartability operations. You can undeploy a Function, pause for few cycles and then start the Function handler-code. Deploying a Function after a time-lapse ensures that the Function execution is tested for restartability.

      • Eventing leverages the latest trends in multi-core CPUs; therefore nodes selected for Eventing should optimally have a higher number of cores than those for indexing.