Hi, I’m exploring the possible use of Workers and was wondering if my use case was off. I have my app with Netlify and would like to redirect API calls to Cloudflare workers which would then call my Azure SQL Server Database.
In the documentation it was saying that you shouldn’t be calling a separate database off of Cloudflare itself but it seems other people are doing that?
Also, I would just like to use some generic Cloudflare domain if possible rather than import my domain into cloudfare. I do have another domain I could use. But if I could just call an IP address or something that would be nicer.
This app that I’m building is just a fun side project I’m building. At this time I don’t expect it to go viral or anything. So, I wouldn’t be getting a ton of requests from users. But all the requests would be coming from my Netlify domain name.
I love working with SQL Server so I would rather not give it up as that makes it much easier for me to get up and running. Also, I would return data from SQL Server as JSON so I would be able to just stream the return directly to the client.
What intrigued me about using Cloudflare Workers was that it doesn’t have the cold start problem what Azure/AWS functions have and that it is super lightweight.
I think you are probably referring to this page, which states: “Generally speed is critical in these applications and making a request back to your origin service or database is too slow. It’s necessary to store or cache data in a location cachable by or near Cloudflare’s edge.”
This wording might be a bit misleading. It is not intended to be prescriptive, but merely intended to point out that, in general, use cases which benefit from Cloudflare Workers tend to be latency-sensitive. Subrequesting all the way to a central database incurs essentially the same latency penalty as having to go all the way to an origin, in which case much of the benefit of running code at the edge is lost.
That said, some use cases cannot avoid a central database, and it sounds like yours is one. In these cases, it’s best to find a way to avoid hitting the database on every request, and instead cache commonly accessed items. That is what the documentation is trying to convey. You might find the Cache API useful for this, or Workers KV, which itself relies on the Cloudflare cache.
That’s a neat idea! It would require quite some effort to make it work, since the assumption of a domain is baked into much of our infrastructure. However, I’ll pass the feature request along.