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

DevFeed: [Surviving Flashes of High-Write Traffic Using Scriptable Load Balancers (Part II)](<https://devfeed.tech/articles/surviving-flashes-of-high-write-traffic-using-scriptable-load-balancers-part-ii-1633.md>)

Original publisher: [Read original article](<https://shopify.engineering/surviving-flashes-of-high-write-traffic-using-scriptable-load-balancers-part-ii>)

Author: Emil Stolarsky

Published: 2017-02-05T19:30:00Z

Content type: article

Language: en

Sources: [Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering.md>), [Shopify Engineering - Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering-shopify-engineering.md>)

Topics: [Shopify](<https://devfeed.tech/topics/shopify.md>), [Lua](<https://devfeed.tech/topics/lua.md>), [nginx](<https://devfeed.tech/topics/nginx.md>), [datacenter](<https://devfeed.tech/topics/datacenter.md>), [Code](<https://devfeed.tech/topics/code.md>), [Redis](<https://devfeed.tech/topics/redis.md>), [Replication](<https://devfeed.tech/topics/replication.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [data-center](<https://devfeed.tech/tags/data-center.md>), [database](<https://devfeed.tech/tags/database.md>), [load-balancer](<https://devfeed.tech/tags/load-balancer.md>), [lua](<https://devfeed.tech/tags/lua.md>), [nginx](<https://devfeed.tech/tags/nginx.md>), [redis](<https://devfeed.tech/tags/redis.md>), [replication](<https://devfeed.tech/tags/replication.md>), [shopify](<https://devfeed.tech/tags/shopify.md>)

## AI overview

Shopify describes a stateless approach to fairly prioritizing customers during flash-sale checkout traffic. Instead of relying on a database across multiple data centers, each load balancer calculates a queue threshold, while a securely signed cookie stores the customer's initial timestamp. High-priority users then pass through an existing leaky-bucket throttle.

## Source excerpt

7 minute read In the first post of this series, I outlined Shopify's history with flash sales, our move to Nginx and Lua to help manage traffic, and the initial attempt we made to throttle traffic that didn't account sufficiently for customer experience. We had underestimated the impact of not giving preference to customers who'd entered the queue at the beginning of the sale, and now we needed to find another way to protect the platform without ruining the customer experience.