archethic-foundation / archethic-foundation/archethic-node

Improving connection timeout

Open
#642 1 comment 0 reactions 1 assignee Claimed by @Neylix View on GitHub
P2P
Dominant language
Elixir
Stars
82
Forks
24
PR merge metrics
No merged PRs in 30d

Description

### Is your feature request related to a problem?

Actually the timeout for a request is based on a flat duration defined by a floor connection speed and the maximum size of the request / expected request response.
This behavior works but is not really accurate and can be optimized.

### Describe the solution you'd like

Timeout calculation should be calculated by the couple node / message.
For each node and each message we calculate the time between the send and the response.
For a node and a message we can keep in memory the last 50 (to adjust) times to get the response.
Based on these 50 times we can calculate using percentile a more precise timeout for the request (maybe with 15% marge error).

Some messages contains various data size. For these messages, we can precise it's maximum size, and so when receiving the request response, we can get the response size and adapt the timeout with this calculation `timeout = (request time * max_size) / request_size`

### Additional context

This behavior will increase and adapt the timeout for each node and each message, but this may take some data in memory.
Let's assume we use 2 bytes to store a time (which is 65 sec maximum)
Storing 50 times represent 100 bytes
We currently have 33 request messages which represent 3 300 bytes for a node
With 200 nodes connected this represent 660 000 bytes (660 KB)

We can improve this as many messages have the same size so we can reduce the number of messages to monitor.
We can also monitor only messages for authorized and available nodes. Other node can have default timeout

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.