Zero-Failure
authorSam Mirazi <sasan345@gmail.com>
Mon, 2 Jun 2025 05:49:36 +0000 (22:49 -0700)
committerSam Mirazi <sasan345@gmail.com>
Mon, 2 Jun 2025 05:49:36 +0000 (22:49 -0700)
benchmark/run_benchmark.py
run_benchmark_NO_RESTRICTIONS.py

index 3aea1a78fae718be009624c1093b5e27fa3add6a..18c5af85286a0f889f4ffbcfc498b66634b7a0ae 100644 (file)
@@ -49,11 +49,12 @@ def run_flask_benchmark(num_requests):
 
 async def fetch_url_async(client, url):
     try:
-        response = await client.get(url, timeout=10) # Increased timeout
+        response = await client.get(url, timeout=20) # Increased timeout from 10 to 20 seconds
         response.raise_for_status()
         return response.status_code
     except httpx.RequestError as e:
-        # print(f"Request to {url} failed: {e}") # Silenced
+        # More verbose error printing
+        print(f"Request to {url} failed. Type: {type(e)}, Str: {str(e)}, Repr: {repr(e)}", flush=True)
         return None
 
 async def run_fastapi_benchmark_async(num_requests):
@@ -61,12 +62,10 @@ async def run_fastapi_benchmark_async(num_requests):
     start_time = time.perf_counter()
     results_list = [] # To store results for final count
     
-    async with httpx.AsyncClient() as client:
+    # Configure httpx limits
+    limits = httpx.Limits(max_connections=500, max_keepalive_connections=50)
+    async with httpx.AsyncClient(limits=limits) as client:
         tasks = [fetch_url_async(client, FASTAPI_URL) for _ in range(num_requests)]
-        # Print a message indicating all tasks are launched and now awaiting completion.
-        # This might be redundant if the parent script already says "launched X/X tasks"
-        # but can be useful for the benchmark script's own log.
-        # print(f"FASTAPI_INFO: All {num_requests} tasks launched, awaiting completion...", flush=True)
         
         completed_count = 0
         for i, task_future in enumerate(asyncio.as_completed(tasks)):
index f2caf196f2dbd16b3692b56d946183a0f6546708..d9a1b3e653bc1ec83ffde0ef991b7f1e8e474a07 100644 (file)
@@ -142,6 +142,15 @@ def run_benchmark_script(framework_arg):
                         final_summary_line = line
                         if progress_line_printed:
                             print("\r" + " " * 80 + "\r", end="", flush=True)
+                    else:
+                        # Print any other lines from the subprocess (e.g., error messages)
+                        if progress_line_printed:
+                            # Clear the progress line before printing the unexpected line
+                            print("\r" + " " * 80 + "\r", end="", flush=True)
+                        print(line, flush=True) # Print the actual error line
+                        if progress_line_printed:
+                            # Reprint the progress line after the error line
+                            print(f"\rFastAPI progress: Completed {requests_done_count}/{NUM_REQUESTS_EXPECTED} tasks...", end="", flush=True)
 
                 process.stdout.close()