Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object Serialization to bytes vs Jackson serialization from Object to JSON?

My question may sound very basic one but I am a bit confused on jackson s writeValueAsString(String) is also called as serialization and conversion of java object to byte stream is also called as Serialization.

Can anyone help me understand; how both of them are different?

The reason I am asking this question is, I got into a scenario where I call a REST service. The REST responds in 10 seconds with JSON. However if I log the time of writeValueAsString(String) on server side, it hardly takes a second.

UPDATE 1: This is what I am observing

  1. Last log on invoked REST service(returning a collection) prints at -->9:10:10 UTC. And, data simultaneously starts streaming on my machines Git bash as I am using curl to call service.

  2. After 10 seconds last log on my Servlet filter( as intercepts the request to REST api uri) prints out at --> 9:10:20 UTC and at the very same time data streaming stops at Git bash(nearly 35Mb downloaded). So, what could be the reason for this behavior?

If Jackson simultaneously started sending bytes over the network while serialization is still on?

Is that Jackson serialization is slow or network bandwidth is low?

Note that, I tried running my serialization and deserialization only using writeValueAsString(..)/readValue(..) operations without any network call through junit with the same set of data and they executes within a second of time.

Thanks

like image 556
Jaraws Avatar asked Apr 02 '26 04:04

Jaraws


1 Answers

Server response time of 10 seconds is not just the serialization time, it includes the:

  • total time of request reaching the REST service server over the network
  • internal processing in the REST service app
  • response reaching your application over the network
  • (Additionaly the time taken at various other layers, but not including them for the sake of simplicity).

And for serialization - adding the comment from @Lino here:

In computing, serialization (or serialisation) is the process of translating data structures or object state into a format that can be stored (for example, in a file or memory buffer) or transmitted (for example, across a network connection link) and reconstructed later (possibly in a different computer environment)

Source : Wikipedia

like image 133
Smile Avatar answered Apr 03 '26 18:04

Smile