Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java serialization alternative with better performance [closed]

Suppose I use the standard Java object serialization to write/read small (< 1K) Java objects to/from memory buffer. The most critical part is the deserialization, i.e. reading Java objects from memory buffer (byte array).

Is there any faster alternative to the standard Java serialization for this case ?

like image 713
Michael Avatar asked Dec 23 '12 13:12

Michael


People also ask

What is alternative for serialization in Java?

As per the Java Object Serialization Specification, we can use the writeObject() method from ObjectOutputStream class to serialize the object. On the other hand, we can use the readObject() method, which belongs to the ObjectInputStream class, to perform the deserialization.

Why is serialization not good?

It is not future-proof for small changes If you mark your classes as [Serializable] , then all the private data not marked as [NonSerialized] will get dumped. You have no control over the format of this data. If you change the name of a private variable, then your code will break.

Is Java serialization faster than JSON?

The results show that Java serialization is slow for a small number of objects, but good for a large number of objects. Conversely, XML and JSON can outperform Java serialization for a small number of objects, but Java serialization is faster for a large number of objects.

Is Java serialization fast?

The main problem with Java Serialization is performance and efficiency. Java serialization is much slower than using in memory stores and tends to significantly expand the size of the object. Java Serialization also creates a lot of garbage.


1 Answers

You might also want to have a look at FST.

also provides tools for offheap reading/writing

like image 81
R.Moeller Avatar answered Oct 03 '22 20:10

R.Moeller