Compact Serialization Vs .Net Serialization

Serialization is the process of converting the state of an object into a form that can be transferred on the wire. The opposite of serialization is deserialization, which converts a stream into an object. In distributed applications the serialization takes place whenever the data has to go out of the process or machine. Serialization in general is a slow process because of the IO and can become a performance bottleneck for distributed applications.

The .NET framework provides multiple serialization techniques such as binary, SOAP and XML serialization. Binary Serialization is commonly used and is much faster than the other serialization techniques. It preserves type consistency, which is useful for preserving the state of an object between different invocations of an application.

Although, .NET binary serialization is fast but it has some serious limitations. When it comes to network, speed of transfer of data is dependent on the data size. When a data is shared process to process while traveling on network, it should be serialized. Whenever an object is serialized, it contains so much Meta data of the object that it becomes very difficult to transfer it on the network. Bigger the object, more time it takes to travel on the network. Serialization uses reflection. Reflection is an I/O process which affects performance badly in case of the applications that uses distributed caching as the size of the serialized objects gets almost double.

Draw backs of binary serialization are:

• Slow reflection

• As the object size gets bigger, it affects the performance and slower network trips.

•People who use distributed caching experience a lot of data transferring which gets slower.

NCache is a distributed caching solution which provides you a feature called compact serialization which can help you fix problem occurring in binary serialization.

Compact Serialization is a process which produces a compact form of serialized object for performance improvement which results in faster network trips. It works by serializing the object in compact in form of data and process. The concept behind the compact serialization is that every keyword/data type is assigned a unique 2-byte type handle by the framework, which lets the deserializer uniquely identify them.
For example, suppose the framework assign a handle 0 to System.Int32. Then the serializer writes the 2-byte handle followed by 4 bytes of object value to the stream. Deserializer reads the handle, finds out the object type, and then creates and gives the object its value.

On other hand the binary serialization writes the complete type information with object data.

How Compact serialization is better than .Net serialization?

• In compact serialization, the serialized object does not contain the complete type information and assemblies. It only contains an object value and a unique 2-byte handle is used as a reference to uniquely identify the type’s details while deserializing an object which reduces the object size.

• Compact serialization also avoids the reflection which also reduces the overhead.

• You don’t need to code.

• It reduces the number of IO operations (minimum or no reflection) which increases performance of the application.

• Faster network trips reduce the cost and improves the performance as the size of the object is reduced.


NCache Home Page

Download NCache


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: