JSON API is slow even for small number of contracts

I know it is recommended to have a database for the query store to use the JSON API effectively. We have this setup on a project, however queries are still slow. There are about 200-300 hundred contracts.

Any thoughts? What should we looking for?

1 Like

Slight correction, the query store is NOT in place. Could this be the reason? The number of contracts does not seem to be that high.

1 Like

15-20s (as you described in another context) is definitely more than I would expect for this type of usecase. In general, I recommend the query backend for all production usecases but I’ll describe performance characteristics for both here. It’s hard to give specific numbers for anything here so I’ll be slightly vague:

  1. Latency and bandwidth between JSON API client, JSON API, database (if used) and the ledger influences response times.
  2. The total ACS size for the templates in your query that are visible to the querying party influences the result. Without the query store, every query will fetch this again from the ledger which can be very expensive for large sizes. With the query store, it will be cached in the database (that’s the whole point of the query store). However, queries still have to filter that down so the total size can still matter.
  3. The size of the result, e.g., if you filter 1000 contracts down to 1, that’s faster than filtering it down to 10 since you have to process the result and send it to the client.
  4. The types of queries you do. The in-memory backend has to traverse the whole ACS and evaluate the query on each contract. The query store handles queries in the database but we do not setup indices by default (JSON query indices are not generic so we cannot do that) so the database might still end up doing a full table scan.
3 Likes

Please define “slow”.

Here are some perf numbers from July, 2020:

Here is the info on how to run the perf tests:

2 Likes

Ummmm… Are you configuring JVM heap size for the JSON API process? I would say enable GC logging and monitor heap usage during the test.

1 Like