Now Available: EdgeKV Distributed Key-Value Store
We're excited to announce the availability of EdgeKV, a distributed key-value store database that enables EdgeWorkers to leverage data stored at the edge when deploying custom code across our serverless computing platform. This solution is fully distributed, meaning it runs in 1,400+ networks and in 135 countries.
As more application functionality moves to the edge, quick access to data will be critical to ensuring low latency and great user experience. With EdgeKV, serverless applications can provide fast responses to complex requests by accessing data at edge locations close to end users -- without having to retrieve information at origin. EdgeKV is deployed across more than 4,200 locations for proximity to users and fast application response times.
Built for developers, EdgeKV supports a broad set of data types, doesn't require a complex query language, and frees development teams from the time-intensive tasks of managing and operating their databases.
EdgeKV provides some key features including:
- High availability and low latency
- Read data at cache-like speeds using Akamai's unmatched infrastructure
- Read and write from within EdgeWorker code
- Global availability on Akamai edge servers
- CLI and administrative APIs to manage day-to-day operations
- Bring data close to your business logic
We are seeing EdgeKV employed in a variety of use cases. One of those use cases involves the requirement for strict geolocation services. Many websites use geolocation intelligence to increase user engagement, reduce bounce rate, and improve conversions by delivering location-specific content -- such as personalized site features, nearby stores, or special products and offers -- to visitors. Let's take a look at how that can work.
User geolocation services at the edge with EdgeWorkers and EdgeKV
An Akamai customer wanted to implement a geolocation service at the edge that included users' latitude and longitude rather than the imprecise location provided by the IP address. With EdgeKV, the customer created an accurate geolocation service that allowed storage of the necessary data to perform geolocation services quickly and efficiently.
Obtain data source in GeoJSON format
GeoJSON contains coordinates for points of a polygon that make up each state boundary and is available in JSON format. One source of such data is available here.
Store that data in EdgeKV
The customer extracted each state from the GeoJSON file and stored it within an EdgeKV key-value pair. The state's two-letter abbreviation was used as the key, and the corresponding GeoJSON data was used as the value. With this structure, any state can be retrieved by its abbreviation.
Generate bounding boxes for each state
A bounding box is described by only four numbers: minimum latitude, minimum longitude, maximum latitude, and maximum longitude. Any point within the state will also be included within this box.
Bounding boxes provide a way to quickly narrow down a list of possible states for a location. Figure 3 shows an example location that includes two bounding boxes: Arizona (red rectangle) and California (blue rectangle).
For each of the possible states, the winding number algorithm was used to determine if the point lies within the boundaries of the shape. For many states, there is more than one polygon in the GeoJSON data that must be checked, creating an increasing number of lookups. For example, the state of Alaska, with its complex coastline, resulted in almost one-third of all JSON data.
EdgeWorkers code
After adding the bounding box check, we moved data out of JavaScript code and into EdgeKV. The code:
- Takes latitude and longitude as input through query string parameters
- Searches through all bounding boxes to determine a list of candidate states
For each candidate state:
- Retrieve the detailed state shape data from EdgeKV
- If latitude and longitude are inside the state, return the state information
Summary
EdgeKV, an edge database as a service used to read or write structured or semi-structured data, provides reliable access to information used to power serverless applications running in EdgeWorkers.