Investigating Unexplained Bandwidth Spikes on September 24th

18 replies
Last updated: Oct 2, 2023
Hi Sanity Help,
I noticed spikes in bandwidth usage which do not not entirely correspond with other usage metrics (see attached).

This is a tiny project with virtually no users so the high bandwidth usage is odd. I would like to identify the cause of the high bandwidth usage before adding new users.

Could you please provide logs or other data that could help me identify the cause of the high bandwidth consumption? I am interested in 24th September in particular.

Many thanks,

User
AI Update

I understand your concern about the bandwidth spike! The good news is that Sanity provides Request Logs that can help you identify exactly what's causing high bandwidth usage.

How to Access Your Request Logs:

  1. Go to your project settings at sanity.io/manage
  2. Navigate to the Usage section
  3. Scroll to the bottom of the page
  4. Download your log data (you can get up to 1GB of logs from the last 7 days, including September 24th if you're still within that window)

Note: New exports can be requested every 24 hours, and logs are available up to the day before the download.

What's in the Logs:

The logs come as GZIPPED NDJSON files and contain detailed information about every request, including:

  • Request Type (API, APICDN, or CDN) - crucial for understanding if it's content queries or asset downloads
  • Full URL with query parameters
  • Remote IP addresses - helps identify if traffic is coming from unexpected sources
  • User Agent strings - can reveal bots or scrapers
  • Referrer information
  • Timestamps for pinpointing exact spikes
  • GROQ Query Identifier - helps group similar queries together

Analyzing the Logs:

You can convert the compressed logs to CSV for easier analysis:

gunzip --stdout [logfile].ndjson.gz | npx json2csv --ndjson --output output.csv

Or use tools like jq, GROQ CLI, Jupyter Notebook, or even upload samples to ChatGPT for help identifying patterns.

Common Culprits for Bandwidth Spikes:

Based on community cases, common causes include:

  • Bot traffic or scrapers hitting your API
  • Missing dependencies in useEffect hooks causing request loops
  • Large asset downloads (images/videos)
  • Inefficient queries running repeatedly
  • CDN cache misses causing repeated fetches

Important: Filter out studioRequest entries when analyzing - those are from Sanity Studio and don't count toward your bandwidth usage or costs, so they won't explain billing spikes.

If you're outside the 7-day window or need more detailed assistance for September 24th specifically, you can contact Sanity support directly through the manage interface, and they can help you investigate specific dates using the Trace IDs and Span IDs in the logs.

Show original thread
18 replies
Hey,
user V
. Although I'm not part of the Sanity team, there are some quick solutions you can employ here.First, it is common for projects to fetch data all the time from Sanity. If your website is targeted by a bot or even a malicious user, this can cause spikes in data usage.
The most common solution to problems of that nature is adding a caching mechanism which will stop data from being fetched on repeat.
Hi
user Z
, thank you for your response. Hopefully the Sanity team will be able to retrieve data about the requests which are causing these spikes.
Can you share your project ID?
Hi
user M
, certainly. I have DM-ed (not sure public they are)
They’re not considered secret but that’s ok!
OK, it looks like the main consumers are mp3 files. This one in particular is the largest:
<https://cdn.sanity.io/files/u1y1uu6u/production/2fd7254ab4676e2c40fc2397888a26d69daf8abf.mp3>
Thanks User. OK that makes sense but I am surprised by the amount consumed, especially on 24th September. Is there there additional metadata, e.g. User Agent?
The project is on the free tier and we’ll naturally upgrade but I just want to ensure I’m not doing anything wrong.
In depth reporting like that is only available on Enterprise plans, unfortunately. What stack are you using for your frontend?
Ok we’re not quite there yet!
There are two frontends:

• iOS app (Sanity content exposed via NodeJS-based API)
• web (NextJS hosted in Vercel) but it doesn’t play audio so won’t consume MP3s
Can I assume that the majority of the bandwidth consumed is due to the audio files?
Did you happen to be doing a lot of development on the24th?
Quite possibly. Will take a look
OK actually I was debugging some playback issues in the app. 3GB is pretty hefty but perhaps the app doesn’t do proper client-side caching of the audio
That sounds like the likely cause!
Ok thanks for your help User.
Much appreciated!
Happy to help!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?