AvroConvert 3.0.1

Apache Avro serializer for .NET.

Install-Package AvroConvert -Version 3.0.1
dotnet add package AvroConvert --version 3.0.1
<PackageReference Include="AvroConvert" Version="3.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AvroConvert --version 3.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AvroConvert, 3.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install AvroConvert as a Cake Addin
#addin nuget:?package=AvroConvert&version=3.0.1

// Install AvroConvert as a Cake Tool
#tool nuget:?package=AvroConvert&version=3.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Docs

Avro format combines readability of JSON and compression of binary data serialization.

Introduction article

Apache Wiki

General information

Documentation

Benefits

The main purpose of the project was to enhance HTTP communication between microservices. Replacing JSON with Avro brought three main benefits:

  • Decreased the communication time between microservices
  • Reduced the network traffic by about 30%
  • Increased communication security - the data was not visible in plain JSON text

Features

AvroConvert Apache.Avro Newtonsoft.Json
Rapid serialization ✔️ ✔️ ✔️
Easy to use ✔️ ✔️
Built-in compression ✔️ ✔️
Low memory allocation ✔️ ✔️ ✔️
Support for C# data structures: Dictionary, List, DateTime... ✔️ ✔️
Support for compression codecs Deflate<br/> Snappy<br/> GZip<br/> Brotli Deflate
Readable schema of data structure ✔️ ✔️ ✔️
Data is encrypted ✔️ ✔️

Full Changelog

Benchmark

Results of BenchmarkDotNet:

Converter Request Time [ms] Allocated Memory [MB] Compressed Size [kB]
Json 672.3 52.23 6044
Avro 384.7 76.58 2623
Json_Gzip 264.1 88.32 514
Avro_Gzip 181.2 75.05 104
Json_Brotli 222.5 86.15 31
Avro_Brotli 193.5 74.75 31

Article describing Avro format specification and benchmark methodology: https://www.c-sharpcorner.com/blogs/avro-rest-api-as-the-evolution-of-json-based-communication-between-mic

Conclusion: <br>
Using Avro for communication between your services significantly reduces communication time and network traffic. Additionally choosing encoding (compression algorithm) can improve the results even further.

Code samples

  • Serialization
 byte[] avroObject = AvroConvert.Serialize(object yourObject);

<br/>

  • Deserialization
CustomClass deserializedObject = AvroConvert.Deserialize<CustomClass>(byte[] avroObject);

<br/>

  • Read schema from Avro object
string schemaInJsonFormat = AvroConvert.GetSchema(byte[] avroObject)

<br/>

  • Deserialization of large collection of Avro objects one by one
using (var reader = AvroConvert.OpenDeserializer<CustomClass>(new MemoryStream(avroObject)))
{
    while (reader.HasNext())
    {
        var item = reader.ReadNext();
        // process item
    }
}

Full Documentation

Related packages

Nuget - Library containing functionalities, which enable communication between microservices via Http using Avro data format

Nuget - Library containing extensions for Confluent Kafka platform - used together with Kafka Consumer and Producer

License

The project is CC BY-NC-SA 3.0 licensed.

For commercial purposes purchase AvroConvert on website - Xabe.net

Contribution

We want to improve AvroConvert as much as possible. If you have any idea, found next possible feature, optimization opportunity or better way for integration, leave a comment or pull request.

Docs

Avro format combines readability of JSON and compression of binary data serialization.

Introduction article

Apache Wiki

General information

Documentation

Benefits

The main purpose of the project was to enhance HTTP communication between microservices. Replacing JSON with Avro brought three main benefits:

  • Decreased the communication time between microservices
  • Reduced the network traffic by about 30%
  • Increased communication security - the data was not visible in plain JSON text

Features

AvroConvert Apache.Avro Newtonsoft.Json
Rapid serialization ✔️ ✔️ ✔️
Easy to use ✔️ ✔️
Built-in compression ✔️ ✔️
Low memory allocation ✔️ ✔️ ✔️
Support for C# data structures: Dictionary, List, DateTime... ✔️ ✔️
Support for compression codecs Deflate<br/> Snappy<br/> GZip<br/> Brotli Deflate
Readable schema of data structure ✔️ ✔️ ✔️
Data is encrypted ✔️ ✔️

