From 5ec614bc356ebd37121888084f6836f6bdce278c Mon Sep 17 00:00:00 2001 From: retoor Date: Wed, 18 Dec 2024 04:14:00 +0100 Subject: [PATCH] Good working max performance settings. 500 concurrency easy. --- src/zamenyat/app.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/zamenyat/app.py b/src/zamenyat/app.py index b0eea3b..e8222ce 100644 --- a/src/zamenyat/app.py +++ b/src/zamenyat/app.py @@ -3,8 +3,9 @@ import asyncio from concurrent.futures import ThreadPoolExecutor as Executor import time -ZAMENYAT_THREAD_COUNT = 500 -ZAMENYAT_BUFFER_SIZE = 64 +ZAMENYAT_BACKLOG=100 +ZAMENYAT_THREAD_COUNT = 2500 +ZAMENYAT_BUFFER_SIZE = 4096 ZAMENYAT_HEADER_MAX_LENGTH = 4096*2 class AsyncWriter: @@ -218,16 +219,16 @@ class Application: loop.set_default_executor(self.executor) return self.executor - async def serve_async(self, host,port): + async def serve_async(self, host,port,backlog=ZAMENYAT_BACKLOG): self.upgrade_executor(ZAMENYAT_THREAD_COUNT) self.host = host self.port = port - self.server = await asyncio.start_server(self.handle_client, self.host, self.port) + self.server = await asyncio.start_server(self.handle_client, self.host, self.port,backlog=backlog) async with self.server: await self.server.serve_forever() - def serve(self, host, port): + def serve(self, host, port,backlog=ZAMENYAT_BACKLOG): try: - asyncio.run(self.serve_async(host,port)) + asyncio.run(self.serve_async(host,port,backlog=backlog)) except KeyboardInterrupt: print("Shutted down server")