Scaling Booster Azure Functions
Booster Azure Provider relies on CosmosDB change feed processor to consume new events. In CosmosDB, the partition keys are distributed in ranges, where each range represents a physical partition. Unlike logical partitions, physical partitions are an internal implementation of the system and Azure Cosmos DB entirely manages physical partitions
With Booster EventStream functionality, we could define the number of physical partitions our events are split and create instances for each partition.
To enable EventStream, set the EventStreamConfiguration
in the configuration object:
Warning: Currently, only available for Azure provider.
config.eventStreamConfiguration = {
enabled: true,
parameters: {
streamTopic: 'test',
partitionCount: 3,
messageRetention: 1,
maxRetries: 5,
mode: 'exponential'
},
}
Parametersβ
- StreamTopic: Define the internal topic name Booster will use.
- PartitionCount: Number of Event Hub partitions. The number of functions app consumer instances will match the partition count
- MessageRetention: Specifies the number of days to retain the events for this Event Hub
- MaxRetries: Number of retries to consume an event
- Mode: Retry mode. It could be
fixed
orexponential
Note: maxRetries
and mode
are configured at Function level
Infrastructureβ
Enabling EventStreamConfiguration
will apply some changes to the infrastructure:
- Two functions will be created
- One function with a CosmosDB consumer that will produce Event Hubs events. Also, it will include the readModels functions, schedule functions app, etc...
- One function with an Event Hub consumer function app. This function will allow you to define the number of instances to be created
- A new container to handle duplicated consumed events
- A new Event Hub will be added for event handling.
Recommendationsβ
Dynamically adding partitions isn't recommended. While the existing data preserves ordering, partition hashing will be broken for messages hashed after the partition count changes due to addition of partitions.
ποΈ Environments
You can create multiple environments calling the Booster.configure function several times using different environment names as the first argument. You can create one file for each environment, but it is not required. In this example we set all environments in a single file:
ποΈ The Register object
The Register object is a built-in object that is automatically injected by the framework into all command or event handlers to let users interact with the execution context. It can be used for a variety of purposes, including:
ποΈ Configuring Infrastructure Providers
The providers are different implementations of the Booster runtime to allow Booster applications run on different cloud providers or services. They all implement the same interface, and the main idea behind the providers is that no matter what the developer chooses as backend, they won't need to know anything about the underlying infrastructure.
ποΈ Create custom providers
Booster provides an infrastructure layer out of the box with sensible defaults that you can use for rapid development, but if
ποΈ Extending Booster with Rockets!
4 items
ποΈ Sensors
1 items
ποΈ Testing
Booster applications are fully tested by default. This means that you can be sure that your application will work as expected. However, you can also write your own tests to check that your application behaves as you expect. In this section, we will leave some recommendations on how to test your Booster application.
ποΈ Migrations
Learn how to migrate data in Booster
ποΈ TouchEntities
Learn how to update entities and ReadModels
ποΈ Customizing CLI resource templates
You can change what the newly created Booster resources will contain by customizing the resource template files.
ποΈ Framework packages
The framework is already splitted into different packages:
ποΈ Booster instrumentation
Trace Decorator
ποΈ Scaling Booster Azure Functions
Booster Azure Provider relies on CosmosDB change feed processor to consume new events.