nayaread
HomeFavouritesTopicsSources
HomeFavouritesTopicsSources
NayaRead links to original engineering blogs. All copyright belongs to the respective authors.
Shopify Engineering·Dec 14, 2018·7 min read42

How an Intern Released 3 Terabytes Worth of Storage Before BFCM - Shopify

Hi there! I’m Gurpreet and currently finishing up my second internship at Shopify. I was part of the Products team during both of my internships. The team is responsible for building and maintaining the products area of Shopify admin. As a developer, every day is another opportunity to learn something new. Although I worked on many tasks during my internship, today I will be talking about one particular problem I solved. The Problem As part of the Black Friday Cyber Monday (BFCM) preparations, we wanted to make sure our database was resilient enough to smoothly handle increased traffic during flash sales. After completing an analysis of our top SQL queries, we realized that the database was scanning a large number of fixed-size storage units, called innoDB pages, just to return a single record. We identified the records, historically kept for reporting purposes, that caused this excess scanning. After talking among different teams and making sure that these records were safe to delete, the team decided to write a background job to delete them.So how did we accomplish this task which could have potentially taken our database down, resulting in downtime for our merchants? The Background Job I built the Rails background job using existing libraries that Shopify built to avoid overloading the database while performing different operations including deletion. A naive way to perform deletions is sending either a batch delete query or one delete query per record. It’s not easy to interrupt MySQL operations and doing the naive approach would easily overload the database with thousands of operations. The job-iteration library allows background jobs to run in iterations and it’s one of the Shopify libraries I leveraged to overcome the issue. The job runs in small chunks and can be paused between iterations to let other higher priority jobs run first or to perform certain checks. There are two parts of the job; the enumerator and the iterator. The enumerator fetches records in

MySQL
Read original on shopify.engineering

Score breakdown

  • Technical depth46
  • Practical value30
  • Originality100
  • Writing quality100
  • Source reputation0
  • Recency0
  • External engagement0
  • On-site engagement0

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

More like this

Dropbox Tech

Improving storage efficiency in Magic Pocket, our immutable blob store

Ilya Yakovlev +10 others·Apr 2, 2026·13 min read
Etsy — Code as Craft

The So-fine Real-time ML Paradigm

Kyle Gallatin·Sep 5, 2023·5 min read
Shopify Engineering

Future Proofing Our Cloud Storage Usage - Shopify

Feb 26, 2018·7 min read
Shopify Engineering

High Availability by Offloading Work Into the Background - Shopify

Jul 8, 2021·16 min read