DEV Community

Callis Ezenwaka
Callis Ezenwaka

Posted on • Edited on

Using Edge Functions to Mitigate Cost and Latency for Distributed Users.

Introduction

Edge functions is a piece of code that executes on an “edge network” or a “Content Delivery Network” (CDN). Edge Networks, which consist of servers that sit on the "edge" of multiple networks, act as bridges to route traffic between nodes or networks across the CDN (1).

Edge networks are networks of servers, distributed around the world, working together to serve cached content to users from the closest server location possible. Edge functions are serverless functions while all serverless functions are not edge functions.

Serverless functions are codes deployed mostly on the cloud and executed on demand, without need for provisioning their own servers, or scaling their application to meet traffic spikes. They are also available in broad geographic regions.

In contrast, Edge functions are serverless functions executed in the location closest to the user’s request. Edge functions are not constrained to specific pieces of code or function. They have the capacity to run just any other business applications.

Since all the business logic is deployed to an edge function, when the user sends a request to a node, it is the function that determines how to respond to the browser. The following cloud providers offer edge functions or a variant of it: Netlify, Vercel, AWS, Azion, Cloudflare, Azure etc.

Benefits of Edge Functions

Edge functions deliver content to users with a fast and personalized experience, and has the following additional benefits (2):
• Decreased latency.
• Reduction in cold start boot times.
• Conditional routing.
• Adding a custom HTTP response header.
• A/B testing.
• Setting a cookie.
• Personalizing by geolocation.
• Authentication.

Common Drawbacks

However, while edge functions offer users the above benefits, they nevertheless have the following drawbacks:
• Latency due to data source location or origin.
• Low execution time.
• Limited memory and functions size.
• Capped invocation limits.
• Unavailable and unsupported native APIs.
• Maximum initial response time.

Conclusion

With the exception of drawbacks, some of which were listed above, edge functions have the potential to reduce cost as it will reduce the latency between a user request and the response time.

They have reduced cold start boot time and thus, could intercept user requests faster and deliver personalized responses based on the user location. Such use of geolocation for content delivery and data management could help mitigate compliance or regulatory challenges such as GDPR.

Of the different cloud providers researched, Amazon CloudFront appears to be a more dominant player in this field. Not only that it has two different flavors for edge networks, but it also has the capability to serve video on demand or live stream real-time events, encrypt specific fields throughout system processing, and serve private content using edge customizations (3).

Since supporting real-time communication between distributed users is an operation that has value only during the interaction time. Hence, round tripping to the main data center could introduce latency and its associated cost.

Edge networks have far reached advantages, most of which were outlined above. The use of edge networks could suffice and deliver more secure, reliable, effective, and affordable services to distributed users.

Resources

https://whitep4nth3r.com/blog/what-is-the-edge-serverless-functions/#edge-functions-are-serverless-functions-at-the-edge
https://vercel.com/docs/concepts/functions/edge-functions/limitations
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/IntroductionUseCases.html
https://www.tigera.io/blog/containerized-air-gapped-edge-platform-architecture/
https://www.netlify.com/blog/edge-functions-explained/
https://www.azion.com/en/documentation/products/edge-application/edge-functions/
https://developers.cloudflare.com/workers/learning/using-websockets/
https://azure.microsoft.com/en-us/blog/microsoft-partners-with-the-industry-to-unlock-new-5g-scenarios-with-azure-edge-zones/

Top comments (0)