Skip to content

Optimize record file query count in web3 #12477

@bilyana-gospodinova

Description

@bilyana-gospodinova

Problem

As a result of the performed testing in #12164 the following observations were made:

  1. Among all record files the latest one is read the most frequently. It is always the same for all requests in the 2-second window that is valid. Currently it is cached for 500ms and this can be increased up to 2s or at least 1s as we don't need it refreshed that frequently.
  2. There are way too many DB requests that are made concurrently to read the latest record file before it gets cached. In numbers: with only 20% of the real world traffic over a 20-second period there are over 850 actual DB queries (not repository calls) for the latest record file. Even in 3-4 ms period about 20 actual DB calls are made (the average time for the repository call completion is about 80ms). This takes 20 DB connections from the pool that can be used for other queries that are really needed.

Solution

Find a way to optimize the record file DB queries. Ideally, only 1 thread should make the call for the latest record file and all others should just wait for it and read it. Then after 2 seconds when the file expires, it needs to be read again.
Another suggestion is to make the repository call lazily and skip the record file reading wherever possible.

Alternatives

No response

Metadata

Metadata

Assignees

Labels

enhancementType: New featureweb3Area: Web3 API

Projects

Status

👷 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions