Skip to content

Improvements - /account/balance performance #283

@Kartiiyer12

Description

@Kartiiyer12
  • Library/Tool: cardano-rosetta-java (v1.2.1)
  • Network: Mainnet
  • Setup: Docker

Request API Call /account/balance

Request:

POST {{URL}}/account/balance
{
    "network_identifier": {
        "blockchain": "cardano",
        "network": "mainnet"
    },
    "account_identifier": {
        "address": "addr1v804tgee0m3ww7z93zh64wr9flqh9psdhnxg6cykfudgulg6f633p",
        "metadata": {}
    }
}

Result:
The query took 1 min 30 secs to get back the result. Interestingly,

  • If queried again after few blocks, the response is under 2 seconds.
  • Querying after 10 blocks takes 14 seconds to return the result.
  • Querying after 50 blocks (aka 15 min) took a minute to get the response.

Issue
In the logs, I saw warnings as -
`WARN 161879 --- [l-1 housekeeper] com.zaxxer.hikari.pool.ProxyLeakTask : Connection leak detection triggered for org.postgresql.jdbc.PgConnection@13df6ef on thread http-nio-8082-exec-4, stack trace follows

java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) ~[HikariCP-5.0.1.jar!/:na]
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-6.4.4.Final.jar!/:6.4.4.Final]
at `

For which I increased the below env variables-
SPRING_DATASOURCE_HIKARI_LEAKDETECTIONTHRESHOLD=180000

After setting the above env variable, no warning logs appeared as the initial leak detection was default to 1 min.

Background

There was a discussion earlier that we can address balances can be cached when queried and then subsequent call for the balance will only from the previous block when the balance was cached to the latest block which can improve the performance but can take up larger space. The rosetta-java even with only transaction data takes up 644 GB vs entire db-sync taking 512 GB.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    On hold

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions