CF Workers gradual rollout

Does anyone have any ideas on how to gradually rollout worker changes? Let’s say we have CF worker script of version 1 and we want to release version 2, but it’s too risky to rollout it to the whole traffic, so we want to rollout this new version to some part of traffic, let’s say 5% for some period of time, ensure that it works fine and only after that rollout it to the rest 95% of traffic.

Cloudflare allows to have different workers for different routes, but it doesn’t work for us as we want to have a new version of worker on all pages, but only for small traffic.

Would be really cool feature if CF would allow assigning different worker scripts not just per specific route but also per geolocation, IP range, HTTP headers, devices, URL query parameters, etc.

Good question! Based on the currently available functionality, I believe you would be looking at building a homegrown solution.

Probably won’t be particularly clean and efficient as workers can’t easily call one another (refer to Is a worker allowed to make requests to another worker? for example), but I’m thinking that the “first” worker would implement the desired logic and call other workers based on that.

With Workers KV, you can store some simple configuration such as available workers and versions, their share (%) of the traffic, and so on.

I guess Cloudflare will launch exactly what you need once you have implemented it - better, cheaper :grinning_face_with_smiling_eyes: Maybe better to have them consider this as a feature request.

I describe how I designed a gradual rollout structure and plan here.
I use K/V storage and service binding