Azure / Azure/azure-sdk-for-python

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

Open
#44,449 3 comments 0 reactions 0 assignees View on GitHub
customer-reported Document Intelligence needs-team-attention question Service Attention
Dominant language
Python
Stars
5.6k
Forks
3.4k
Avg merge
1d 21h
Merged PRs (30d)
193

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.