Running applications or business logic in a serverless environment has become prevalent. In these environments, the context in which logic runs is volatile, stateless, and can be reused multiple times by different applications.
Split’s Cloudflare Workers
The storage wrapper communicates with Cloudflare’s Durable Object store, which is an external cache. The Synchronizer keeps the rollout plan, i.e., the set of splits and segment definitions, synchronized in the external cache, and the SDK runs in partial consumer mode to read splits and segments from the external cache to evaluate splits.
In partial consumer mode, the SDK does not start the usual synchronization to keep internal definitions of splits and segments up to date. Instead, it uses the external cache to access them. A cron trigger can be used in the Cloudflare Workers to periodically execute the synchronizer and then update the cache with the latest definitions of the splits and segments in your environment.
In regards to tracked events and impressions data, in partial consumer mode, the SDK automatically sends them to Split cloud instead of storing them in the external cache, keeping the implementation friendly to serverless environments.
The following data flow diagram shows an overall architecture of how the different components are orchestrated in the Cloudflare Workers serverless environment:
The GitHub repository for the Cloudflare Workers template contains the necessary steps to get started using this template.