Good working max performance settings. 500 concurrency easy.
This commit is contained in:
parent
f506e5e52b
commit
5ec614bc35
@ -3,8 +3,9 @@ import asyncio
|
|||||||
from concurrent.futures import ThreadPoolExecutor as Executor
|
from concurrent.futures import ThreadPoolExecutor as Executor
|
||||||
import time
|
import time
|
||||||
|
|
||||||
ZAMENYAT_THREAD_COUNT = 500
|
ZAMENYAT_BACKLOG=100
|
||||||
ZAMENYAT_BUFFER_SIZE = 64
|
ZAMENYAT_THREAD_COUNT = 2500
|
||||||
|
ZAMENYAT_BUFFER_SIZE = 4096
|
||||||
ZAMENYAT_HEADER_MAX_LENGTH = 4096*2
|
ZAMENYAT_HEADER_MAX_LENGTH = 4096*2
|
||||||
|
|
||||||
class AsyncWriter:
|
class AsyncWriter:
|
||||||
@ -218,16 +219,16 @@ class Application:
|
|||||||
loop.set_default_executor(self.executor)
|
loop.set_default_executor(self.executor)
|
||||||
return 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.upgrade_executor(ZAMENYAT_THREAD_COUNT)
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
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:
|
async with self.server:
|
||||||
await self.server.serve_forever()
|
await self.server.serve_forever()
|
||||||
|
|
||||||
def serve(self, host, port):
|
def serve(self, host, port,backlog=ZAMENYAT_BACKLOG):
|
||||||
try:
|
try:
|
||||||
asyncio.run(self.serve_async(host,port))
|
asyncio.run(self.serve_async(host,port,backlog=backlog))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Shutted down server")
|
print("Shutted down server")
|
||||||
|
Loading…
Reference in New Issue
Block a user