2 ms·
So I'm guessing that in order to use modules from npm you use WebPack? And what's available is the same as a Service Worker in Chrome. So you can use http fet
by ilaksh 8y ago
So I'm guessing that in order to use modules from npm you use WebPack?
And what's available is the same as a Service Worker in Chrome. So you can use http fetch but there is no raw socket etc. Does it support WebRTC (not sure if there is a way to actually use that on the server but maybe there is some weird use case for communicating between Workers).
Also wondering what options there are for files or databases etc.
It sounds like the design is for them to handle individual requests, but just out of curiousity, how long can the workers keep running?
- treelovinhippie 8y agoYep I've got an index.js file that creates a simple API gateway via a basic switch() on the url pathname. Then individual files for each function. Bundle them into a single script with webpack and copy that into the Workers UI (there's an API for deployment too... eg can use Serverless Framework). 1MB max size, max 5-50ms CPU time, max 128MB RAM: https://developers.cloudflare.com/workers/writing-workers/resource-limits https://developers.cloudflare.com/workers/writing-workers/re... That said I've got a worker script running a pass-through websocket to GraphQL origin server and it keeps the connection open. I'm doing authentication within the worker too. Long-term I can see ability to run absolutely everything there: microservices, GraphQL server (Apollo has a beta), auth, static SPA files, SSR etc. $0.50 per million calls ($5/mth minimum). And they intend to be within 10ms ping of 99% of the global population. If they can workout how to do databases on the edge (they're working on it), then I can see a future where you could build scalable apps that serve millions of users for maybe less than $100/mth across the entire stack.