1

Hi everyone, my name is Mic

A fan who has worked for 4 years and submitted a lot of resumes

I finally received an interview invitation from an Internet company.

He was killed in the first round of the interview because he had too little understanding of mainstream Internet technologies.

One such question is: "Tell me briefly about your understanding of serialization and deserialization"

Check out the answers from ordinary people and experts below.

Ordinary people:

Serialization and deserialization means that I want to transfer an object to another application on the network. In the previous case, I need to serialize this object.

Then think that we can in Java, if we need to serialize this object, we need to implement an interface like Serializable.

Expert:

OK, I need to answer this question from several perspectives.

First of all, I think the core purpose of serialization is to solve the problem of object transmission between network communications.

That is, how to transfer an object in the current JVM process to another JVM process across the network.

Serialization is to convert objects in memory into byte streams for storage or transmission.

Deserialization is to describe the information and state of objects stored in the byte stream according to the byte stream of the object obtained from the file or the network.

Rebuild a new object.

image-20220518201612649

Secondly, the premise of serialization is to ensure the identifiability of the object between the communicating parties, so in many cases, we will first convert the object into a general parsing format,

Such as json, xml, etc. Then they are converted into data streams for network transmission, so as to achieve cross-platform and cross-language recognizability.

Finally, let me add the serialization option.

There are many open source serialization technologies on the market, such as Json, Xml, Protobuf, Kyro, hessian and so on.

In practical applications, which serialization is the most suitable, I think there are several key factors.

  • The size of the data after serialization, because the size of the data will affect the transmission performance
  • Serialization performance, serialization takes a long time and will affect the performance of the business
  • Whether to support cross-platform and cross-language
  • The maturity of the technology, the more mature the solution used by the more companies, the more stable it is.

The above is my understanding of the problem!

Summarize

Serialization is a question that is asked a lot in interviews.

Going a little deeper, we will also ask about the algorithm and principle of serialization.

In actual development, the choice of serialization technology has a great impact on performance.

Therefore, Internet companies will pay more attention to this aspect.

Friends who like my works, remember to like, favorite and follow.

file

Copyright notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated. Reprint please indicate the source Mic带你学架构 !
If this article is helpful to you, please help to follow and like, your persistence is the driving force for my continuous creation. Welcome to follow the WeChat public account of the same name to get more technical dry goods!

跟着Mic学架构
810 声望1.1k 粉丝

《Spring Cloud Alibaba 微服务原理与实战》、《Java并发编程深度理解及实战》作者。 咕泡教育联合创始人,12年开发架构经验,对分布式微服务、高并发领域有非常丰富的实战经验。