Home / AI & GenAI

AI & GenAIRunbookAdvanced

Sev1: Azure AI Search returning 503 under load. RAG assistant failing at peak

RAG answers fail or time out at peak because Azure AI Search throttles queries with 503. Confirm throttling, pause indexers, add replicas, and fix client retries and query cost.

Deepak Bhardwaj7 min read

Applies toAzure AI Search (Basic and Standard tiers), Azure CLI, Search REST API 2024-07-01, Azure Monitor

Symptoms

  • The assistant answers "I couldn't find anything" or errors out, mostly during business peaks.
  • Application logs show 503 Service Unavailable from https://<service>.search.windows.net/indexes/<index>/docs/search.
  • Indexing calls return 207 Multi-Status with some documents failing with status 503.
  • Search latency climbs from tens of milliseconds to seconds before the errors start.

Azure AI Search returns 503 when the service has no spare capacity for the request. It is load shedding, not an outage of the service. The fix is to reduce load or add capacity, and you can do both in the next 15 minutes.

1. Confirm scope and impact

Check that the errors are throttling and not something else (network, auth, a deleted index):

RG=rg-ai-prod; SVC=srch-prod
ID=$(az search service show -g $RG -n $SVC --query id -o tsv)

az monitor metrics list --resource $ID \
  --metric ThrottledSearchQueriesPercentage SearchLatency SearchQueriesPerSecond \
  --interval PT5M --offset 3h -o table
What you see Meaning Go to
ThrottledSearchQueriesPercentage above 0 and rising with QPS Query capacity exhausted Steps 2 and 3
Throttling only while an indexer runs Indexing competes with queries Step 2
No throttling, but 503 in the app Network path, private endpoint or gateway Check DNS and the proxy, not Search
404 on the index Index deleted or renamed Different incident
401/403 Key or RBAC change Different incident

Check the service size and state:

az search service show -g $RG -n $SVC \
  --query "{sku:sku.name, replicas:replicaCount, partitions:partitionCount, status:status, provisioning:provisioningState}" -o table

A single replica has no headroom and no SLA for queries. If this shows replicas: 1, that is likely your root cause.

If diagnostic logs go to Log Analytics, find which index and which operation is hot. Column names below apply to the AzureDiagnostics table; check yours if you use resource-specific tables.

AzureDiagnostics
| where ResourceProvider == "MICROSOFT.SEARCH" and TimeGenerated > ago(1h)
| summarize calls = count(),
            throttled = countif(ResultSignature == "503"),
            p95_ms = percentile(DurationMs, 95)
          by OperationName, IndexName_s, bin(TimeGenerated, 5m)
| order by TimeGenerated desc

2. Take load off the service now

Pause indexers that run during the peak

Indexers share replicas with queries. Disable the schedule until the peak passes. Fetch the definition, set "disabled": true, and put it back:

TOKEN=$(az account get-access-token --resource https://search.azure.com --query accessToken -o tsv)
BASE="https://$SVC.search.windows.net"

curl -s "$BASE/indexers/docs-indexer?api-version=2024-07-01" -H "Authorization: Bearer $TOKEN" \
  | jq 'del(."@odata.context", ."@odata.etag") | .disabled = true' > indexer.json

curl -s -X PUT "$BASE/indexers/docs-indexer?api-version=2024-07-01" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d @indexer.json -o /dev/null -w "%{http_code}\n"

Use an api-key header instead of the bearer token if the service does not have RBAC enabled for the data plane.

Also pause any custom push jobs (Functions, Databricks jobs, scripts) that upload documents with /docs/index.

Stop retry storms

A client that retries a 503 immediately multiplies the load. If you have a gateway or a feature flag, temporarily:

  • Turn off "retry on 503" with zero delay, or raise the backoff.
  • Lower top (for example 50 to 10) and remove facets from RAG queries. The LLM only uses the first few chunks anyway.
  • Turn off the semantic ranker for low-value traffic if it is enabled. It has its own capacity limits; check the current limits for your tier.

3. Add replicas

Replicas add query capacity. Partitions add storage and some indexing throughput; they are not the fix for query throttling.

az search service update -g $RG -n $SVC --replica-count 3

Warning

Scaling is not instant. It can take from a few minutes to much longer on a large index, and the service keeps serving at the old capacity while it runs. Start the change early, then do the other mitigations while you wait. Replicas are billed per unit; check the current pricing for your tier before going above what your budget owner approved.

Watch progress:

watch -n 30 "az search service show -g $RG -n $SVC --query '{replicas:replicaCount, state:provisioningState, status:status}' -o tsv"

Notes:

  • The Free tier cannot scale. If production runs on Free, plan a move to a paid tier; there is no quick fix.
  • Each tier has a maximum replica and search unit count. Check the current limits for your tier before you request a number.
  • Two replicas give the read SLA; three give read and write SLA.

4. Make the client behave

Retry 503 and 429 with exponential backoff and jitter, and give up quickly so the user gets a fallback answer instead of a hung request.

import random, time
from azure.core.exceptions import HttpResponseError
from azure.search.documents import SearchClient

def search_with_backoff(client: SearchClient, text: str, attempts: int = 4):
    for i in range(attempts):
        try:
            return list(client.search(search_text=text, top=8,
                                      select=["id", "title", "chunk", "source_url"]))
        except HttpResponseError as e:
            if e.status_code not in (429, 503) or i == attempts - 1:
                raise
            time.sleep(min(8, 0.5 * 2 ** i) + random.random() / 2)

Query cost matters as much as query count:

Expensive pattern Cheaper version
select missing, returns every field including vectors select only the fields the prompt needs
top=50 then the app keeps 5 top close to what the prompt uses
Vector k much larger than needed Lower k; tune with your evaluation set
Wildcard or regex in search text Filter on a filterable field
Same question asked many times Cache results for a short TTL

5. Verify recovery

az monitor metrics list --resource $ID --metric ThrottledSearchQueriesPercentage SearchLatency \
  --interval PT1M --offset 30m -o table
  • Throttled percentage back at 0 through a peak period.
  • p95 search latency back to baseline.
  • Application error rate and "no results" answers back to normal.

Then re-enable the indexer (same steps as above with .disabled = false) outside the peak and check that a run completes without throttling queries:

curl -s "$BASE/indexers/docs-indexer/status?api-version=2024-07-01" -H "Authorization: Bearer $TOKEN" \
  | jq '.lastResult | {status, itemsProcessed, itemsFailed, startTime, endTime}'

Tell users

"The knowledge assistant is returning errors or empty answers during busy periods. We have added search capacity and are watching recovery. Answers may be slower for the next 30 minutes. Next update at HH:MM."

Prevent it next time

  • Run production on at least 2 replicas (3 if you index during business hours).
  • Alert on ThrottledSearchQueriesPercentage > 0 for 5 minutes and on p95 SearchLatency above your baseline.
az monitor metrics alert create -g $RG -n srch-throttling --scopes $ID \
  --condition "avg ThrottledSearchQueriesPercentage > 0" \
  --window-size 5m --evaluation-frequency 1m --severity 1 \
  --action <action-group-id>
  • Schedule indexers and bulk re-indexing outside peaks; throttle push jobs on 207/503 responses.
  • Load-test retrieval with realistic queries (vector + filters + semantic) before launches and record the QPS per replica you measured.
  • Keep the replica count in Bicep or Terraform so a redeploy does not scale the service back down.