How many worker sites can I have?

In the workers pricing it says I can have 30 functions in either the free or unlimited plan.

Does this mean I have a limit of 30 sites even if the same function is used in all sites?

I’m working on a SaaS where I need my users to have its own custom domain. I’d also like to use the cache API for each of those domains with a single function.

I understand that to do that dynamically first I’d need to add the domain via the Cloudflare API. After that I’d need to create the routes for each domain that point to the same function.

Is this correct?

Would this count as a single function considering there is a limit of 30 functions?

That’s 30 workers. Do what you want with them. I have some workers shared across 10-15 sites. So I’m already at over 30 routes using Workers. And, go figure, I’m already up to 24 workers. I’m going through them as if money grows on trees.

1 Like

Hmm for some reason the mods merged the two threads although those were 2 different topics.

@sdayman so one worker per site, thanks.

It’s a shame there is no pay as you go to add more workers. More functions would mean more requests. Hopefully Cloudflare will reconsider.

One worker per site? It’s one worker per route. So I have a “Security Headers” Worker assigned to example.com/*, but don’t want to CSP to break my admin console, so I have a “Limited Headers” worker assigned to example.com/admin/*. The Admin route is more specific, so it triggers before the full-site one has a chance to trigger.

And I can add these same two workers to a dozen sites. That’s a total of 24 routes, but only two workers. I could go with fifty sites (one hundred routes) with these two workers and still be ok.

1 Like

But if there is one worker per site and each site has a route domain.com/* that’s one worker per site, no?

It’s however you want to configure it. You can create one worker: security_headers, but assign it to all your sites example.com/*, domain.com/*, etc. That would be one worker serving multiple sites.

Or you can have workers: example_header, and domain_header. Each for their own domain. Two workers, two sites, etc., up to thirty individual workers for thirty individual sites (routes).

To answer this, no. The same function (worker) can be used on 50+ sites.

1 Like

I’m confused. Didn’t you just say that:

It’s one worker per route.

?

Wouldn’t example.com/* + domain.com/* count as 2 routes?

You can assign a script to as many different routes and domains as you want, but you cannot assign a worker to an already assigned route. In other words, 1 worker per route.

3 Likes

Thanks for the clarification. One worker per route, as in no more than one worker for the same route, not as in one worker = one route.

So in principle I should be able to use the same worker for hundreds of routes. Is there a limit to how many routes I can have for each CF plan?

1 Like

Fortunately, according to the current limits, there isn’t! :smiley:

By the way, you should take a look at the Workers documentation:

It will certainly help you to clear up most of the doubts that may arise.

3 Likes