Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching network calls for RPC returning immutable data #924

Closed
roxaneletourneau opened this issue Jun 9, 2021 · 2 comments
Closed

Caching network calls for RPC returning immutable data #924

roxaneletourneau opened this issue Jun 9, 2021 · 2 comments
Assignees
Milestone

Comments

@roxaneletourneau
Copy link
Collaborator

roxaneletourneau commented Jun 9, 2021

Is your feature request related to a problem and use case? Please describe.
Description from AndreasGassmann:

We are trying to optimise the number of network requests our dapp does. When refreshing a page, we are getting a lot of data from different contracts and storages, which results in a high number of network calls (around 150). Many of them are definitely necessary (eg. getting storage values and bigmap values), but I noticed that the /chains/main/blocks/head/header call is done repeatedly (more than 10 times) during page load. Is it possible to somehow hook into taquito and "cache" those requests? We already cache every ContractAbstraction and storage promise so we can reuse them (and only request the data once), but I don't know how we can prevent the header call. Maybe the easiest will be to just enable caching on the server side.

Describe the solution you'd like
Implement a cache on the RpcClient or HttpBackend class.
Records the number of calls made to each endpoint on our integration tests before and after adding the cache to measure improvement.

Immutable data caching would be a great point to start.
We want to access RPCs that would fit into this category. Examples are script, entrypoint, etc.

Then we will look at other call and can categorize further.

@Innkst Innkst changed the title Caching network calls Caching network calls for RPC returning immutable data Jun 10, 2021
@Innkst Innkst added this to the v10.2 milestone Sep 9, 2021
@michaelkernaghan michaelkernaghan self-assigned this Sep 10, 2021
@michaelkernaghan
Copy link
Collaborator

taquito-http-utils.ts
config.ts

We have an ongoing discussion in Taquito where we want to improve dApps performance by reducing the number of calls that Taquito makes to the RPC. What I am looking for first is some metrics on the current state so we can see how we improve it.
One way would be to measure the number of calls made to the RPC in the different integration tests. This will give us a number of calls for particular scenarios and how the future improvements we make in Taquito can reduce this number.

I first discussed with Michael about using a custom RpcClient, but I think it would be better to use a custom HttpBackend instead. The HttpBackend is the class that provides http functionality for Taquito. The idea is to implement a new HttpBackend class (almost the same as the current one, but it can include a map where the key is an url and the value a number representing how many time the url is called).

Thus, this custom httpBackend can be injected in the TezosToolkit instantiated in the config file of the integration test: https://github.com/ecadlabs/taquito/blob/master/integration-tests/config.ts#L277 and assertions on the number of calls could be added to the different tests.

@michaelkernaghan
Copy link
Collaborator

michaelkernaghan commented Oct 4, 2021

a branch with tests instrumented to count RPC calls has been made. The results are being used to design the caching for RPC calls.

mk-924-caching-for-RPC

roxaneletourneau added a commit that referenced this issue Oct 4, 2021
* Added RpcClientInterface

* Implement an RpcClientCache class
@ac10n ac10n moved this to Done in Taquito Dev Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants