Posts

Showing posts with the label serialization

XML Serialization in Java with XStream

Image
Xstream is an old but still a good framework for serialization. Definitely, there are faster libraries however Xstream still lightweight and relevant if you need to deal with XML. There are other formats like YAML, JSON, and so many others. For configurations, I definitely favor java properties file format which is just a key/value format. Generally, I would favor JSON for configs over YAML. So why XML in 2021? I'm not arguing XML is the way. Just saying sometimes you need to deal with old services or old systems and for that case, you might be constrained with whatever format is there. You might consider creating a wrapper service to abstract an old API and old format but eventually, complexity needs to live somewhere. So I made some POC showing some of the capabilities that Xstream has. Let's get started!

Serde Benchmark

Image
Serialization is always an important aspect of any Microservice or solution. Often people associate Benchmarks as potential flame-war enablers, thats not my goal here. Benchmarks are sensible things, they really vary from config, hardware, use case, payload. I'm trying to convince you guys of anything. I'm Just sharing some simple comparison exercise I did so you guys have any idea about performance to Serialize and Deserialize and the resulting size. I highly recommend you do this benchmark for you use case. However, my pet project here might give you some ideas on how to get started. The benchmark I will show is coed in Java but you can take this ideas and do them in any language. I will use Junit as way to run the benchmarks. So let's get started.