SlideShare a Scribd company logo
1 of 52
Serialization and
performance
Сергей Моренец
23 мая 2014 г.
About author
Works in IT since 2000
10 year of Java SE/EE experience
Occupied senior Java developer/Team
Lead positions
Winner of 2013 JBoss Community
Recognition Award.
https://www.jboss.org/jbcra
Agenda
• Purpose of serialization
• Frameworks overview
• Performance testing
• Q & A
Serialization
File storages
Database
Network communication
Web usage
Serialization
Simple
Flexible
Compact
Versioning
Fast Scalable
Data formats
Binary
XML
JSON
YAML
Performance
• Native memory copying using C operations
• “Unsafe” operations
• Ignore object introspection
• Direct object-object copying
Java serialization
• The easiest programming effort
• Out-of-the-box functionality
Java serialization
• Serializable interface
• Decreases the flexibility to change a class’s
implementation once it has been released
• Doesn’t allow to exchange data with
C++/Python applications
• Due to default constructors hole for invariant
corruption and illegal access
• No customization
• You should have access to the source code
No customization
You should have access to the source code
Java externalization
• Serialization but by implementing
Externalizable interface to persist and
restore the object
• Responsibility of the class to save and
restore the contents of its instances
• Requires modifications in
marshalling/unmarshalling code if the class
contents changed
No customization
You should have access to the source code
Java externalization
Avro
• Schema evolution
• Binary and JSON encoding
• Dynamic typing
• Support of Java, C, C++, C# and Python
• Apache Hadoop integration
Avro
Avro
XML
• Interchangeable format
• Supported schemas
• Space intensive and huge performance loss
• Complex navigating
Simple
• High performance XML serialization and
configuration framework for Java.
• Requires absolutely no configuration
• Can handle cycles in the object graph
Simple
Javolution
• Fast real-time library for safety-critical
applications
• Based on OSGi context
• Parallel computing support
Javolution
Json-io
• Doesn’t require custom interfaces/attributes
usage/source code
• Handles cyclic references
• Reader/writer customization
• Does not depend on any native or 3rd party
libraries.
Google gson
• Java library to convert JSON to Java objects and
vice-versa
• Doesn’t require source code of serialized objects
• Allow custom representatives
Google gson
Jackson
• High-performance, ergonomic JSON processor
Java library
• Extensive customization tools
• Mix-in annotations
• Materialized interfaces
• Multiple data formats
Jackson
• JSON
• CSV
• Smile(binary JSON)
• XML
• YAML(similar to JSON)
BSON for Jackson
• Binary encoded JSON
• Main data exchange format for MongoDB
• Allows writing custom extensions
Protocol buffers
• Way of encoding structured data in an efficient
yet extensible format.
• Google uses Protocol Buffers for almost all of
its internal RPC protocols and file formats.
• Supported in Java, C++, Python
Protocol buffers
message User {
required string login = 1;
repeated Order orders = 2;
}
message Order {
required int32 id = 1;
optional string date = 2;
}
Protocol buffers
FST
• Java-to-java library
• No support for versioning
• Use case is high performance message oriented
software
• Drop-in replacement
• Custom optimization using annotations, custom
serializers
FST
GridGain
• Part of distributed computing system
• Don’t require any custom interfaces or API
• Direct memory copying by invoking native
"unsafe" operations
• Predefined fields introspection
GridGain
Kryo
• Fast and efficient object graph serialization
framework for Java
• Open source project on Google code
• Automatic deep and shallow copying/cloning
• Doesn’t put requirements on the source classes
(in most cases)
Kryo
• Twitter
• Apache Hive
• Akka
• Storm
• S4
Kryo
Kryo
Benchmark
• JDK 1.8.0.5
• Apache Avro 1.7.6
• Simple 2.7.1
• Json-io 2.5.2
• Google GSON 2.2.4
• Jackson 2.3.2
• BSON for Jackson 2.3.1
• Protocol buffers 2.5
• Kryo 2.23
• FST 1.54
• GridGain 6.0.2
Benchmark
• Speed(serialization and deserialization)
• Size(complex and ordinary objects)
• Flexibility
Benchmark
Benchmark
Issues
Library Description
Gson, Jackson Crashed when serializing cyclic
dependency
Simple Crashed for very big XML file
Avro Bug during deserialization
Serialization (complex)
# Library Time(ms)
1 Kryo(optimized) 134
2 Protocol buffers 165
3 GridGain 196
4 FST 207
5 Kryo 209
6 Jackson(smile) 275
7 Kryo(unsafe) 306
8 Jackson 491
9 Java serialization 605
10 Javolution 1043
Serialization (simple)
# Library Time(ms)
1 Protocol buffers <1
2 Google GSON 5
3 Java serialization 10
4 BSON for Jackson 10
5 Jackson(smile) 11
6 Kryo(optimized) 17
7 Kryo 18
8 Jackson 18
9 Kryo(unsafe) 20
10 Javolution 21
Deserialization (complex)
# Library Time(ms)
1 Kryo(optimized) 113
2 Protocol buffers 165
3 GridGain 196
4 FST 207
5 Kryo 209
6 Jackson(smile) 275
7 Kryo(unsafe) 306
8 Jackson 491
9 Java serialization 605
10 BSON for Jackson 930
Deserialization (simple)
# Library Time(ms)
1 Protocol buffers 1
2 GridGain 3
3 Google GSON 6
4 Jackson(smile) 9
5 BSON for Jackson 9
6 Kryo(optimized) 18
7 Kryo 18
8 Jackson 18
9 Kryo(unsafe) 20
10 FST 42
Size (complex)
# Library Size(bytes)
1 Kryo(optimized) 33904
2 FST 34069
3 Kryo 35674
4 Protocol buffers 39517
5 Kryo(unsafe) 40554
6 Jackson(smile) 44840
7 Java serialization 49757
8 GridGain 58288
9 Jackson 67858
10 Google GSON 68338
Size (simple)
# Library Size(bytes)
1 Kryo(optimized) 18
2 Kryo 18
3 Protocol buffers 20
4 Kryo(unsafe) 21
5 GridGain 33
6 Jackson(smile) 40
7 Jackson 41
8 Google GSON 41
9 Jackson(YAML) 41
10 BSON for Jackson 46
Usability
# Library
1 Google GSON
2 Kryo
2 Kryo(unsafe)
3 Jackson
3 Jackson(XML, Smile, YAML)
3 BSON for Jackson
4 Json-io
5 FST
6 Java serialization
7 Kryo(optimized)
Overall rating (2014)
# Library Rating
1 Kryo(optimized) 67
2 Protocol buffers 65
3 Kryo 58
4 Jackson(smile) 55
5 Kryo(unsafe) 46
6 GridGain 44
7 Google GSON 43
8 FST 43
9 Jackson 40
10 BSON for Jackson 33
11 Java serialization 32
Overall rating (2013)
# Library Rating
1 Kryo(optimized) 67
2 Kryo(unsafe) 65
3 Protocol buffers 63
4 Kryo 59
5 Jackson(smile) 51
6 Google GSON 45
7 FST 42
8 GridGain 34
9 Jackson 32
10 Java serialization 30
11 BSON for Jackson 24
Advices
Library Usage
Kryo Fast and compact serializer for complex
objects over network
Protocol buffers Fast serializer for simple objects
Jackson(smile) Jackson-based serializer for Web usage
Google JSON Dirty solution to quickly serialize/deserialize
objects
Apache Avro Serialize objects into files with possible
schema changes
Java Out-of-the-box trusted solution without
additional libraries
Сергей Моренец
morenets@mail.ru
Q&A

