Skip to content

Commit

Permalink
Turn of aiohttp connection limit, let's see if it improves p95 lag
Browse files Browse the repository at this point in the history
  • Loading branch information
jstray committed Oct 20, 2024
1 parent 020e491 commit 73e741e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__pycache__/
*.py[cod]
*$py.class
.DS_Store

# C extensions
*.so
Expand Down
8 changes: 2 additions & 6 deletions perspective_ranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
)
from prometheus_client import Counter, Histogram

# each post requires a single request, so see if we can do them all at once
KEEPALIVE_CONNECTIONS = 50

# keep connections a long time to save on tcp connection startup latency
KEEPALIVE_EXPIRY = 60 * 10

dotenv.load_dotenv()
PERSPECTIVE_HOST = os.getenv(
Expand Down Expand Up @@ -193,7 +188,8 @@ async def score(self, attributes, statement, statement_id):
)

if self.client is None:
self.client = aiohttp.ClientSession()
connector = aiohttp.TCPConnector(limit_per_host=0) # don't limit max connections
self.client = aiohttp.ClientSession(connector=connector)

try:
response = await self.client.post(
Expand Down

0 comments on commit 73e741e

Please sign in to comment.