SBN

How Enigmo Moved Logic from Client to Origin to Edge

By: Hideki Ito

 

Enigmo owns BUYMA, a Japanese fashion C2C marketplace that helps people buy and sell high-quality goods from overseas on www.buyma.com. BUYMA has 8.21 million members and deals with 5.62 million items across 140,000 fashion brands. Its website uses EdgeWorkers to manipulate cookies, a typical use case at the edge. 

In 2020, Enigmo decided to use EdgeWorkers for dynamic content delivery. Previously, it set cookies at an origin server to track customer page views, including first visit time, last visit time, affiliate, and referrer. 

At first, the browser set cookies using a JavaScript API. But after Safari introduced Intelligent Tracking Prevention (ITP), cookies set by the browser had a limited duration. According to the latest ITP 2.1, all persistent client-side cookies (i.e., persistent cookies created through a document.cookie API) are capped at a seven-day expiration. Enigmo needed to set cookies for more than a year to analyze customer behavior.

The following picture shows how the cookie manipulation logic moved from the client to the server and finally to the edge. Enigmo used JavaScript to call the document.cookie API in the browser, then used Ruby to set cookies at the origin, and finally used JavaScript at the edge.

howtomovethelogic.png

Reduced latency and consistent performance with edge computing

Enigmo has several domains, and it previously used Akamai’s content delivery network (CDN) for static domains that deliver images, JavaScript, and CSS. Because of a business policy about cost-effectiveness, Enigmo didn’t use CDN for its www domain, which provides the API and HTML. 

However, as the business grew, Enigmo had concerns about peak traffic and reconsidered using CDN and serverless computing solutions. Black Friday and Cyber Monday are critical events for BUYMA, and its website needs to use caching for several campaign pages. CDN technology allows BUYMA to provide consumers with a consistent user experience during campaigns, while EdgeWorkers manipulates cookies instead of the origin server. 

EdgeWorkers works quickly, providing the client device with responses from an optimal location at the edge. The following image is a sample report that shows EdgeWorkers’s average initialization time as 7.16 ms and average execution time as 0.20 ms. 

enigmo-april.jpegWhen the New Year’s sales campaign started in January, website offload increased more than 50% compared with non-campaign time. Enigmo wanted to protect the origin during peak times, and EdgeWorkers was crucial to its decision.

DIY development at the edge with EdgeWorkers

Akamai provides a best-in-class user interface and API for managing CDN. However, it’s an evident trend that application developers need more flexibility to write code at the edge. EdgeWorkers allows developers to write JavaScript and run custom code on the event handler. Cookie manipulation requires some business logic to trigger an onClientResponse event before the http response from the edge to the browser. According to Shintaro Kimura, development manager at Enigmo, it’s now mandatory to shift logic from the server side to the edge. An Enigmo developer learned EdgeWorkers by reading documents on developer.akamai.com, referred to some sample code on GitHub’s repository, and prototyped and released an initial version within a week. 

As head of the application development group, Kimura-san evaluated EdgeWorkers’s approach  and discovered that it manages both CDN properties and edge applications separately. From an application management perspective, Kimura-san recommended avoiding code overwriting between the infrastructure engineer and the application developer. 

According to Kenji Ozawa, director of service engineering at Enigmo, EdgeWorkers has helped BUYMA provide a specialty marketplace to their customers — anytime and anywhere.

“To maximize our business, site stability is a critical part of our service strategy. We have been pursuing modern and flexible development environments so engineers can release excellent features on time,” said Ozawa-san. “EdgeWorkers is one of those environments, and our team successfully released our first edge application.”

Summary

EdgeWorkers helps developers at companies like Enigmo write custom logic at the edge. As the browser faces more restrictions when it comes to manipulating cookies, edge computing becomes more important because it acts as a first-party domain. With serverless computing, application developers can obtain a new generation framework to write, run, and manage their own code at the edge. Register your account and start your free trial today at developer.akamai.com

Resources

*** This is a Security Bloggers Network syndicated blog from The Akamai Blog authored by Akamai. Read the original post at: http://feedproxy.google.com/~r/TheAkamaiBlog/~3/6D3llofR2Q4/how-enigmo-moved-logic-from-client-to-origin-to-edge.html

Secure Guardrails