Questions about Communication Client <-> Server

Hello,

maybe you could help me because I was not able to find the infomrations that I need. I have some questions about the client (browser) - serverside - communication.
As far as I know the data communication (changes in state object) uses JSon. Is it correct? Does it use optimizations/compression out of the box? Are there possibilities to do something like this (change configuration, use other JSon libraries, …)?
In my scenario I have some thousand objects of the same type which I need at client side and it needs its time before they are available on client side (you can also see it in debugger/profiler).
For example all the objects have the same structure, there are a lot of repeating values in the objects, …
Or are there other possibilies to speed up communication?

Thanks a lot…

Hi,

just a few comments: compression at least should be usable from the application container level as usual (e.g.
server.xml in Tomcat
). I’m not sure if it’s possible to change the JSON library, but if your data format is inefficient, that probably wouldn’t solve your problems anyway.

-Olli

And what format you would suggest? Actual I have a bean container with properties like this:

  • start: int
  • end: int
  • height: int
  • offset: int
  • tooltip: int
  • additionalStart: int
  • additionalEnd: int
  • infoStart: List<String/Icon>
  • infoMiddle: List<String/Icon>
  • infoEnd: List<String/Icon>
  • editMode: Enum
  • id: String
  • groudId: String
  • infoStrategyData: StrategyData (Bean container)

Propertynames could only have one char, I could describe the data structure only once and every bean reference it (what would be the right place to do it? Best would be in the workflow which encrypts and decrypts JSON data), …
Also the info properties contains much repeating data. How to handle that (put all Strings in a map with a short key and reference that keys, …)?
As far as I know there also exists JSON libraries that can do such things (extract data structure and so on), that’s why I asked how to change the JSON library. It would be stupid if I have to do everything by myself.

Thanks, Philipp

It of course depends on the shape of your data and the workings of your client-side component - there is no simple one-size-fits-all solution. One thing to think about: do you need all of the data immediately, or can you load some of it lazily with RPC? It won’t affect the total number of bits transferred, but the user experience will possibly improve if you can load data only when it’s actually needed.

Map can be used in shared state and it could be quite good (especially if you have sensible default data you can substitute for missing key), but again, it really depends.

Registering custom JSON serializers / deserializers is theoretically doable, although IIRC you will need to make some small adjustments in the visibility of some framework fields to get that done. I know some people have done (or attempted) that, but I’m not aware of any documentation on the subject.

-Olli