Follow

Optimizing CSDL by Reducing Duplicated Logic

CSDL allows you to group multiple streams together into a 'master stream'. The DPU cost of the master stream will be the sum of the costs of the sub-streams, plus any additional logic in the sub-streams.

Let's say we have two similar streams, for two different customers:

interaction.type in "twitter" AND
language.tag in "en" AND
interaction.content any "my brand, my product, marketing campaign"

And for the other customer:

interaction.type in "twitter" AND
language.tag in "en" AND
interaction.content any "new product, another brand, another marketing campaign"

Looking at these two examples, we can see there is a lot of shared logic between them. As we merge these streams into one, like so:

tag.customer "customer_1" { interaction.content any "my brand, my product, marketing campaign" }
tag.customer "customer_2" { interaction.content any "new product, another brand, another marketing campaign" }
return {
interaction.type in "twitter" AND
language.tag in "en" AND
interaction.content any "my brand, my product, marketing campaign, new product, another brand, another marketing campaign"
}

 In a small example like this, it should be easy to see just how much of an impact this should have on your overall CSDL cost - we have reduced six CSDL statements over two streams, to just three statements and some tags. If you were to scale this example up to hundreds or thousands of customers you could be dropping from hundreds of lines of CSDL, to just three.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments