Erica Pisani, senior software engineer at Netlify, presented at QCon London on what edge is, how running code and serving data on the edge can improve site performance, and how to leverage these options effectively in a site to maximize site performance with minimal architectural changes.
After introducing herself, Pisani started explaining what Edge is. First, she took a step back, presenting the concepts of cloud regions and their availability zones, taking AWS as an example (the same applies to Google Cloud and Microsoft Azure). Pisani describes The Edge as data centers that are outside of the availability zones.
She gave an example of the edge in a request life cycle before diving into Web application functionality on the Edge using Edge Functions.
Pisani provided a few problem statements and solutions to explain the value of the edge, including code samples.
Problem: High-traffic page that needs to serve localized content.
Solution: Transforming a Server Side Render (SSR) page into a static one and inject localized content using an edge function.
Another problem statement and solution Pisani explained showed the benefit of edge functions.
Problem: User session validation should take less time in the request.
Solution: User session validation in an edge function.
And the final one she explained was on third-party integration.
Problem: Route a third-party integration request to the correct region.
Solution: Use data encoded in a JWT and route from an edge function.
Next, Pisani discussed data on the edge and challenges like limited connections and data consistency. First, she explained connection pooling as a collection of open connections that can be passed from database operation to data operation as needed to face the challenge of limited connections. For example, she mentions that Prisma Data Proxy is a tool that uses connection pooling in a serverless edge function. In addition, she says Cloudflare Durable Objects is a way to face data consistency challenges. And finally, she also mentions Planetscale to meet the data consistency challenges and provides a code sample on how to fetch data using Planetscale.
Lastly, Pisani pointed out a product called AWS Snowball as the "edgiest" of the edge of edge computing in areas like ships, windmills, and remote factories with no or unreliable internet.
She ended her talk with limitations of the edge, like lower CPU time availability, cost, and limited integration with some cloud services.
InfoQ interviewed Erica Pisani about boosting site performance with Edge Computing.
InfoQ: Is the Edge going to have a regulatory problem? What mechanism can one use?
Erica Pisani: Particularly around data being handled and stored within a particular region, it faces a challenge. I'm not sure about what the configuration would look like in other cloud providers such as Google Cloud Platform and Microsoft Azure. Still, in an AWS context, there's a characteristic that makes it slightly more challenging to be compliant with regulations.
You cannot specify certain regions to run Lambda@Edge to the exclusion of others, and they can be used in any particular region once deployed. Suppose you want to have only edge locations in the EU to handle EU user data, for instance, rather than edge locations in other regions, and the user making the request is closer to an edge location outside of the EU. In that case, that edge location may be used instead due to being physically closer.
CloudFront is the mechanism that is in the best position to help address this since it is what triggers Lambda@Edge functions as part of handling the request. In addition, its Geographic Regions feature allows you to impose geographic restrictions on the types of requests Cloudfront will fulfill when the requests originate from particular locations.
I need to familiarize myself with this feature to go into more detail than that, and it may be too blunt of a tool for what is looking to be accomplished, but it can be a simple solution for some types of requests.
InfoQ: Will the development cost of Edge be reduced?
Pisani: Given the increasing interest over the past few years on running web application functionality and hosting data on the edge, the development cost will go down, but to what extent and how quickly is hard to say right now. Like other technologies, we may also see the monetary cost of developing and hosting data and application functionality on the edge go down as time goes by, which will further help justify a move towards the edge for its performance-boosting capabilities.
As more tooling becomes available and the edge capabilities of the various cloud providers increase, developing on the edge is as challenging as developing for the origin server today, leading to equivalent development costs for companies. However, with that being said, given that the use cases for the edge are highly focused at the moment, such as setting cookies and custom request headers, the development cost should be manageable to start looking at incrementally adopting the edge today.