I noticed that we are doing a lot of WS queries to a whole set of different templates, which appears it is significantly slowing down the application. ( a total of 12 MB was downloaded on the Issuance Page #/app/issuance/issuances
I counted 43 Websocket Streams including TemplateIds which may not be related (and not be required ) to display any data on this specific page.
The only required Template may be Daml.Finance.App.Issuance.Model:Issuance
I’ve relied on the ticket, copying in here for reference:
We use React contexts throughout the app to load up the most important contracts upfront. So when you log in as a user the following contracts are loaded:
All services
All instruments
All holdings
All accounts
Each of these contexts opens a stable websocket connection for each template type, so that would explain the number of streams you’re seeing.
We do this primarily to speed up subsequent loading of sub-pages in the app. These contexts are state-ful so that accessing the contracts within them is instantaneous (after the initial load). So you should only see these streams being opened once upon login. This is of course a specific design decision, and there are other ways to optimize this. We have gone for optimizing for speedy app usage, so are willing to accept the initial delay and stream overhead.
Note that the streams are recycled quite aggressively (1min timeout), so that we don’t hit the limit if we repeatedly switch parties during a demo.