Azure / Azure/azure-sdk-for-python

High CPU usage (100%) when awaiting begin_analyze_document inside Docker/Kubernetes

Ouverte
#44,449 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
customer-reported Document Intelligence needs-team-attention question Service Attention
Langage dominant
Python
Étoiles
5.6k
Forks
3.4k
Merge moyen
2 j 2 h
PR mergées (30 j)
213

Description

---

* **Package Name**: `azure-ai-documentintelligence`
* **Package Version**: `1.0.2`
* **Operating System**: Linux (Docker container, Kubernetes environment)
* **Python Version**: Python 3.x

---

### **Describe the bug**

When using `azure-ai-documentintelligence` inside a Docker container, the application consistently consumes 100% CPU during document analysis.
This occurs even when the container is explicitly constrained to **1 CPU core and 2 GB of memory**.

When deployed in Kubernetes, this behavior causes pods to be terminated with **OOMKill** once CPU usage reaches 100%, despite the simplicity of the workload.

The issue occurs while awaiting the result of `begin_analyze_document`, specifically during `await poller.result()`.

---

### **To Reproduce**

Steps to reproduce the behavior:

1. Build an API using **FastAPI**
2. Build the Docker image:

```bash
docker build -t document-intelligence-test .
```

3. Run the container with explicit CPU and memory limits:

```bash
docker run --cpus="1.0" -m 2g --memory-swap 2g document-intelligence-test
```

4. Monitor resource usage using:

```bash
docker stats
```

5. Execute the following code inside the container:

```python
from azure.ai.documentintelligence import DocumentIntelligenceClient
from azure.core.credentials import AzureKeyCredential
from azure.ai.documentintelligence.models import AnalyzeDocumentRequest

client = DocumentIntelligenceClient(
endpoint="",
credential=AzureKeyCredential("")
)

analyze_request = AnalyzeDocumentRequest(
url_source="https://www.kinea.com.br/wp-content/uploads/2025/05/KNCR_Regulamento_05-2025.pdf"
)

poller = client.begin_analyze_document(
body=analyze_request,
model_id="prebuilt-layout",
output_content_format="markdown"
)

result = await poller.result()
```

---

### **Expected behavior**

CPU usage should remain within reasonable limits while waiting for the document analysis to complete.
The SDK should not fully saturate the allocated CPU core during asynchronous polling.

---
### **Screenshots**

Image

Image

Image

---

### **Additional context**

* Reproducible with a single request and no concurrency
* Occurs consistently inside Docker containers
* Happens even with strict resource limits (`--cpus="1.0"`, `-m 2g`, `--memory-swap 2g`)
* In Kubernetes environments, this behavior results in **OOMKill**
* No custom threading, multiprocessing, or manual polling logic is implemented
* Behavior suggests a possible inefficient or busy-wait polling loop inside the SDK

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par reproduire l’exemple d’une seule requête avec azure-ai-documentintelligence 1.0.2 dans les limites Docker fournies, puis observez l’utilisation du CPU autour de begin_analyze_document et await poller.result(). Inspectez le chemin d’interrogation asynchrone du SDK afin de détecter un comportement d’attente active. C’est terminé lorsque l’analyse du document s’achève sans saturer le CPU limité ni provoquer un Kubernetes OOMKill.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
azure, docker, fastapi, kubernetes, python
Domaine
backend, cloud, devops, performance
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.