HomeCategoriesAll Tags

Cloudflare Workers are really impressive

For serverless solutions, you must give a try to cloudflare workers. They are not suitable for all the needs but if they fit your needs then cloudflare workers along with cloudflare complete ecosystem are just awesome.

Runtime

Runtime is the USP of cloudflare workers. This is what separates them from other cloud functions. Here you do not get the real Node.js runtime containers but instead the code runs on javascript's V8 engine isolates. This makes them lightweight and superfast. You also avoid cold starts and warm-up time. The only downside is that you can't use all the node.js features because these V8 isolates are similar to Service Worker API

Edge network

Automatically our function replicated and is deployed all over the world instead of particular regions like with the traditional cloud functions. Thus, offering exceptional performance and scalability. Also you can also leverage Cloudflare’s network features, such as DNS, SSL/TLS, DDoS protection, firewall, caching, load balancing.

KV Store

Cloudflare Workers include a distributed key-value store called Cloudflare Workers KV. This storage solution provides a simple way to persist and retrieve data across requests and deployments. KV is designed for high-read and low-write scenarios, where you need to access data quickly and frequently from multiple locations. Up to 25 MB of data can be stored in a key. However, I found issues if incoming request was having a large strigified body then cloudflare worker was rejecting it.

HTML Rewriter

HTML Rewriter is a powerful tool that allows developers to modify HTML content in real-time at the edge. Technically, it is a streaming HTML parser and modifier. You can unleash all your creativity here to do wonders as it enables dynamic rewriting of web pages, making it possible to add, remove, or modify elements on the fly. It is a bit tricky to get your head around this but once your code works it will amaze you.

When you should not use Cloudflare Workers

  • Services that require a lot of CPU or memory.
  • Services that are compute or network intensive and need a longer execution time.
  • Services that need a lot of to and fro from external data resources.
  • You need to use libraries or frameworks that are not compatible with the V8 engine or the Service Worker API.

I hope this was helpful. Thanks for reading along. Let me know your feedback/suggestions in the comments.

- Ayush 🙂