Getting frequent 504s with medium sized PDFs and ocr_only and hi_res strategies
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- nginx, python
- Ambito
- api, backend, infrastructure
Direzione di ricerca
Inizia con il percorso della richiesta API self-hosted esercitato da partition_via_api e con la richiesta curl equivalente, quindi esamina la relazione tra il timeout del gateway nginx e l'elaborazione OCR di PDF di lunga durata del server. Riproduci il problema con il PDF collegato di 39 pagine e ocr_only o hi_res, e considera il problema risolto quando la richiesta viene completata senza un 504 né lavoro scartato lato server.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Sending a single PDF (this one: https://arxiv.org/abs/2310.12931, embedded text, 39 pages) to the self hosted API, with either ocr_only or hi_res strategy.
The server has 32GB RAM, 8 CPU cores and a CUDA enabled GPU, ressources are below 20% CPU and 5% RAM when processing the PDF.
The Unstructured API version is v0.0.61.
The server responds with 504 after some 20 to 30s and the client caller via partition_via_api will try again for some time.
In the server logs I can see, that each time a new request is made it is properly worked on, printing out '[...] unstructured INFO Processing entire page OCR [...]' and the server does not crash.
However the client detaches and discards the request, so when the server is done processing, it is just discarded.
On the client side I get
INFO: Response status code: 504 Retry attempt #1. Sleeping 1.4 seconds before retry.
INFO: <html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>
leaving the process running on the server and triggering a new one which gets detached in a similar fashion.
I tested the same call on the officially hosted API and the results was there after some 5m:30s.
Question: Is there some setting I can make on the server side to avoid that? It is obviously running on the officially hosted service so the answer should be yes. Could you hint me the right way to go with this?
To Reproduce
Calling the API like this:
from unstructured.partition.api import partition_via_api
API_BASE_URL = "....."
result = partition_via_api(
"files/2310.12931.pdf",
strategy="ocr_only",
api_url=f"{API_BASE_URL}/general/v0/general/",
)
- Filetype: PDF (see above for exact file)
- Any additional API parameters: The server runs with UNSTRUCTURED_MEMORY_FREE_MINIMUM_MB="4096"
Environment:
- Using the hosted API or self hosting?
- using the self-hosted API
- How are you calling the API? (Langchain, SDKs, cUrl, etc.)
- Calling via Unstructured API SDK
partition_via_api
- Calling via Unstructured API SDK
Additional context
Update: The same happens when calling the API with cURL like so:
curl -X "POST" "$API_BASE_URL/general/v0/general" \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F files=@files/2310.12931.pdf \
-F 'strategy=ocr_only'
minus the retry part, because cURL simply stops after a single attempt.
On the server side the behaviour stays the same, the process keeps running until properly finished and is then discarded because the client detached.
- Lingua principale
- Python
- Stelle
- 953
- Fork
- 192
- Merge medio
- 1g 1h
- PR unite (30g)
- 5
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Unstructured-IO/unstructured-api
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 39/100
-
Dependency DashboardAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 15/100
Tutte le issue di Unstructured-IO/unstructured-api
Issue simili
-
bug needs-triage priority:medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
yeongseon/azure-functions-logging-python#583 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation needs-triage priority:medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
yeongseon/azure-functions-validation-python#546 ·
I maintainer di solito rispondono entro 1 giorno
-
PHP workflow streaming requests buffer the full SSE responseForse già presa @Winoren l’ha presa oggi. Apertareview: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
langgenius/dify#44270 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
P4: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
jeffknupp/association#523 ·
-
bug help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
DarkStarSystems/pcons#229 ·
I maintainer di solito rispondono entro 1 giorno