Lightweight JS vs Node JS at the Edge

There are a number of lightweight code at the edge solutions emerging to complement existing lightweight solutions such as AWS Lambda. Several traditional CDN players have implemented a cut down Javascript layer called V8 (both Cloudflare and Stackpath have taken this route).

At Section, we generally want developers to avoid having to rebuild their applications at the edge, though there are many use cases where simple apps created at the edge can be very effective. We offer both lightweight and fully featured Javascript at the edge (in addition to a range of other language options, as well as open source and third party web performance and security modules).

Let’s review the benefits and challenges associated with both lightweight and fully featured code at the edge options.

Lightweight JS at the Edge

Cloudflare and Stackpath have both implemented the use of Chrome V8 at the edge (essentially a lightweight JS), and hailed it as the critical ingredient for their serverless programs. The team at Cloudflare describes V8 Isolates as “the future of serverless and cloud computing in general”.

V8 is an open-source JavaScript engine developed for Google Chrome and Chromium web browsers by Danish computer programmer Lars Bak. Its first iteration launched in 2008, initially designed solely to be executed by web browsers. V8 can also now execute JS code outside of a browser, which enables server-side (i.e. back-end) scripting. Cloudflare equates V8 to an “eight-cylinder car engine” because it is “fast and powerful” and capable of translating JavaScript code directly into machine code, which CPUs can understand because it is purely digital. V8 also optimizes JavaScript execution.

Cloudflare, which processes millions and millions of requests each second, was in need of a solution which allowed its manifold customers to write code and build applications themselves on the CDN’s 150+ servers worldwide. Cloudflare previously used Lua, but because it wasn’t sandboxed, its customers were not able to independently run code. Cloudflare ruled out containerization technologies such as Kubernetes for being too expensive and overly resource intensive. Its engineering team eventually landed on Chrome V8 Isolates as the backbone for the Cloudflare Workers serverless program: a single process can run hundreds or thousands of Isolates and switch between them, thereby allowing code from many different customers to run in the same OS process.

In a post titled “Cloud Computing without Containers” written for Cloudflare, Zack Bloom, Director of Product for Product Strategy, says he believes, “it’s possible with this model to get close to the economics of running code on bare metal, but in an entirely Serverless environment”. Bloom believes that the use of V8 marks not just “an iterative improvement but an actual paradigm shift”.

StackPath’s serverless computing platform, EdgeEngine, also leans heavily on V8 as its backbone, allowing the uploading of JavaScript scripts to be automatically deployed “within seconds” to each of StackPath’s global data centers. When a request comes in, the developer’s JS code is executed in an individual, isolated sandbox environment built on top of StackPath’s customized implementation of the V8 JavaScript engine. StackPath describes the setup as a means for developers to get “a simple and easy way to deploy highly-distributed, highly-performant and highly-scalable global applications”.

Both StackPath and Cloudflare espouse the speed of V8, and how quickly it allows your code to start. Zack Bloom describes the way in which “any given isolate” is able to “start around a hundred times faster than I can get a Node process to start on my machine.”

On Section’s Edge Compute Platform, we offer options for lightweight code at the edge, but we also support richer JS at the edge that traditional platforms are unable to provide. The richer JS option is a fully fledged Node JS module running at the edge in a completely containerized solution which eliminates the security risks other platforms face. This allows your apps to run natively, and moreover, grants you the full experience. Full featured application functionality means flexibility in your technology stack, and the ability to mix and match best-of-breed security and performance options in order to build the solution you need, not the one you are locked into by traditional CDNs.

Section’s holistic solution gives websites maximum overall value and the opportunity to achieve optimal performance and robust security at any required scale.

One of the key differentiators with Section’s Edge Compute Platform is its adherence to modern DevOps principles. Our platform provides developers with the tooling they need to clone environments and run Node apps locally for testing before pushing to staging and production, ensuring faster and smoother development lifecycles.

The Section platform utilizes a blue-green deployment model which eliminates the need for ‘spinning up’. Many believe that spin up time is an issue for fully featured code at the edge; we believe, however, that this only applies to a subset of solutions, such as AWS Lambda, in which containers are spun up and then discarded once the code operation is complete.

Finally, adding our Node JS Module to the edge is highly cost effective when evaluating fully featured and developer integrated solutions at the edge.

With Section, you can choose whichever option best suits you - or use both.

Practical Use Cases for Node JS at the Edge

Some example use cases for running Node JS at the edge include:

  • Deploy your single page app (SPA) to the edge;
  • Handle API requests;
  • Rewrite body content;
  • Implement custom security filters at the edge;
  • Redirect segments of users to different back-ends;
  • Deliver highly personalized content to users;
  • … and many, many more! (What will you create.)

Have a use case that you’d like to talk through with our engineers? Contact Us

Similar Articles