TL;DR: With Black Friday and Cyber Monday just around the corner, you’ll need to make sure your app is ready to scale on a whim.
It’s that time of year again. Anyone in ecommerce has a love/hate relationship with Black Friday, Cyber Monday because although it means an increase in sales, it also means there’s a lot of work that needs to be done to prepare.
For Shopify app developers, that means that no matter what, your app can’t see downtime. You have to make sure your infrastructure is ready to handle increased loads, webhooks, data processing. Here are our tips on keeping your app performant over the craziest weekend of the year.
Typically, the bulk of the traffic you’ll see during the BFCM weekend will be from storefront traffic, and that means more orders and activity that will trigger webhooks to your app. To save on costs, one of the ways you can manage the increase is by configuring any and all webhook traffic to be handled in a background job where possible. By adding a queue between webhook reception and webhook processing, you create a buffer for any spikes in traffic, which will help prevent dropping webhooks entirely. If you want more tips on how to handle syncing data from Shopify, you can read about our recommended best practices in this blog. Shopify has some best practices docs that are a great starting point if you’re looking to learn.
In the last year, Gadget has handled more than 500 million webhooks, and we’re ready for more. We handle the Shopify read rate limits and webhook subscriptions for your Gadget app, taking care of all of the queue infrastructure for incoming webhooks, and running daily reconciliation jobs to make sure nothing ever gets missed.
Depending how your app handles data, flash sales, higher order volume, and larger orders can all put a heavy burden on your infrastructure. Your app can generally expect up to 10 times as much traffic as it might see the weekend before BFCM, or any other time of the year, so it’s important to prepare for an influx of data pouring into your backend. You can expect the increase in traffic to have more writes to your database, because of the more traffic and orders hitting the stores that have installed your app..
Apps built with Gadget automatically scale up resources based on traffic, so you don't need to worry about doing that yourself. Everything from your database, to your API, to your frontend, is kept performant and scaled by the platform. So no matter how many and big flash sales that merchants using your app have, it will automatically adapt in an instant as needed..
With the drastic increase in traffic to your app, beyond webhooks, the biggest concern is having too many queries sent to the database, which can end up overwhelming it. One easy way to fix this is ensuring both your code and your queries are performant by indexing your queries where possible. For example, one thing to consider is removing as many N+1 queries as you can, and instead run two queries, one to get the products, one to get the variants, so you can avoid having the number of queries be dependent on the number of products.
One of the ways Gadget helps with the performance of your database is by ensuring all your fields are indexed, making it so queries are always fast. It’s easy to make your code performant with Gadget because the platform stores the previous state of records, so you know what has recently changed, which makes it easier to avoid any redundant work. If a record hasn’t changed since the last time your app received a webhook for it, Gadget won’t issue any changes to that record.
As you and your app get ready for the biggest weekend of the year, remember to take breaks and cut yourself some slack as bugs and issues inevitably pop up. For anyone that has already built an app with Gadget, your app’s infrastructure will easily handle any sudden influx of traffic, leaving you more time to focus on supporting merchants throughout the weekend.
If you want to talk about preparing for Black Friday and Cyber Monday with some fellow Shopify app developers, join the Gadget Discord! You’ll be among friends.