Size your playlist transfer queue from two numbers, and never multiply them together. The first is your MusicAPI rate limit: 300 requests per minute for the whole partner account, counted across every key and credential you hold, in one fixed 60-second window. The second is the billing meter, which counts the requests MusicAPI sends outward to music streaming services on your behalf. The pricing model puts that at roughly 60 source requests for a typical 2,000-song library, plus about 120 destination requests when MusicAPI writes the destination too. Different traffic, different window, different consequence when you cross it. Your queue shape comes from the first number. Your invoice comes from the second.
The two meters, side by side
| Dimension | Rate limit | Billing meter |
|---|---|---|
| What it counts | Your calls to /public/* and /api/* | Requests MusicAPI sends to a music streaming service |
| Window | One fixed 60-second window | Calendar month, cumulative buckets |
| Ceiling | 300 requests per minute per partner account | No cap on volume in the top bucket |
| When you cross it | 429 with Retry-After: 60 | Nothing fails, the invoice grows |
| Not counted | Hosted sign-in pages, webhooks | Authentication redirects, dashboard seats, webhooks, sandbox traffic, support |
On MusicAPI Core you own the destination, so only the requests MusicAPI sends to the source service are metered. On MusicAPI Managed Transfers MusicAPI runs both sides, so source reads and destination writes both count as requests. Neither of those is what the 300 per minute limit measures. That limit counts your own calls to /public/* and /api/*: starting a transfer, reading its status, pulling match results, searching the catalog. Hosted sign-in pages and webhooks do not count.
Keep the two apart in your capacity doc, because they fail in opposite directions. Cross the rate limit and requests stop with a 429. Cross a billing bucket and nothing stops: volume discounts apply automatically as buckets fill, and there is no cap on volume in the top bucket. One is a queue problem you solve in code. The other is a forecast you hand to finance, and the pricing page has the bucket arithmetic.
One lever before you design anything: the 300 per minute default is not fixed. MusicAPI can raise the limit of your account or remove it on request. Ask weeks ahead of your peak, not in the minute you start shedding jobs. The rate limits and errors docs carry the current behaviour and the error table.
Size for the peak week, not the average month
Average monthly transfers is the wrong input. Import traffic arrives in bursts, and the bursts usually follow something you did: a launch, a press hit, an email. Spotify's own rate limit guidance makes the point with a familiar example, telling developers that if you notice your website receives a surge in traffic after you send out your weekly newsletter, you might stagger the delivery of those emails over the course of a day. The surge lands in the week your campaign lands.
So plan a peak minute, not a peak month. Take the transfers you expect to start in your busiest hour, divide by 60, and multiply by the number of API calls your backend makes per transfer. That last number is yours to measure, not something to copy from the pricing model: it is the call that starts a transfer, plus whatever status reads, match result reads and catalog searches your code makes around it. Count them in an integration test and write the number down. It is the only multiplier that turns a traffic forecast into a 300 per minute budget.
One account, one budget, so per-worker limits break
Each partner account has one rate limit for all its keys and credentials together. Per-worker throttles cannot enforce that. Ten workers at 30 requests per minute each is exactly 300 while all ten are alive. Autoscale to fifteen during the peak and you are at 450, which is the exact moment you least want 429s.
Use one token bucket per account, shared, in Redis or whatever your workers already agree on. Two details of the MusicAPI limit shape that bucket. It is a fixed window, not a rolling one: the first request starts the window, and the count resets 60 seconds later. And Retry-After: 60 gives the window length in seconds, not the time left in the window. A worker that reads it as time remaining will sleep wrong, and every worker that sleeps exactly 60 seconds wakes at the same instant. Add randomness to the backoff to spread the retries around in time.
Pace the bucket rather than draining it. The docs say it plainly: spread bulk work over time instead of sending it in bursts. A bucket refilling continuously at five requests per second gives you the same 300 a minute without the stampede at the top of the window and the stall at the bottom. A worker process should consume from the queue at a controlled rate that stays within your API quota.
Per-provider limits are the other half of the problem, and they are the half you can hand over. When a music service asks MusicAPI to slow down, the transfer waits and continues by itself. When a service keeps refusing for too long, the transfer fails with errorType: "rateLimited" and failureReason: "rateLimited". Your queue manages your own 300 per minute. Managed Transfers manages the providers' limits, the retries and the paging behind them.
Fair scheduling so one giant library does not starve the rest
MusicAPI already serializes per person. Transfers of one person run one after the other, never side by side, and a second transfer waits until the first one ends, then starts by itself. That protects one user's account. It does nothing for fairness across users.
The failure mode is plain FIFO. One listener whose library is many times the modelled 2,000 songs enters the queue at 09:00, and the 500 listeners who signed up at 09:01 sit behind it. Three fixes, in order of effort:
- Round-robin across per-user queues instead of one global list. A worker takes the next user, then that user's next item.
- Chunk long jobs. A job that handles one playlist and re-enqueues itself gives the worker back between chunks, so a large library interleaves with small ones.
- Split queues by class. Keep onboarding imports, which a user is watching right now, away from background re-syncs. Separate your request queues so batch work never starves real-time features of their rate limit budget.
One cost you do not have to schedule: when a user picks content in the hosted wizard, every wizard screen reads the snapshot MusicAPI took when the account connected, so picking content is fast and costs no extra calls to the service. The transfer itself is the expensive part, and that is what your queue orders.
Backpressure at enqueue beats retries at the API
Decide at enqueue time whether the work fits, and tell the user then. The alternative is accepting everything and discovering the ceiling through 429s, which is the worst place to find it. When a client retries, it spends more of the server's time to get a higher chance of success, and layered retries multiply: Amazon's worked example of five service layers with three retries each turns into a 243x increase in load on the database, making it unlikely to ever recover.
Three rules keep retries honest:
- Retry at a single point in the stack. Pick the worker, not the worker and the HTTP client and the job runner.
- Limit retries with their own token bucket, so calls retry while there are tokens and then retry at a fixed rate once the tokens are exhausted. Same mechanism as your rate budget, separate bucket, so a retry storm cannot eat the budget for new work.
- Branch on the status code instead of retrying everything. A 400 is not valid: fix the request, do not retry it unchanged. A 412 with
internalCode: 14means the music service refused the stored sign-in and MusicAPI could not renew it, and MusicAPI already tried once before answering, so do not retry the call in a loop. Route that user to a reconnect prompt and move on.
Backpressure only works if a deferred job is safe to run later, which means designing the job so a re-run cannot duplicate anything: an API that is idempotent can be safely retried. The per-item version of that is in idempotent playlist transfer. When the queue is deep, give the waiting listener a number rather than a spinner, which is what playlist transfer time works through.
Webhooks instead of polling
Polling spends the budget you are trying to protect. Status reads are calls to the MusicAPI API, and calls to /public/* and /api/* count toward the 300. Webhooks do not count against the rate limit, and authentication redirects, dashboard seats, webhooks, sandbox traffic and support are not metered either, since only requests that leave MusicAPI for a music service are counted. A queue of 2,000 jobs polling every ten seconds is a self-inflicted outage.
So push, do not pull. Your backend follows state changes through webhooks and reads the unmatched items from the Match Results API. Branch on the state rather than on a progress percentage. created, fetching and running mean the transfer reads the source and writes the destination. waitingForReauth means one account needs a new sign-in, nothing is lost, and the transfer continues after the user signs in again or after your backend pushes a new token. completedWithErrors means the transfer ended and some items did not match or failed, which is the only state that needs a product decision rather than a retry. What to do with those per item results is covered in playlist transfer reconciliation.
If you run your own provider apps, the ceiling changes shape
The 300 per minute budget is one ceiling. If you bring your own developer credentials, each provider adds another, and they are not the same shape.
Spotify calculates its rate limit from the number of calls your app makes in a rolling 30 second window, and the limit varies depending on whether your app is in development mode or extended quota mode. Apps in extended quota mode have a rate limit much higher than apps in development mode, the default mode for new apps. You apply for the extension from your app detail page in the Developer Dashboard. Start that before the peak, because the answer does not arrive on your schedule.
YouTube is a daily quota, not a per-minute one. Projects that enable the YouTube Data API get a default allocation of 100 search.list calls, 100 videos.insert calls, and 10,000 units per day combined for all other endpoints. Every request, including an invalid one, costs at least one point, and each request for an additional page of a paged result incurs the quota cost again. A per-minute limit recovers in 60 seconds. A daily quota does not recover until quotas reset at midnight Pacific Time. Drain the day's units at 11:00 and the rest of the day's imports are finished, and no backoff strategy repairs that.
This is where the build versus buy line usually sits for a queue. On MusicAPI's managed credentials the floor is explicit: MusicAPI bills the greater of your metered usage and €500 per month. You are trading a known monthly number for the provider access reviews and the daily quota math.
What to instrument before the peak
A boring peak week is one where every number below already has a baseline from a quiet week.
- Your 429 rate against MusicAPI. Log every 429 response with the service name, endpoint, timestamp, and retry delay. Above zero during normal traffic means your bucket is already wrong.
- Time a job spends waiting for a token, p50 and p99. This is your queue's real latency, and it moves long before anything breaks.
- Queue depth and the age of the oldest waiting job, per class. Age is the fairness metric, depth is only the volume metric.
- Requests per transfer, measured rather than modelled. Compare it to the roughly 60 source requests and about 120 destination requests in the pricing model and find which transfers are the outliers.
- Transfer outcomes split by state, particularly
completedWithErrorsagainstfailed, and how many sit inwaitingForReauth. - Reconnect rate: 412 answers carrying
internalCode: 14. That number tells you how much of your peak is users who cannot start at all.
Set the alert thresholds now, while nothing is on fire, and make the first three page someone. The rest can be a dashboard.
FAQ
Does a transfer that matches nothing still cost requests?
Yes for the reads, no for the retries. The read that found no match counts, because MusicAPI made it, while a provider error that MusicAPI retries does not. Budget for the match attempt, not for the outcome.
Do staging and production share the rate limit?
If they sit on the same partner account, yes. One rate limit covers all the keys and credentials of an account together, so a staging backfill running during your busiest hour takes requests away from production. Give the two separate accounts, or schedule the backfill outside your peak.
Can I load test the queue before going live?
Not at production volume. Every account starts in evaluation with 5 connected users, and a docs sandbox session has its own limit of 30 calls per minute. Rehearse the mechanics there, bucket pacing, backoff, jitter and webhook handling against synthetic jobs, then watch the real numbers through your first production peak.
Skip months of OAuth and per-provider SDK work. Sandbox access is free and not metered, and one API moves libraries between 11 streaming services. Start with how Managed Transfers works.