Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungI built an agent that refuses to answer Next.js from stale docs(24.09.2026 um 03:17 Uhr)
Sichere ProgrammierungI vibe-coded a Next.js knowledge base that argues with itself(24.09.2026 um 03:17 Uhr)
Linux Tipps & HardeningUbuntu speeds up kernel security updates because of AI(24.09.2026 um 03:01 Uhr)
IT Security NachrichtenGoogle's PageBreak Project – Real-World Findings(24.09.2026 um 02:00 Uhr)
IT Security NachrichtenAI spend will jump 49.5% in 2026, says Gartner(24.09.2026 um 03:26 Uhr)
IT NachrichtenAI spend will jump 49.5% in 2026, says Gartner(24.09.2026 um 03:26 Uhr)
Sichere ProgrammierungI built an agent that refuses to answer Next.js from stale docs(24.09.2026 um 03:17 Uhr)
Sichere ProgrammierungI vibe-coded a Next.js knowledge base that argues with itself(24.09.2026 um 03:17 Uhr)
Linux Tipps & HardeningUbuntu speeds up kernel security updates because of AI(24.09.2026 um 03:01 Uhr)
IT Security NachrichtenGoogle's PageBreak Project – Real-World Findings(24.09.2026 um 02:00 Uhr)
IT Security NachrichtenAI spend will jump 49.5% in 2026, says Gartner(24.09.2026 um 03:26 Uhr)
IT NachrichtenAI spend will jump 49.5% in 2026, says Gartner(24.09.2026 um 03:26 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Why is My Multi-Threaded API Still Slow?

I'm facing an issue with my API, and I'm hoping someone can help. Despite adding multi-threading, the performance gains are far from what I expected. Ideally, if one thread takes 1 second to complete a task, then 10 threads running…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

I'm facing an issue with my API, and I'm hoping someone can help. Despite adding multi-threading, the performance gains are far from what I expected. Ideally, if one thread takes 1 second to complete a task, then 10 threads running concurrently should also take about 1 second (that's my understanding). However, my API response times are still very slow.






The Problem



I'm using FastAPI along with libraries like Playwright, MongoDB, and ThreadPoolExecutor. The goal was to use threading for CPU-bound tasks and async-await for IO-bound tasks. Still, my response times are not improving as expected.






Book Automation Example



One part of my project involves automating book queries using Playwright to interact with an EPUB viewer. The following function uses Playwright to open a browser, navigate to a book's page, and perform searches:




from playwright.async_api import async_playwright
import asyncio

async def search_with_playwright(search_text: str, book_id: str):
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
page = await browser.new_page()
book_id = book_id.replace("-1", "")
book_url = f"http://localhost:8002/book/{book_id}"
await page.goto(book_url)
await page.fill("#searchInput", search_text)
await page.click("#searchButton")
await page.wait_for_selector("#searchResults")
search_results = await page.evaluate('''
() => {
let results = [];
document.querySelectorAll("#searchResults ul li").forEach(item => {
let excerptElement = item.querySelector("strong:nth-of-type(1)");
let cfiElement = item.querySelector("strong:nth-of-type(2)");

if (excerptElement && cfiElement) {
let excerpt = excerptElement.nextSibling ? excerptElement.nextSibling.nodeValue.trim() : "";
let cfi = cfiElement.nextSibling ? cfiElement.nextSibling.nodeValue.trim() : "";
results.push({ excerpt, cfi });
}
});
return results;
}
''')
await browser.close()
return search_results






The function above is meant to be async to avoid blocking other tasks. However, even with this async setup, the performance is still not as expected.

Note: I've calculated the time taken to open book and run query a single book is approximately 0.0028s





Refactor Example



I used run_in_executor() to execute functions in ProcessPoolExecutor, trying to avoid the GIL and properly manage workloads.




async def query_mongo(query: str, id: str):
query_vector = generate_embedding(query)

results = db[id].aggregate([
{
"$vectorSearch": {
"queryVector": query_vector,
"path": "embedding",
"numCandidates": 2100,
"limit": 50,
"index": id
}
}
])

# Helper function for processing each document
def process_document(document):
try:
chunk = document["chunk"]
chapter = document["chapter"]
number = document["chapter_number"]
book_id = id

results = asyncio.run(search_with_playwright(chunk, book_id))
return {
"content": chunk,
"chapter": chapter,
"number": number,
"results": results,
}
except Exception as e:
print(f"Error processing document: {e}")
return None

# Using ThreadPoolExecutor for concurrency
all_data = []
with ThreadPoolExecutor() as executor:
futures = {executor.submit(process_document, doc): doc for doc in results}

for future in as_completed(futures):
try:
result = future.result()
if result: # Append result if it's not None
all_data.append(result)
except Exception as e:
print(f"Error in future processing: {e}")

return all_data









Question



Even after these changes, my API is still slow. What am I missing? Has anyone faced similar issues with Python's GIL, threading, or async setups? Any advice would be greatly appreciated!

SOC Incident Playbook: Vulnerability Remediation & Verification
title: Detect Exploitation - Why is My Multi-Threaded API Still Slow?
id: 750aa8d3-9b78-4599-9a29-bdbea1604f56
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Why is My Multi-Threaded API S" ascii wide
    condition:
        any of them
}
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Why is My Multi-Threaded API Still Slow?.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Why is My Multi-Threaded API Still Slow?

Thematisch verwandte Begriffe: MultiThreaded, Still, Slow · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-96676 | A vulnerability was identified in Fast FAC1900R 20190827_2.0.2. The impa…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick