How to determine the current cache size for Apollo client's InMemoryCache - apollo-client

I need to do some memory usage profiling for a react native app using Apollo Client. Is there an easy way to determine how big the cache has grown at a certain point in time (API call or any other way of determining the size of the InMemoryCache)?

Related

Is it advisable to use GraphQL client cache to manage local state for a significant application?

My team builds and maintains a large enterprise application that uses mobx stores to manage state on the frontend. We are adopting graphql (Apollo Client) for a new project and I see that local state can be modeled in the cache so that it's effectively part of the same store as api data and there is a single source of truth for the whole application. This would seem to obviate the need for external store solutions (e.g. Redux or Mobx stores). I am wondering whether people have had success doing this? Is it commonplace?

how to design a high performance distribution system with a shared resource?

My project has a problem with CPU performance for signle server. I think make the project to a distribution system would a way to handle this problem. But, my project core part is based on a shared resource(a map with roads info) which is probobly changed by tons of client at the 30ms level. Any client would change part of the shared map.
The problem is that server needs the all map info to calculate. And the map would be a high frequency write and read resouce. If use data syncronized middleware, like a redis cluster, I think it can not support the 30ms level considering of the network time cost.
Is there any middleware or system model able to handle it?

Blazor webassembly: manage memory usage on client

We plan to make static some classes containing the data we get from the server so that when we move out and get back to the page we can show them immediately and offer to the user the possibility to hit a button to refresh them. So basically we are using static fields as cache.
As the app is quite big we are worried that this could cause memory problems on (less powerful) clients.
Is there a way to check how much memory the client has, and how much memory is used by that particular static field?

Caching on web player

I'm creating a runtime obj importer in unity, but I need create a cache system on my web player. I tried "PlayerPrefs" but is to small to store all information. Is there another possibility to store information in client side, close 10MB.
Client-side caching is usually done in memory for speed. If your data can't fit in memory, then you'll need to write it to the local drive or send it to the back-end.
Since the local file storage is unavailable in the Unity3D Web Player, you'll have to either send it to some sort of back-end or develop and in-memory store by hand.
Hope it helps.

Faster API access via javascript or server-side libraries

I would like to display information obtained from a web-API. (say, instagram or last.fm)
Is there generally a noticable speed difference between using a serverside (Ruby) or clientside (JS) API library?
I would guess Javascript would be faster since you can contact the API asynchronously once the page has loaded in the client's browser
Just wondering if there is a "best practice" for this since API libraries generally exist for both client-side and server-side.
Each way has pro and cons, one really isn't better or worse than the other for a general case, you have to use what makes sense in your situation.
With a small amount of data / operations, you will most likely be throttled by the web request itself, not the processing power of either JavaScript or Ruby.
I haven't made an exhaustive list, but some general things to consider:
Client Side:
Processing power is pushed over to the client, you use less resources, but performance will vary.
API must support either JSONp or Access-Control-Allow-Headers.
Very slow for large operations on large data sets.
Any API key will be viewable by any visitor to your website.
Initial response time from your server will be quicker, but if you load most of your content from an API request, you'll still have to wait.
Server Side:
Won't expose an API key to the client.
Uses more resources, but can handle larger amounts of data/operations
Will take a longer amount of time to return the initial page.
Sometimes has additional user features/methods since oAuth or other security features are supported.
One big difference is that the JS API does not add load on your server, so it makes it easier to scale your web app.
Also, in general using JS is likely to be faster to the user because the client's browser will be getting the data directly from the web-API server, rather than going via your server.

Resources