Cloudflare workers + pages, possible KV, R2 and D1...
# workers-help
a
anteac: I've read up all the docs but im not sure if those things provide a near kubernetes like cloud worker restarts or wehatever it needs to do to keep going, serverless., or microservices. idk what my usecase even is, serverless or microservices? Plan is running nextjs website and seperate API server on edgerouter mode on CF workers, coupled with some postgres supported DB and lastly a graphql server that a discord.js based bot consumes. theorectly possible all on cloudflare workers/pages, but I assumed you had to have some software to keep an eye on all the services to provide redundancy and selfhealing if needeed like kube. Like what am i missing here? Whats the best setup if I were to put everything in CF workers/pages? Do I even need a service discovery type thing, or do i need like a API gateway a lá Kong or something like these things https://github.com/envoyproxy/envoy or https://github.com/istio/istio or https://github.com/solo-io/gloo? anyone have experience with organizing something very similar recently? and if i need any of those api gateways?. I assume terraform would do the trick but I cant find any info on that combinened with edge workers only ,,,
s
I don't think you'd need any of that, no
Workers run in every data center that cloudflare has (which is a lot) - if one of them goes down for whatever reason, requests will just be routed to another one
a
so thats taken care of then. , what is currently the best way to run nextjs website and seperate API server on edgeroute mode on CF workers, (or Pages?) coupled with some postgres supported DB and lastly a graphql server that a discord.js based bot consumes.
manually splitting up my codebase into seperate pages /workders? or is there some way to migrate
s
You'd probably have to do a bit of rewriting, yeah
It's worth noting that at the moment workers don't support TCP connections, so they wouldn't directly be able to reach postgres, though that is coming soon
Also if your discord bot is one that runs persistently (i.e. a gateway websocket connection to discord), you're probably going to struggle running it on workers - they're more meant for handling individual requests across the globe, and not for long running processes (you'd get evicted before long)
a
alright i think we will have to find out another solution then