More Related Content

What's hot

pgpool-II demonstration
pgpool-II demonstrationpgpool-II demonstration
pgpool-II demonstration
elliando dias
 
Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
confluent
 

What's hot (20)

The Real Cost of Slow Time vs Downtime
The Real Cost of Slow Time vs DowntimeThe Real Cost of Slow Time vs Downtime
The Real Cost of Slow Time vs Downtime
 
InnoDB Internal
InnoDB InternalInnoDB Internal
InnoDB Internal
 
pgpool-II demonstration
pgpool-II demonstrationpgpool-II demonstration
pgpool-II demonstration
 
REST vs. GraphQL: Critical Look
REST vs. GraphQL: Critical LookREST vs. GraphQL: Critical Look
REST vs. GraphQL: Critical Look
 
Tomcat, Undertow, Jetty, Nginx Unit: pros and cons
Tomcat, Undertow, Jetty, Nginx Unit: pros and consTomcat, Undertow, Jetty, Nginx Unit: pros and cons
Tomcat, Undertow, Jetty, Nginx Unit: pros and cons
 
Monitoring Apache Kafka
Monitoring Apache KafkaMonitoring Apache Kafka
Monitoring Apache Kafka
 
codecentric AG: CQRS and Event Sourcing Applications with Cassandra
codecentric AG: CQRS and Event Sourcing Applications with Cassandracodecentric AG: CQRS and Event Sourcing Applications with Cassandra
codecentric AG: CQRS and Event Sourcing Applications with Cassandra
 
Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
Achieving a 50% Reduction in Cross-AZ Network Costs from Kafka (Uday Sagar Si...
 
EDB Failover Manager for Seamless Failover & Switchover
EDB Failover Manager for Seamless Failover & SwitchoverEDB Failover Manager for Seamless Failover & Switchover
EDB Failover Manager for Seamless Failover & Switchover
 
ksqlDB로 실시간 데이터 변환 및 스트림 처리
ksqlDB로 실시간 데이터 변환 및 스트림 처리ksqlDB로 실시간 데이터 변환 및 스트림 처리
ksqlDB로 실시간 데이터 변환 및 스트림 처리
 
Introduction to SignalR
Introduction to SignalRIntroduction to SignalR
Introduction to SignalR
 
Event Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveEvent Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspective
 
Scaling managed MySQL Platform in Flipkart - (Sachin Japate - Flipkart) - Myd...
Scaling managed MySQL Platform in Flipkart - (Sachin Japate - Flipkart) - Myd...Scaling managed MySQL Platform in Flipkart - (Sachin Japate - Flipkart) - Myd...
Scaling managed MySQL Platform in Flipkart - (Sachin Japate - Flipkart) - Myd...
 
Hibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance TechniquesHibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance Techniques
 
Exactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache KafkaExactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache Kafka
 
Building Event-Driven Systems with Apache Kafka
Building Event-Driven Systems with Apache KafkaBuilding Event-Driven Systems with Apache Kafka
Building Event-Driven Systems with Apache Kafka
 
ElasticSearch in action
ElasticSearch in actionElasticSearch in action
ElasticSearch in action
 
SignalR Overview
SignalR OverviewSignalR Overview
SignalR Overview
 
Orchestration Patterns for Microservices with Messaging by RabbitMQ
Orchestration Patterns for Microservices with Messaging by RabbitMQOrchestration Patterns for Microservices with Messaging by RabbitMQ
Orchestration Patterns for Microservices with Messaging by RabbitMQ
 
게임 서비스 품질 향상을 위한 데이터 분석 활용하기 - 김필중 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
게임 서비스 품질 향상을 위한 데이터 분석 활용하기 - 김필중 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming게임 서비스 품질 향상을 위한 데이터 분석 활용하기 - 김필중 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
게임 서비스 품질 향상을 위한 데이터 분석 활용하기 - 김필중 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
 

Viewers also liked

Viewers also liked (14)

Practical Machine Learning
Practical Machine LearningPractical Machine Learning
Practical Machine Learning
 
[D2]java 성능에 대한 오해와 편견
[D2]java 성능에 대한 오해와 편견[D2]java 성능에 대한 오해와 편견
[D2]java 성능에 대한 오해와 편견
 
20150526 오픈업 mcn의 미래_명승은
20150526 오픈업 mcn의 미래_명승은20150526 오픈업 mcn의 미래_명승은
20150526 오픈업 mcn의 미래_명승은
 
Advanced nGrinder 2nd Edition
Advanced nGrinder 2nd EditionAdvanced nGrinder 2nd Edition
Advanced nGrinder 2nd Edition
 
[오픈소스컨설팅]Java Performance Tuning
[오픈소스컨설팅]Java Performance Tuning[오픈소스컨설팅]Java Performance Tuning
[오픈소스컨설팅]Java Performance Tuning
 
Micro Service Architecture 탐방기
Micro Service Architecture 탐방기Micro Service Architecture 탐방기
Micro Service Architecture 탐방기
 
Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015
 
공짜 경제에서 어떻게 돈을 버는가?(How to Make Money in Free Economy)
공짜 경제에서 어떻게 돈을 버는가?(How to Make Money in Free Economy)공짜 경제에서 어떻게 돈을 버는가?(How to Make Money in Free Economy)
공짜 경제에서 어떻게 돈을 버는가?(How to Make Money in Free Economy)
 
왜 레진코믹스는 구글앱엔진을 선택했나
왜 레진코믹스는 구글앱엔진을 선택했나왜 레진코믹스는 구글앱엔진을 선택했나
왜 레진코믹스는 구글앱엔진을 선택했나
 
Programming skills 1부
Programming skills 1부Programming skills 1부
Programming skills 1부
 
XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영
XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영
XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영
 
Front end 웹사이트 성능 측정 및 개선
Front end 웹사이트 성능 측정 및 개선Front end 웹사이트 성능 측정 및 개선
Front end 웹사이트 성능 측정 및 개선
 
객체지향 개념 (쫌 아는체 하기)
객체지향 개념 (쫌 아는체 하기)객체지향 개념 (쫌 아는체 하기)
객체지향 개념 (쫌 아는체 하기)
 
오늘 밤부터 쓰는 google analytics (구글 애널리틱스, GA)
오늘 밤부터 쓰는 google analytics (구글 애널리틱스, GA) 오늘 밤부터 쓰는 google analytics (구글 애널리틱스, GA)
오늘 밤부터 쓰는 google analytics (구글 애널리틱스, GA)
 

Similar to Serialization and performance in Java

Сергей Моренец. Serialization and performance in Java
Сергей Моренец. Serialization and performance in JavaСергей Моренец. Serialization and performance in Java
Сергей Моренец. Serialization and performance in Java
Volha Banadyseva
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey Morenets
Alex Tumanoff
 
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para TiGustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
Software Guru
 
MySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics Improvements
Morgan Tocker
 
Zero to 1 Billion+ Records: A True Story of Learning & Scaling GameChanger
Zero to 1 Billion+ Records: A True Story of Learning & Scaling GameChangerZero to 1 Billion+ Records: A True Story of Learning & Scaling GameChanger
Zero to 1 Billion+ Records: A True Story of Learning & Scaling GameChanger
MongoDB
 

Similar to Serialization and performance in Java (20)

Сергей Моренец. Serialization and performance in Java
Сергей Моренец. Serialization and performance in JavaСергей Моренец. Serialization and performance in Java
Сергей Моренец. Serialization and performance in Java
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey Morenets
 
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para TiGustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
 
JavaOne_2010
JavaOne_2010JavaOne_2010
JavaOne_2010
 
OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6
 
De Java 8 ate Java 14
De Java 8 ate Java 14De Java 8 ate Java 14
De Java 8 ate Java 14
 
CQRS and Event Sourcing for Java Developers
CQRS and Event Sourcing for Java DevelopersCQRS and Event Sourcing for Java Developers
CQRS and Event Sourcing for Java Developers
 
De Java 8 a Java 11 y 14
De Java 8 a Java 11 y 14De Java 8 a Java 11 y 14
De Java 8 a Java 11 y 14
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoon
 
Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014
 
Grails 3.0 Preview
Grails 3.0 PreviewGrails 3.0 Preview
Grails 3.0 Preview
 
Алексей Швайка "Bundling: you are doing it wrong"
Алексей Швайка "Bundling: you are doing it wrong"Алексей Швайка "Bundling: you are doing it wrong"
Алексей Швайка "Bundling: you are doing it wrong"
 
GemStone/64 product update and road map
GemStone/64 product update and road mapGemStone/64 product update and road map
GemStone/64 product update and road map
 
DOTNET8.pptx
DOTNET8.pptxDOTNET8.pptx
DOTNET8.pptx
 
Jakarta EE 8 on JDK17
Jakarta EE 8 on JDK17Jakarta EE 8 on JDK17
Jakarta EE 8 on JDK17
 
MySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics Improvements
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
 
Expertezed 2012 Webcast - XML DB Use Cases
Expertezed 2012 Webcast - XML DB Use CasesExpertezed 2012 Webcast - XML DB Use Cases
Expertezed 2012 Webcast - XML DB Use Cases
 
Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12
 
Zero to 1 Billion+ Records: A True Story of Learning & Scaling GameChanger
Zero to 1 Billion+ Records: A True Story of Learning & Scaling GameChangerZero to 1 Billion+ Records: A True Story of Learning & Scaling GameChanger
Zero to 1 Billion+ Records: A True Story of Learning & Scaling GameChanger
 

More from Strannik_2013

Gradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypesGradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypes
Strannik_2013
 
Git.From thorns to the stars
Git.From thorns to the starsGit.From thorns to the stars
Git.From thorns to the stars
Strannik_2013
 

More from Strannik_2013 (16)

Junior,middle,senior?
Junior,middle,senior?Junior,middle,senior?
Junior,middle,senior?
 
JEEConf 2016. Effectiveness and code optimization in Java applications
JEEConf 2016. Effectiveness and code optimization in  Java applicationsJEEConf 2016. Effectiveness and code optimization in  Java applications
JEEConf 2016. Effectiveness and code optimization in Java applications
 
Effectiveness and code optimization in Java
Effectiveness and code optimization in JavaEffectiveness and code optimization in Java
Effectiveness and code optimization in Java
 
Effective Java applications
Effective Java applicationsEffective Java applications
Effective Java applications
 
Top 10 reasons to migrate to Gradle
Top 10 reasons to migrate to GradleTop 10 reasons to migrate to Gradle
Top 10 reasons to migrate to Gradle
 
Gradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypesGradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypes
 
Spring Boot. Boot up your development. JEEConf 2015
Spring Boot. Boot up your development. JEEConf 2015Spring Boot. Boot up your development. JEEConf 2015
Spring Boot. Boot up your development. JEEConf 2015
 
Gradle 2.Write once, builde everywhere
Gradle 2.Write once, builde everywhereGradle 2.Write once, builde everywhere
Gradle 2.Write once, builde everywhere
 
Java 8 in action.Jinq
Java 8 in action.JinqJava 8 in action.Jinq
Java 8 in action.Jinq
 
Spring Boot. Boot up your development
Spring Boot. Boot up your developmentSpring Boot. Boot up your development
Spring Boot. Boot up your development
 
Spring.Boot up your development
Spring.Boot up your developmentSpring.Boot up your development
Spring.Boot up your development
 
Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gates
 
Getting ready to java 8
Getting ready to java 8Getting ready to java 8
Getting ready to java 8
 
JSF 2: Myth of panacea? Magic world of user interfaces
JSF 2: Myth of panacea? Magic world of user interfacesJSF 2: Myth of panacea? Magic world of user interfaces
JSF 2: Myth of panacea? Magic world of user interfaces
 
Git.From thorns to the stars
Git.From thorns to the starsGit.From thorns to the stars
Git.From thorns to the stars
 
Spring Web flow. A little flow of happiness
Spring Web flow. A little flow of happinessSpring Web flow. A little flow of happiness
Spring Web flow. A little flow of happiness
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Serialization and performance in Java

  • 2. About author Works in IT since 2000 10 year of Java SE/EE experience Occupied senior Java developer/Team Lead positions Winner of 2013 JBoss Community Recognition Award. https://www.jboss.org/jbcra
  • 3. Agenda • Purpose of serialization • Frameworks overview • Performance testing • Q & A
  • 7. Performance • Native memory copying using C operations • “Unsafe” operations • Ignore object introspection • Direct object-object copying
  • 8. Java serialization • The easiest programming effort • Out-of-the-box functionality
  • 9. Java serialization • Serializable interface • Decreases the flexibility to change a class’s implementation once it has been released • Doesn’t allow to exchange data with C++/Python applications • Due to default constructors hole for invariant corruption and illegal access • No customization • You should have access to the source code No customization You should have access to the source code
  • 10. Java externalization • Serialization but by implementing Externalizable interface to persist and restore the object • Responsibility of the class to save and restore the contents of its instances • Requires modifications in marshalling/unmarshalling code if the class contents changed No customization You should have access to the source code
  • 12. Avro • Schema evolution • Binary and JSON encoding • Dynamic typing • Support of Java, C, C++, C# and Python • Apache Hadoop integration
  • 13. Avro
  • 14. Avro
  • 15. XML • Interchangeable format • Supported schemas • Space intensive and huge performance loss • Complex navigating
  • 16. Simple • High performance XML serialization and configuration framework for Java. • Requires absolutely no configuration • Can handle cycles in the object graph
  • 18. Javolution • Fast real-time library for safety-critical applications • Based on OSGi context • Parallel computing support
  • 20. Json-io • Doesn’t require custom interfaces/attributes usage/source code • Handles cyclic references • Reader/writer customization • Does not depend on any native or 3rd party libraries.
  • 21. Google gson • Java library to convert JSON to Java objects and vice-versa • Doesn’t require source code of serialized objects • Allow custom representatives
  • 23. Jackson • High-performance, ergonomic JSON processor Java library • Extensive customization tools • Mix-in annotations • Materialized interfaces • Multiple data formats
  • 24. Jackson • JSON • CSV • Smile(binary JSON) • XML • YAML(similar to JSON)
  • 25. BSON for Jackson • Binary encoded JSON • Main data exchange format for MongoDB • Allows writing custom extensions
  • 26. Protocol buffers • Way of encoding structured data in an efficient yet extensible format. • Google uses Protocol Buffers for almost all of its internal RPC protocols and file formats. • Supported in Java, C++, Python
  • 27. Protocol buffers message User { required string login = 1; repeated Order orders = 2; } message Order { required int32 id = 1; optional string date = 2; }
  • 29. FST • Java-to-java library • No support for versioning • Use case is high performance message oriented software • Drop-in replacement • Custom optimization using annotations, custom serializers
  • 30. FST
  • 31. GridGain • Part of distributed computing system • Don’t require any custom interfaces or API • Direct memory copying by invoking native "unsafe" operations • Predefined fields introspection
  • 33. Kryo • Fast and efficient object graph serialization framework for Java • Open source project on Google code • Automatic deep and shallow copying/cloning • Doesn’t put requirements on the source classes (in most cases)
  • 34. Kryo • Twitter • Apache Hive • Akka • Storm • S4
  • 35. Kryo
  • 36. Kryo
  • 37. Benchmark • JDK 1.8.0.5 • Apache Avro 1.7.6 • Simple 2.7.1 • Json-io 2.5.2 • Google GSON 2.2.4 • Jackson 2.3.2 • BSON for Jackson 2.3.1 • Protocol buffers 2.5 • Kryo 2.23 • FST 1.54 • GridGain 6.0.2
  • 38. Benchmark • Speed(serialization and deserialization) • Size(complex and ordinary objects) • Flexibility
  • 41. Issues Library Description Gson, Jackson Crashed when serializing cyclic dependency Simple Crashed for very big XML file Avro Bug during deserialization
  • 42. Serialization (complex) # Library Time(ms) 1 Kryo(optimized) 134 2 Protocol buffers 165 3 GridGain 196 4 FST 207 5 Kryo 209 6 Jackson(smile) 275 7 Kryo(unsafe) 306 8 Jackson 491 9 Java serialization 605 10 Javolution 1043
  • 43. Serialization (simple) # Library Time(ms) 1 Protocol buffers <1 2 Google GSON 5 3 Java serialization 10 4 BSON for Jackson 10 5 Jackson(smile) 11 6 Kryo(optimized) 17 7 Kryo 18 8 Jackson 18 9 Kryo(unsafe) 20 10 Javolution 21
  • 44. Deserialization (complex) # Library Time(ms) 1 Kryo(optimized) 113 2 Protocol buffers 165 3 GridGain 196 4 FST 207 5 Kryo 209 6 Jackson(smile) 275 7 Kryo(unsafe) 306 8 Jackson 491 9 Java serialization 605 10 BSON for Jackson 930
  • 45. Deserialization (simple) # Library Time(ms) 1 Protocol buffers 1 2 GridGain 3 3 Google GSON 6 4 Jackson(smile) 9 5 BSON for Jackson 9 6 Kryo(optimized) 18 7 Kryo 18 8 Jackson 18 9 Kryo(unsafe) 20 10 FST 42
  • 46. Size (complex) # Library Size(bytes) 1 Kryo(optimized) 33904 2 FST 34069 3 Kryo 35674 4 Protocol buffers 39517 5 Kryo(unsafe) 40554 6 Jackson(smile) 44840 7 Java serialization 49757 8 GridGain 58288 9 Jackson 67858 10 Google GSON 68338
  • 47. Size (simple) # Library Size(bytes) 1 Kryo(optimized) 18 2 Kryo 18 3 Protocol buffers 20 4 Kryo(unsafe) 21 5 GridGain 33 6 Jackson(smile) 40 7 Jackson 41 8 Google GSON 41 9 Jackson(YAML) 41 10 BSON for Jackson 46
  • 48. Usability # Library 1 Google GSON 2 Kryo 2 Kryo(unsafe) 3 Jackson 3 Jackson(XML, Smile, YAML) 3 BSON for Jackson 4 Json-io 5 FST 6 Java serialization 7 Kryo(optimized)
  • 49. Overall rating (2014) # Library Rating 1 Kryo(optimized) 67 2 Protocol buffers 65 3 Kryo 58 4 Jackson(smile) 55 5 Kryo(unsafe) 46 6 GridGain 44 7 Google GSON 43 8 FST 43 9 Jackson 40 10 BSON for Jackson 33 11 Java serialization 32
  • 50. Overall rating (2013) # Library Rating 1 Kryo(optimized) 67 2 Kryo(unsafe) 65 3 Protocol buffers 63 4 Kryo 59 5 Jackson(smile) 51 6 Google GSON 45 7 FST 42 8 GridGain 34 9 Jackson 32 10 Java serialization 30 11 BSON for Jackson 24
  • 51. Advices Library Usage Kryo Fast and compact serializer for complex objects over network Protocol buffers Fast serializer for simple objects Jackson(smile) Jackson-based serializer for Web usage Google JSON Dirty solution to quickly serialize/deserialize objects Apache Avro Serialize objects into files with possible schema changes Java Out-of-the-box trusted solution without additional libraries