<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gustaf Nilsson Kotte on Medium]]></title>
        <description><![CDATA[Stories by Gustaf Nilsson Kotte on Medium]]></description>
        <link>https://medium.com/@gustaf_nk?source=rss-ccfe43f325de------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LgJvmd6vSdCLBkEy.</url>
            <title>Stories by Gustaf Nilsson Kotte on Medium</title>
            <link>https://medium.com/@gustaf_nk?source=rss-ccfe43f325de------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 10:04:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gustaf_nk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Server-side rendering IKEA.com with Edge Computing]]></title>
            <link>https://medium.com/flat-pack-tech/server-side-rendering-ikea-com-with-edge-computing-fcce97f6314f?source=rss-ccfe43f325de------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcce97f6314f</guid>
            <category><![CDATA[edge-computing]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-architecture]]></category>
            <category><![CDATA[a-b-testing]]></category>
            <category><![CDATA[personalisation]]></category>
            <dc:creator><![CDATA[Gustaf Nilsson Kotte]]></dc:creator>
            <pubDate>Thu, 20 Jun 2024 10:28:05 GMT</pubDate>
            <atom:updated>2024-06-20T10:44:15.277Z</atom:updated>
            <content:encoded><![CDATA[<p>In <a href="https://medium.com/flat-pack-tech/ikea-com-the-problems-with-static-content-3cd750a5f529">my previous blog post</a>, I wrote about the problems with static content.</p><p>What we want to achieve is rapid and reliable feedback that our changes to IKEA.com are also changing our metrics — and do not change other metrics negatively (side-effects). The practice of <em>A/B testing</em> (also known as randomized control trials) is a reliable and scalable method to introduce <em>causality</em> between changes and effects.</p><p>We also want to achieve a more <em>relevant</em> website for our visitors, by returning different experiences for them depending on their identified needs/context — a practice called <em>personalisation.</em></p><p>The conclusion of the previous blog post is that implementing A/B testing and personalisation with client-side JavaScript on top of static content introduces problems with web performance and experimentation data quality (including <a href="https://www.scribbr.com/research-bias/attrition-bias/">attrition bias</a>, which was not mentioned in the previous post). Instead, we have started a transformation of IKEA.com towards <em>dynamic</em> content using server-side rendering. In order to achieve server-side rendering <em>at scale</em> — both globally and by multiple teams — we’re using Edge Computing.</p><p>Note that we are relatively early in the transformation process from static web to dynamic web. That being said, we hope this post will still provide some valuable insights.</p><h3>Table of contents</h3><ul><li>Server-side rendering</li><li>Edge Computing</li><li>Data for the variants</li><li>Caching: Introducing Edge Variant Service</li><li>Local testing</li></ul><h3>Server-side rendering</h3><p>With server-side rendering, we’re generating HTML <em>on-demand</em> in a web server. While static content is also technically speaking generated server-side, it’s not <em>driven</em> from browser navigations — static content is <em>push</em>, while server-side rendering is <em>pull. </em><a href="https://web.dev/articles/rendering-on-the-web">Rendering on the web</a> is a great article that contains a terminology of web rendering.</p><p><a href="http://ikea.com/">IKEA.com is using Edge Side Includes (ESI)</a> to implement modularity in the web architecture, decoupling the teams’ deliveries from each other and thus enabling Continuous Delivery for the many teams. ESI <em>composes</em> the page template and its dependencies (fragments) into a finished page, which we call the <em>composition.</em> We call requests for page templates and fragments <em>internal HTML requests</em>.</p><p>What we want is the ability to return different HTML for page template and fragment routes depending on A/B testing buckets and customer data. Let’s wait a bit with <em>how</em> we get that data and just assume that we have it available when rendering happens. Then we could write code like the below examples (I use Jinja-like pseudo code in the examples, for simplicity).</p><pre>{% if experiments[&#39;navigation&#39;] == &#39;next-nav&#39; %}<br>  &lt;next-nav&gt;<br>{% else %}<br>  &lt;nav&gt;<br>{% endif %}</pre><p>or</p><pre>{% if customer.isReturningVisitor %}<br>  &lt;esi:include src=&quot;[welcome-back-url]&quot; /&gt;<br>{% else %}<br>  &lt;esi:include src=&quot;[welcome-new-url]&quot; /&gt;<br>{% endif %}</pre><p>or</p><pre>Welcome back {{ name }}</pre><p>We call the different HTML responses for the same route <em>variants</em>, because they vary over one or several variables. In the cases of A/B testing and soft personalisation, the number of variants for a single response type is relatively small, while the number of variants for individual personalisation is large.</p><figure><img alt="A diagram showing two actors: New visitor and Returning visitor. A box labelled Variant A data has an arrow to a box Variant A, which has an arrow to New visitor. A box labelled Variant B data has an arrow to a box Variant B, which has an arrow to Returning visitor." src="https://cdn-images-1.medium.com/max/746/0*9z89KPOWBhhkTs-q" /><figcaption>Different visitor types get different variants, based on different variant data</figcaption></figure><p>Assuming a high cache hit ratio without variants, the cache hit ratios for internal HTML requests have an inverse relationship to the number of variants: when the number of variants is low, cache hit ratio is likely high, and vice versa.</p><p>After the HTML response is rendered by the browser, a couple of things can happen. Either:</p><ul><li>Nothing, since the interactive elements in the HTML are links or forms</li><li>One or several JavaScript applications get rehydrated (see <a href="https://web.dev/articles/rendering-on-the-web">Rendering on the web</a> for details). ESI together with rehydration (possibly lazy rehydration) is similar to an <a href="https://www.patterns.dev/vanilla/islands-architecture">Islands architecture</a>.</li><li>(In theory, a hypermedia JavaScript library like <a href="https://htmx.org/">htmx</a> could also be used instead of rehydration)</li></ul><p>IKEA.com serves customers from 50 countries around the world and we want each of our customers to have a great experience, in turn requiring great web performance. However, when starting to server-side render HTML, we need to think about <em>where</em> we do that. The simplest way <em>for an engineer</em> would be to render in a single server location, but that would break the web performance for customers far away from that location. The optimal distribution for our <em>customers</em> would be to render server-side as close to them as possible. Thus, we want to have variants <em>and </em>great web performance. Enter edge computing.</p><h3>Edge computing</h3><p>My colleague Debapriya has previously <a href="https://medium.com/flat-pack-tech/edge-computing-all-about-where-and-when-you-need-it-f2725ab1310b">written about edge computing</a>. In the context of IKEA.com, it means to be able to distribute compute close to our customers.</p><p>However, acquiring the capability of edge computing introduces questions around <em>how</em> we do that:</p><ul><li>Should our teams build edge computing themselves — distributed <em>build</em>?</li><li>Should we instead build a central edge computing platform in-house — central <em>build</em>?</li><li>Should we buy the capability from a vendor — central <em>buy</em>?</li></ul><p>Leaving some details aside, we today offer a <em>central</em> edge computing platform to our teams, reducing their cognitive load so that they can focus on solving customer problems.</p><p>This means that our teams can treat the network of compute locations as a single<em> global serverless</em> solution. For example, when they deploy code, it gets deployed <em>globally</em>. And when they observe metrics about their application, the metrics too are global by default (but can be drilled down into for example regions).</p><p>In summary, enabling our teams to deploy their server-side rendering code to an edge computing platform creates the capability to render the different variants close to our customers, which in turn gives us what we want: variants <em>and</em> great web performance.</p><p>But this introduces another challenge: where does the data for our variants come from?</p><h3>Data for the variants</h3><p>If we would render variants at the edge but have our data in a central location, we would gain very little since the edge servers would have to wait for the central API requests to return until they could render the HTML. So it’s crucial that the necessary data is also available close to our customers. Depending on the data and use-cases, there’s different trade-offs and patterns. The<a href="https://en.wikipedia.org/wiki/CAP_theorem"> CAP theorem</a> (or <a href="https://en.wikipedia.org/wiki/PACELC_theorem">PACELC theorem</a>) comes into play, with architectural patterns like <a href="https://martinfowler.com/bliki/CQRS.html">CQRS</a> and eventing/messaging. A more in-depth description is unfortunately out of scope for this blog post.</p><p>For both A/B testing and personalisation, there needs to exist an identifier of the visitor or customer, like a session cookie. If there’s no existing identifier, it needs to be created <em>server-side</em> and <em>before</em> any dependent functionality is executed — otherwise the customer would experience inconsistencies between their first page view and subsequent navigation.</p><h3>A/B testing</h3><p><a href="https://medium.com/@thisisflea/a-good-hash-is-hard-to-find-6edbbf6a78b0">A good hash is hard to find</a> is a great article on how A/B testing bucketing can work. Given an identifier from a cookie, the only additional data we need is <em>configuration data</em> about the experiments themselves. Thus, the data set for A/B testing bucketing is relatively small and easily cacheable — great! Also, if the number of simultaneous A/B tests for a module is low, the number of variants will be low and thus cache hit ratio will be high for the internal HTML requests.</p><figure><img alt="A labelled arrow Identifier goes to a box labelled A/B bucketing from the left. From that box, the are two arrows. A downward arrow labelled fetch goes to a cylinder labelled Configuration and a rightward arrow goes to a box labelled Variant data." src="https://cdn-images-1.medium.com/max/888/1*Op2utFIsJiImoR2WdXmNMA.png" /><figcaption>Based on an identifier, the A/B bucketing reads configuration, performs the bucketing and returns variant data</figcaption></figure><p>However, if experiments also can depend on <em>customer data, </em>that data needs to be available close to the customer.</p><h3>Soft personalisation</h3><p>In soft personalisation, we personalise based on customer groups. Members in a group share one or more properties. Some of these properties are <em>derived properties</em> and can be calculated offline and in batch. Properties can be persisted on <em>smaller</em> and <em>distributed</em> customer objects — similar to the CQRS pattern. Regardless, the customer data set is <em>large</em>, and <em>not cacheable</em> between customers.</p><p>Thus, in order to have the necessary data for creating the HTML variants for soft personalisation, we <em>must</em> request the customer object containing this data — there’s no way around this. But these requests can be cached within<em> a session</em>, making the system a bit more efficient.</p><figure><img alt="A labelled arrow Identifier goes to a box labelled Personalisation service from the left. From that box, the are two arrows. A downward arrow labelled fetch goes to a cylinder labelled Customer data and a rightward arrow goes to a box labelled Variant data." src="https://cdn-images-1.medium.com/max/880/1*uCkC0g0JVmxiV3Gk0hK6PA.png" /><figcaption>Based on an identifier, a personalisation service reads the customer data, performs the personalisation and returns variant data</figcaption></figure><p>The good news is that if the number of properties that we personalise on is low, we have the same situation as for A/B testing with high cache hit ratio for the internal HTML requests.</p><h3>Individual personalisation</h3><p>Individual personalisation shares some of the concepts from soft personalisation, but the main differences from our perspective are that the variants are not cacheable between customers and that there’s often more compute involved within the request chain, for example recommendation engines.</p><p>It’s outside the scope of this blog post to further expand on individual personalisation. Instead, let’s dive deeper into caching.</p><h3>Caching with Edge Variant Service</h3><p>From a cache key perspective, we need to find how to <em>collapse</em> the cache key space from individual (i.e. session identifier) to variants. Also, we need to figure out <em>where</em> to cache.</p><h3>Edge Side Includes and Caching</h3><p>In a web architecture with static delivery, caching the ESI composition works well. However, this model breaks down when introducing variants for the internal HTML requests. Three years ago, we disabled caching of the ESI composition, while keeping the cache for the internal HTML requests.</p><p>Looking at ESI and caching of variants, we saw an opportunity: if the layer that produces the ESI composition is not cacheable, what if we could also do the cache key collapsing here? Then we could have a single uncacheable layer and still let the underlying layers be cacheable (except for the customer data requests).</p><p>We started to develop a service that we call the Edge Variant Service (EVS). EVS is responsible for forwarding the necessary information to the HTML rendering edge services. To know what data to forward, we rely on configuration. For example, the configuration tells us which A/B testing projects belong to which internal routes and what other data they need, i.e. customer data properties and cookies. This way, the HTML rendering services only get a minimal amount of data and we can maintain as high a cache hit ratio as possible.</p><p>Important to note is that the ESI resolution and configuration look-ups need to be <em>tightly</em> integrated, i.e. before a fragment is requested it needs to be decorated with additional context. The context comes from A/B testing bucketing and/or soft personalisation bucketing, which we can generalise to <em>variant data generators</em>.</p><figure><img alt="A labelled arrow Page template goes into a box labelled ESI execution. An arrow labelled Fragment requests is going out of the ESI execution box. A smaller box labelled Hook is inside the ESI execution box. From the Hook box, there’s an arrow going to a box labelled Variant data generator." src="https://cdn-images-1.medium.com/max/1024/0*3XhezlCdOOYELFZG" /><figcaption>Before a ESI fragment gets fetched, the variant data generator is called and additional context is added to the request</figcaption></figure><h3>Cache key design: Translate data to query strings</h3><p>When caching HTTP requests in a CDN or cloud, the simplest and default approach is that the <em>URL</em> is the cache key (with or without query string). Therefore, we translate all information that should be passed to the underlying HTML rendering services to query string parameters, i.e.</p><ul><li>A/B testing buckets</li><li>Customer data properties</li><li>Cookies</li><li>Request headers</li></ul><p>An example internal HTML request query string could look like this:</p><ul><li>?navigation=next-nav</li><li>?isReturningVisitor=true</li><li>?customerName=Gustaf (not cacheable between customers)</li></ul><p>This way, we can continue to have a simple cache configuration at the cost of a more complicated mapping logic. This is a good design trade-off, because the mapping code is easier to test and requires less specialised competence compared to cache configuration. However, the length of the URL needs to be monitored so it doesn’t exceed the platform limits.</p><h3>Local testing</h3><p>In order to get a fast feedback loop for our engineers, we need support for <em>local development</em>, i.e. that an engineer can run a service on their own computer, including EVS. Local development support is an important non-functional requirement for the central edge computing platform.</p><p>Testing in a microfrontends architecture shares similar challenges as in a microservices architecture. Unless we re-introduce coordination of releases (and we don’t want to do that), there’s no guarantee that the system you’re testing is the exact system you’ll find in production, because things might change between when you test and when you release. Instead, we acknowledge that there’s a trade-off between speed and thoroughness (see the <a href="https://en.wikipedia.org/wiki/Efficiency%E2%80%93thoroughness_trade-off_principle">ETTO principle</a>), that local testing gives us speed, and that the only environment that ultimately matters is production. There’s an excellent article related to this topic: <a href="https://copyconstruct.medium.com/testing-in-production-the-safe-way-18ca102d0ef1">Testing in Production, the safe way</a> by Cindy Sridharan.</p><p>Since EVS is a key component for ESI composition, A/B testing and personalisation, we needed to figure out a way to distribute it for local development. We also needed to distribute configuration tailored to local development needs, so that an engineer can test their code <em>together</em> with our internal test site (or even the production site). Today, we distribute EVS and its configuration as an internal npm package. It’s also possible for engineers to override configuration entries if multiple modules are being worked on or are needed for other reasons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*lDRY3s4XXNfu2Mnu" /></figure><h3>Summary</h3><p>In order to solve the challenges with static content described in <a href="https://medium.com/flat-pack-tech/ikea-com-the-problems-with-static-content-3cd750a5f529">my previous blog post</a>, we’ve started to server-side render HTML <em>variants</em> using Edge Computing. The variants need data, which comes from A/B testing configuration and customer data. Fetching customer data can easily become a performance issue, and here the CQRS pattern can help.</p><p>To cache the variants, we have built a service called Edge Variant Service (EVS), which also is responsible for ESI resolution.</p><p>Local testing is important and supported in the platform, together with a distribution of EVS and configuration for local testing needs.</p><p>Big thanks to Lukas Vermeer (Vista), Martin Gudmundsson, Robin Whittleton, and Mats Johansson for reviewing this blog post and providing valuable feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcce97f6314f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flat-pack-tech/server-side-rendering-ikea-com-with-edge-computing-fcce97f6314f">Server-side rendering IKEA.com with Edge Computing</a> was originally published in <a href="https://medium.com/flat-pack-tech">Flat Pack Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IKEA.com — the problems with static content]]></title>
            <link>https://medium.com/flat-pack-tech/ikea-com-the-problems-with-static-content-3cd750a5f529?source=rss-ccfe43f325de------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cd750a5f529</guid>
            <category><![CDATA[personalisation]]></category>
            <category><![CDATA[a-b-testing]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-architecture]]></category>
            <dc:creator><![CDATA[Gustaf Nilsson Kotte]]></dc:creator>
            <pubDate>Thu, 31 Aug 2023 13:50:59 GMT</pubDate>
            <atom:updated>2023-08-31T13:50:59.346Z</atom:updated>
            <content:encoded><![CDATA[<h3>IKEA.com — the problems with static content</h3><p>In my <a href="https://medium.com/flat-pack-tech/history-of-ikea-com-static-files-and-microfrontends-6def9d7c4285">previous blog post</a>, I wrote about the history of IKEA.com going from a monolithic e-commerce platform to a modular web architecture delivered using static files.</p><p>In this post, we’ll go through the problems related to A/B testing and personalisation in this static files based architecture.</p><p>These problems then become the drivers for us to change the web architecture towards server-side rendering using Edge Computing: “If we want to increase A/B testing and personalisation, and we can’t do that without also increasing the <em>problems</em> they create in this web architecture, we need to change the web architecture”.</p><h3>Table of Contents</h3><ul><li>Static content</li><li>A/B testing and Personalisation</li><li>As-is problem statement</li><li>A/B testing sub-problems</li><li>Personalisation sub-problems</li><li>From Static content to Dynamic content</li></ul><h3>Static content</h3><p>The majority of the HTML page responses for IKEA.com is served from <em>static content</em>, using pre-rendered HTML files uploaded to a file store. The rest of the page responses are Single-Page Applications. Static pages and SPAs can contain static <em>fragments </em>and JavaScript components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ahpLqZUegIkq1tYVJr7PIw.png" /><figcaption>The Static files pattern enables Static content and client-side JavaScript</figcaption></figure><p>Static content has been a great pattern for us, since it easily enables Web Performance, Availability, Security, and SEO. We currently have 40 million “active” static files, i.e. being updated and serving traffic.</p><p>However, we have encountered problems when increasing the use of A/B and personalisation using the static pages approach.</p><h3>A/B testing and Personalisation</h3><p>Before going through the problems, let’s have a very short introduction to the concepts.</p><h4>A/B testing</h4><p>A/B testing (or A/B/n testing) allows us to get fast and reliable feedback that the changes we do to IKEA.com increase the customer value <em>in reality</em>. And inversely, that the changes we do have no clear unintended negative side-effects.</p><p>Verifying changes using A/B testing does not replace other important practices like user research, but instead <a href="https://medium.com/booking-product/multiplication-instead-of-division-7b57d9d7800b">amplifies them</a>.</p><p>The last twelve months, we have conducted 1100 A/B tests on IKEA.com and the goal for the next twelve months is to grow this number by at least 30%. My own ambition is that <em>all</em> changes to IKEA.com should be possible to A/B test (with some exceptions, i.e. changes to DNS).</p><h4>Personalisation</h4><p>From a high-level perspective, personalisation is the practice of presenting different experiences to different users. Some important factors are:</p><ul><li>The <em>granularity</em> of the personalisation, i.e. purely individual, user segments, or geo location</li><li><em>How</em> the functionality of the site is changing due to the user properties, i.e. displaying the user’s name, picking more <em>relevant</em> <em>content</em> for the user’s segment, or changing the order of content/components to be as relevant as possible</li><li>Where the <em>data</em> is coming from, i.e. user settings, logged in profile data, click-streams, and geo location APIs</li><li>Related to user settings, how to handle users logging in and out in different devices, and how to resolve possible data conflicts</li><li><em>When</em> to update the user UI, i.e. near real-time, hourly, daily, weekly. For example changing the layout of a page within a session would likely confuse the user</li></ul><p>It’s important to stress that Compliance (including GDPR), Privacy, and Ethics are also crucial factors here.</p><h4>Two sides of the same coin</h4><p>A/B testing and Personalisation in their essence both present different things to different users. The difference is that in A/B testing we want users to be <a href="https://medium.com/@thisisflea/a-good-hash-is-hard-to-find-6edbbf6a78b0">assigned to test groups randomly and the assignment between tests are fully independent</a>, but in Personalisation we want to change the experience based on the user’s behaviour over time and their context.</p><p>The consequence of this is that A/B testing bucketing would almost always be a faster operation than Personalisation, because A/B testing only needs access to a seed, a configuration, and a hashing function. Personalisation needs access to user data, which then needs to be available in a performant way globally.</p><h3>As-is problem statement</h3><p>Without any other tools than static files and client-side JavaScript, the only option for static content teams to implement A/B tests and Personalisation is to use client-side JavaScript because static files can contain no logic in themselves. Client-side JavaScript has a clear <a href="https://www.youtube.com/watch?v=ZKH3DLT4BKw">performance impact</a>, impacting our <a href="https://web.dev/vitals/">Core Web Vitals</a>, which in turn is a <a href="https://www.linkedin.com/pulse/impact-core-web-vitals-seo-2023-shailesh-gupta#:~:text=Core%20Web%20Vitals%20are%20important,way%20to%20measure%20that%20experience.">ranking factor for SEO</a>.</p><p>At IKEA.com we have already seen an increase of <a href="https://web.dev/cls/">Cumulative Layout Shift</a> (CLS) happening in production due to A/B testing and Personalisation of certain features. Unless we do something different, when we increase our use of these practices over time, we will also increase the problems associated with these practices.</p><p>CLS is not the only problem associated with these practices. I’ll try to cover the other problems below. However, some of these problems only happen in some cases, which makes it hard to get a sense of the total size of the problem. Therefore, I’ll try to decompose the problem into different sub-problems, when they occur, and what the impact is.</p><h3>A/B testing sub-problems</h3><p>In this scenario, we assume that “A” is already statically rendered, and we alter the experience with client-side JavaScript to B (if the user is bucketed into B).</p><h4>Cumulative Layout Shifting (CLS)</h4><p>Measuring CLS in the large is <a href="https://web.dev/evolving-cls/">not trivial</a>. Also, it’s important to point out that the Google Core Web Vitals measurements are done in real user experiences measured in Chrome and visible in the <a href="https://developer.chrome.com/docs/crux/about/">CRuX</a> reports.</p><p>Most web navigations are “forward”, which makes it very important that <a href="https://en.wikipedia.org/wiki/Above_the_fold">above-the-fold content</a> has low CLS. But we should also not forget users navigating<em> backwards</em>, which will navigate to their last scroll position on the previous page.</p><p>If we assume that above-the-fold content is the most valuable information on a page (why is it otherwise there?), we can also assume to have a higher ratio of A/B tests above-the-fold.</p><h4>Flickering (Flash of Original Content)</h4><p>Flickering is similar to CLS in the sense that the user experiences that elements are <em>replaced</em> in the browser. The difference is that these replacements don’t cause a layout shift.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*PSoPVBCLtbBR5dBGHXqLLQ.gif" /><figcaption>Flickering image, B replacing A</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*upEVf1iQVOHyezVSaSZR3w.gif" /><figcaption>Flickering button actions, worst case example</figcaption></figure><p>According to my knowledge, there exists no web performance metric for flickering in web browsers. But it’s still a web performance problem to solve (in my opinion), even if we need to rely on visual tests in order to detect the problems.</p><h4>Biased/uncertain experimentation process</h4><p>CLS and flickering are performance problems, which makes the user experience worse. However, in an A/B testing context we can sometimes <em>also</em> get a positive effect, since UI elements that move/blink can increase the attention from the user.</p><p>An experimentation process should be as unbiased as possible, so that we can trust the results. A/B testing is a method to create a “<a href="https://en.wikipedia.org/wiki/Ceteris_paribus">all other things being equal</a>” environment, where we can measure the differences between A and B in isolation.</p><p>But if we introduce both positive and negative factors of unknown magnitudes into the system, can we then trust the results? For example, a bad scenario would be that we measure that B is better than A, but when we properly release B into production we see that it’s not better, because we had noise in our experimentation process. Or the opposite: in another test we measure that B is <em>not</em> better than A, when in reality the negative effects of CLS and flickering is cancelling out the true value increase caused by B.</p><p>CLS can be measured, so if we have zero CLS increase in the test we can rule out that factor. However, flickering can’t be measured, so we wouldn’t know (not at scale at least) if flickering is biasing our tests.</p><h4>Poor developer experience during experimentation</h4><p>If we want A/B testing to be adopted at larger scale, we need developers to be able to A/B test in their current web development paradigm. But for the static content teams, they need to implement their tests using client-side JavaScript. Then, if B wins, they need to take that code and adapt that to their static content generation web paradigm.</p><p>This approach might be ok for A/B testing in smaller scale, but not when it’s becoming an integrated part of a team’s workflow.</p><h3>Personalisation sub-problems</h3><h4>Cumulative Layout Shifting (CLS)</h4><p>If we don’t reserve screen real estate for personalised content <em>or</em> if the personalised content is not fixed height (width is often less of a problem), CLS will occur when the personalised content is rendered.</p><p>If the order of components is changed in order to increase relevance, CLS is almost guaranteed to happen.</p><p>Again, CLS (and flickering) is mostly applicable for above-the-fold content, even if we shouldn’t neglect backward navigation.</p><h4>Search Engine Optimisation risks</h4><p>Search Engine Optimisation (SEO) is very important for IKEA.com. Search engines is also part of the user journey for our users: if a user enters a search term, we want to help search engines to display as relevant results as possible. A fundamental piece of this is to allow search engines to crawl effectively, in order for them to index and rank both new content and updated content.</p><p>The <a href="https://developers.google.com/search/docs/crawling-indexing/large-site-managing-crawl-budget">faster our pages load and render, the more Google is able to crawl</a> for the limited crawl budget we have.</p><h3>From Static content to Dynamic content</h3><p>Static content has been instrumental to help us build, scale, and operate IKEA.com for our globally distributed customers. As long as the files contain the correct information, the operational work from the teams is minimal. And since the files already contain the HTML needed to render the pages, static content enables great web performance and effective SEO crawling.</p><p>However, as described above, increased A/B testing and Personalisation introduces great challenges that are not possible to overcome in the static content web development paradigm. Therefore, we much change the web architecture from Static content to <em>Dynamic</em> content, i.e. server-side rendering.</p><p>Server-side rendering enables us to respond with different responses depending on the properties of the customer, i.e. A/B testing seed and customer data. The challenge here is to implement server-side rendering in a way that still enable the product teams to easily build web solutions with great global web performance, effective SEO crawling, and with great developer experience. In other words, we want to keep the great properties of the current web architecture, while adding dynamic capabilities. And here’s where Edge Computing is an important technology going forward.</p><p>The next blog post in the series will cover more about Edge Computing from a web perspective.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cd750a5f529" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flat-pack-tech/ikea-com-the-problems-with-static-content-3cd750a5f529">IKEA.com — the problems with static content</a> was originally published in <a href="https://medium.com/flat-pack-tech">Flat Pack Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[History of IKEA.com: Static files and Microfrontends]]></title>
            <link>https://medium.com/flat-pack-tech/history-of-ikea-com-static-files-and-microfrontends-6def9d7c4285?source=rss-ccfe43f325de------2</link>
            <guid isPermaLink="false">https://medium.com/p/6def9d7c4285</guid>
            <category><![CDATA[team-topologies]]></category>
            <category><![CDATA[web-architecture]]></category>
            <category><![CDATA[conways-law]]></category>
            <category><![CDATA[micro-front-end]]></category>
            <dc:creator><![CDATA[Gustaf Nilsson Kotte]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 15:20:18 GMT</pubDate>
            <atom:updated>2023-06-26T15:20:18.002Z</atom:updated>
            <content:encoded><![CDATA[<p>A few weeks ago, we at Ingka Digital decommissioned IKEA Retail Web (IRW), a monolithic e-commerce system that has been in production for 20 years. IRW has served us very well over the years, but now it was time to say good bye.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DFq4j7H6pTO6NfiQfIRycQ.jpeg" /><figcaption>Thank you IRW!</figcaption></figure><p>As Mats mentions in the post, we have replaced IRW with a Microfrontends architecture. That’s the modularity aspect of the new architecture. The other aspect is how we deliver HTML: we use static files (ca 40 million of them).</p><p>IKEA.com is today developed by 50+ central product teams for 48 countries, where 25 countries have some form of feature development in addition to the central deliveries. In 2022, IKEA.com had over three billion sessions, which is around 100 sessions per second (roughly a low G on a guitar).</p><p>In this blog post I’ll look back on the most important events and concepts, according to me.</p><h3>Background</h3><p>Early 2016, I was one of the first people in a team which mission was to create an intermediate web solution on top of IRW. There was already another big monolithic web platform that was planned to replace IRW, but it struggled, so there were two main reasons why to create an intermediate solution:</p><ul><li>Be able to enhance/improve IRW with additional and improved experiences “right now”</li><li>Be able to support IKEA’s launch in India a few years later with a great mobile web experience (not possible for IRW and the new monolithic web platform could not meet that timeline)</li></ul><p>This was forming a great <em>“Think big, start small”</em> approach: we could s<em>tart small</em> by creating new web sections “on the side” of IRW, and then start to replace parts of the mobile web experience — implementing a <a href="https://martinfowler.com/bliki/StranglerFigApplication.html">strangler fig application</a> approach. And we could <em>think big</em> by having the long-term goal of having a full mobile web experience in India. Even if the focus was mobile web, we chose to support “large tablets in landscape mode” so that the step from mobile web to a responsive web would be a smaller.</p><p>The initial goal was to enhance the site with an inspirational content section within 3–4 months.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*o_337KzcDzduNbVDrD8BXg.png" /><figcaption>The workshop box where the modern IKEA.com was created. We worked here in the initial 6–8 weeks. Imagine the walls being completely covered with post-its and design prototypes.</figcaption></figure><h3>Static files</h3><p>The team was a small cross-functional <a href="https://docs.aws.amazon.com/whitepapers/latest/introduction-devops-aws/two-pizza-teams.html">two pizza team</a> with Product, Engineering, and UX people. We needed to create a solution that would:</p><ul><li>have a fast time-to-market</li><li>handle the traffic volumes of the IKEA web visitors, in the magnitude of billion visits per year</li><li>have a great web performance, in all the countries that IKEA is present in</li><li>not “drown” the team in operational work (robustness)</li><li>be as secure as possible from cyber attacks</li></ul><p>How could we solve for all the above constraints, with such a small team? The idea of <em>static files</em> came up: if we could upload static files to a robust storage, we would be able to scale globally with minimal operational work and with great web security. And creating HTML in static files is quite easy, enabling a fast time-to-market.</p><p>We initiated a great collaboration with the CDN team, both to host our files in three locations (plus fail-overs) and to eventually create a highly effective caching solution (48h TTL + cache purge when files are uploaded).</p><h3>HTML Modularity with Edge-Side Includes</h3><p>However, we almost immediately saw a major flaw in the static files approach: a change the common elements of the web pages (i.e. the header navigation) would force us to recreate the entire site — not great. What we lacked was <em>modularity</em>.</p><p>From earlier projects, some team members had prior knowledge of <a href="https://en.wikipedia.org/wiki/Edge_Side_Includes">Edge-Side Includes</a> (ESI): a <a href="https://www.w3.org/TR/esi-lang/">web standards proposal</a> from 2001 that allows HTML fragments to be included by other HTML, like this:</p><pre>&lt;esi:include src=”/path/to/fragment” /&gt;</pre><p>If we extracted i.e. the header navigation to its own HTML fragment, we could then reuse it by including it using ESI. Our CDN supported ESI, so this was an easy decision.</p><p>We were able to meet the timeline and the initiative got more and more traction and responsibility, but eventually our team grew to 20–25 people and we started to sense problems in our agile morning stand-up. We were effectively 2–3 sub-teams in the larger team and the standups started to become too long and unfocused. We needed to split the team.</p><p>We could split the team either into frontend/backend teams (“horizontal”), or to continue with the cross-functional teams approach (“vertical”). There were pros and cons with both approaches, but we could see that the vertical approach would scale better when the number of teams increased. If we split into frontend/backend, it would only be a matter of time until those teams would become bottlenecks.</p><h3>Microfrontends with Edge-Side Includes</h3><p>We split the large team into three teams:</p><ul><li>CMS (stream aligned team¹)</li><li>Product presentation (stream aligned team)</li><li>Framework (platform team)</li></ul><p>In retrospect, splitting the team was an <a href="https://martinfowler.com/bliki/ConwaysLaw.html">Inverse Conway Maneuver</a> that caused enough friction to create the Microfrontend architecture IKEA.com has today.</p><p>We already had support for modular HTML, but we needed to come up with a frontend architecture that worked both from a local team autonomy and a system-as-a-whole perspective.</p><p>Inspired by the <a href="https://martinfowler.com/articles/microservices.html">original Microservices article</a>, we came up with three architectural goals:</p><ol><li>Great web performance</li><li>Scalable development — enabling Continuous Delivery for the many teams</li><li>Evolvability–being able to change parts of the system without the need for central coordination</li></ol><p>(2) and (3) are very similar and follow the Microservices characteristic of <a href="https://martinfowler.com/articles/microservices.html#DecentralizedGovernance">Decentralised Governance</a>, allowing the teams to choose (and change) their own tools as long as the system maintains a great web performance.</p><p>In short:</p><ul><li>each team is responsible for their delivery</li><li>page teams own their own head/body tags</li><li>no shared frameworks/libraries/css in the browser</li><li>separate <em>content fragments </em>from <em>resource fragments,</em> where the latter contain cache busted links to JS/CSS dependencies</li><li>use namespaces in the HTML to decouple</li></ul><p>During this time, I also wrote down a more detailed description of “how” on a <a href="https://microservice-websites.netlify.app/">personal website</a>.</p><h3>Dynamic use-cases with JavaScript</h3><p>In order to be able to have a complete web experience–in turn to eventually support the launch of IKEA.com in India–we needed to support more dynamic use-cases, i.e.:</p><ul><li>Search</li><li>Cart</li><li>Checkout</li></ul><p>Since we already had support for static files, we didn’t need to change anything in the web architecture to support SPAs. Even better, these applications could include the header/footer using ESI, improving <a href="https://web.dev/fcp/">First Contentful Paint</a>.</p><p>By adding JavaScript and APIs to our static HTML markup, we had created our own modular <a href="https://en.wikipedia.org/wiki/Jamstack">JAMStack</a>.</p><h3>People, process, tools</h3><p>While the architectural properties of HTML delivery through static files and Modularity through ESI is the architectural foundation, there are many other important tools and processes in the socio-technical system, including:</p><ul><li>Our Design System <a href="https://www.youtube.com/watch?v=yPLY-FFf7OY">SKAPA</a></li><li>Documentation, on-boarding process, presentations, slack channels</li><li>Upload Service: abstracting file upload and cache purge (we have changed file origin three times, without noticeable impact from the teams)</li><li><a href="https://web.dev/csp/">Content Security Policy</a>: an AllowList of what client-side requests are allowed</li><li>Self-hosted instance of <a href="https://polyfill.io/v3/">Polyfill.io</a>: only serve polyfills if they are needed</li><li>Handling redirects as a failure mode: only check for redirects if origin responds with 404</li></ul><h3>Summary</h3><p>With a “Think big, start small” approach, a small team managed to create increased customer value within a short period of time, while also creating the foundation for the web architecture that we have today.</p><p>Creating (and maintaining) the aspect of cross-functional teams was a major success factor.</p><p><a href="https://mcfunley.com/choose-boring-technology">Old and trusted</a> technologies can sometimes be used for new problems — lowering the <a href="https://itrevolution.com/articles/cognitive-load/">cognitive load</a>.</p><p>This was also a great example of working using <a href="https://about.ikea.com/en/about-us/ikea-culture-and-values">IKEA’s key values</a>, including Renew &amp; Improve, Togetherness, and Simplicity.</p><p>The next blog post in the series will cover why IKEA.com needs to move its HTML delivery mechanism from static files towards server-side rendering using Edge Computing.</p><h3>Footnotes</h3><ol><li>Team Topologies terminology, see <a href="https://teamtopologies.com/key-concepts">https://teamtopologies.com/key-concepts</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6def9d7c4285" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flat-pack-tech/history-of-ikea-com-static-files-and-microfrontends-6def9d7c4285">History of IKEA.com: Static files and Microfrontends</a> was originally published in <a href="https://medium.com/flat-pack-tech">Flat Pack Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>