Full Changelog

Benchmark

Results of BenchmarkDotNet:

Converter Request Time [ms] Allocated Memory [MB] Compressed Size [kB]
Json 672.3 52.23 6044
Avro 384.7 76.58 2623
Json_Gzip 264.1 88.32 514
Avro_Gzip 181.2 75.05 104
Json_Brotli 222.5 86.15 31
Avro_Brotli 193.5 74.75 31

Article describing Avro format specification and benchmark methodology: https://www.c-sharpcorner.com/blogs/avro-rest-api-as-the-evolution-of-json-based-communication-between-mic

Conclusion: <br>
Using Avro for communication between your services significantly reduces communication time and network traffic. Additionally choosing encoding (compression algorithm) can improve the results even further.

Code samples

  • Serialization
 byte[] avroObject = AvroConvert.Serialize(object yourObject);

<br/>

  • Deserialization
CustomClass deserializedObject = AvroConvert.Deserialize<CustomClass>(byte[] avroObject);

<br/>

  • Read schema from Avro object
string schemaInJsonFormat = AvroConvert.GetSchema(byte[] avroObject)

<br/>

  • Deserialization of large collection of Avro objects one by one
using (var reader = AvroConvert.OpenDeserializer<CustomClass>(new MemoryStream(avroObject)))
{
    while (reader.HasNext())
    {
        var item = reader.ReadNext();
        // process item
    }
}

Full Documentation

Related packages

Nuget - Library containing functionalities, which enable communication between microservices via Http using Avro data format

Nuget - Library containing extensions for Confluent Kafka platform - used together with Kafka Consumer and Producer

License

The project is CC BY-NC-SA 3.0 licensed.

For commercial purposes purchase AvroConvert on website - Xabe.net

Contribution

We want to improve AvroConvert as much as possible. If you have any idea, found next possible feature, optimization opportunity or better way for integration, leave a comment or pull request.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on AvroConvert:

Package Downloads
SolTechnology.Avro.Http
Library containing functionalities, which enable communication between microservices using Avro data format
OptimoveSdk.Engager.Integration
SDK for Engagers intergration with Optimove
SolTechnology.Avro.Kafka
Library containing extensions for Confluent Kafka platform
SlimMessageBus.Host.Serialization.AvroConvert
Extension to SlimMessageBus that provides Avro serialization based on the AvroConvert library

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.0.1 218 4/2/2021
3.0.0 8,081 3/26/2021
2.7.1 2,384 2/5/2021
2.7.0 19,524 12/18/2020
2.6.3 2,343 10/25/2020
2.6.2 147 10/23/2020
2.6.1 2,170 7/25/2020
2.6.0 213 7/22/2020
2.5.1 1,004 6/11/2020
2.5.0 554 5/15/2020
2.4.1 1,010 4/14/2020
2.4.0 498 3/25/2020
2.3.0 411 3/19/2020
2.2.2 633 2/7/2020
2.2.1 222 2/7/2020
2.2.0 276 1/27/2020
2.1.0 210 1/16/2020
2.0.0 207 1/4/2020
1.8.1 490 12/9/2019
1.8.0 964 8/30/2019
1.7.0 272 8/22/2019
1.6.0 299 7/22/2019
1.5.1 321 7/14/2019
1.5.0 324 7/11/2019
1.4.0 272 6/17/2019
1.3.0 308 6/4/2019
1.2.0 310 6/3/2019
1.1.0 298 5/28/2019
1.0.1 306 5/21/2019
1.0.0 506 4/24/2019
0.8.0 461 5/1/2019
0.7.0 543 4/22/2019
0.6.3 477 4/19/2019
0.6.2 491 4/19/2019
0.6.1 475 4/19/2019
0.6.0 480 4/19/2019
0.5.0 513 4/18/2019
0.3.0 629 4/11/2019
0.2.1 482 4/11/2019
0.2.0 483 4/11/2019
0.1.0 503 4/10/2019