4 ms·
What about Node makes it unsuitable for FastCGI? I always found it curious that Cloudflare Workers does not use Node, makes sense that there could be an underly
by divbzero 5y ago
What about Node makes it unsuitable for FastCGI? I always found it curious that Cloudflare Workers does not use Node, makes sense that there could be an underlying reason.
- afiori 5y agoI believe I made a mistake, my previous comments are about CGI not FastCGI. Also I am not an expert so I will not be able to prove anything, but I can try my best to express my opinions. I do not think that node has any problems with FastCGI So basically Node's start latency are too slow for CGI and FastCGI is bad for a worker platforms (or for any multitenant offering). The reason is that cloudflare doesn't want to keep track which workers are for which customers and want to offer a clean slate environment for each request. This either means spinning up new processes or using some other in-process isolation techniques. All javascript workers platforms I know use V8 isolates, which (I believe) node does not offer. PS: I made also another mistake, it looks like deno offers a worker platform on V8 isolates. https://deno.com/deploy https://deno.com/deploy
- deleted 5y ago[deleted]
- kentonv 5y agoNode is not designed to be multi-tenant. That is, it is expected that a single Node.js process runs a single Node application. Additionally, Node does not attempt to provide any isolation of that application -- it is assumed that the application code is fully trusted. So, in order to host Node apps on behalf of multiple customers, you must run multiple copies of Node.js as separate processes, and you must use some sort of secure containerization or VMs to isolate them from each other and from the system. That in turn means there's a lot of overhead involved in running each application instance. To amortize that overhead, it's necessary for each instance to handle a large number of events, so that the per-event overhead is reasonable. So, you need to concentrate your traffic stream onto a small number of instances. Workers, however, had the design goal that every application would run at every one of Cloudflare's hundreds of locations, in order to run as close to the end user as possible. That implies that there may be hundreds of instances of an app around the world, while each instance only handles traffic from a particular locality, which may be small. This means the setup overhead per instance had to be much less, and it had to be possible to run tens of thousands of live instances per machine, with the ability to quickly load from a library of millions on disk on-demand. That's just not possible with containers, or even processes. But it is possible if you run lightweight V8 JavaScript instances -- called "isolates" -- all inside a single process. This talk of mine goes into a lot more detail: https://www.infoq.com/presentations/cloudflare-v8/ https://www.infoq.com/presentations/cloudflare-v8/ (I'm the lead engineer for Workers.)