nayaread
HomeFavouritesTopicsSources
HomeFavouritesTopicsSources
NayaRead links to original engineering blogs. All copyright belongs to the respective authors.
Shopify Engineering·Apr 9, 2021·11 min read52

How Shopify Dynamically Routes Storefront Traffic - Shopify

In 2019 we set out to rewrite the Shopify storefront implementation. Our goal was to make it faster. We talked about the strategies we used to achieve that goal in a previous post about optimizing server-side rendering and implementing efficient caching. To build on that post, I’ll go into detail on how the Storefront Renderer team tweaked our load balancers to shift traffic between the legacy storefront and the new storefront. First, let's take a look at the technologies we used. For our load balancer, we’re running nginx with OpenResty. We previously discussed how scriptable load balancers are our secret weapon for surviving spikes of high traffic. We built our storefront verification system with Lua modules and used that system to ensure our new storefront achieved parity with our legacy storefront. The system to permanently shift traffic to the new storefront, once parity was achieved, was also built with Lua. Our chatbot, spy, is our front end for interacting with the load balancers via our control plane. At the beginning of the project, we predicted the need to constantly update which requests were supported by the new storefront as we continued to migrate features. We decided to build a rule system that allows us to add new routing rules easily. Starting out, we kept the rules in a Lua file in our nginx repository, and kept the enabled/disabled status in our control plane. This allowed us to quickly disable a rule without having to wait for a deploy if something went wrong. It proved successful, and at this point in the project, enabling and disabling rules was a breeze. However, our workflow for changing the rules was cumbersome, and we wanted this process to be even faster. We decided to store the whole rule as a JSON payload in our control plane. We used spy to create, update, and delete rules in addition to the previous functionality of enabling and disabling the rules.

Read original on shopify.engineering

Discussion around the web

  • Hacker News17 · 0 💬

Score breakdown

  • Technical depth82
  • Practical value45
  • Originality85
  • Writing quality100
  • Source reputation0
  • Recency0
  • External engagement16
  • On-site engagement0

NayaRead shows a summary and links to the original article. The full article is hosted on shopify.engineering.

More like this

The Cloudflare Blog

Pushing Nginx to its limit with Lua

Dec 8, 2012·11 min read
Etsy — Code as Craft

Improving performance by prefetching product pages from Etsy Search

David Weinzimmer·Oct 29, 2025·11 min read
Engineering at Meta

Introducing Zelos: A ZooKeeper API leveraging Delos

Jun 8, 2022·16 min read
Shopify Engineering

Surviving Flashes of High-Write Traffic Using Scriptable Load Balancers (Part II) - Shopify

Feb 5, 2017·9 min read