walkor / walkor/GatewayWorker

Operation timeout in Lib\Gateway sendAndRecv method

Open
#100 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1k
Forks
291
PR merge metrics
No merged PRs in 30d

Description

https://github.com/walkor/GatewayWorker/blob/aefdc21fdf847331a5acbd7e4422cd26d44e5474/src/Lib/Gateway.php#L1157

Under a high load workers turn to a busy state after this exception in `sendAndRecv` method

`stream_socket_client(): unable to connect to tcp://127.0.0.1:2313 (Operation timed out) in GatewayWorker/Lib/Gateway.php on line 1157`

Linux kernel is optimized based on a manual.

I believe the problem is that the connection is closed every time and needs to be open on each new message, because of a `getSession` method call

I also noticed that some other calls of `stream_socket_client()` have STREAM_CLIENT_PERSISTENT flag, but this one does not.

Is it possible to have long-lasting connections here, since it would dramatically increase a performance? If not, how can we prevent this timeout errors?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at src/Lib/Gateway.php line 1157 in sendAndRecv, then inspect getSession and the other stream_socket_client calls that use STREAM_CLIENT_PERSISTENT. Reproduce the timeout under high load and determine whether connection persistence or timeout handling addresses the busy-worker behavior. Done means the timeout errors and resulting worker state are addressed without regressing message delivery.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.