Skip to main content
Version: 0.14

Overview

Apache Fory™ is a blazingly-fast multi-language serialization framework powered by JIT compilation, zero-copy techniques, and advanced code generation, achieving up to 170x performance improvement while maintaining simplicity and ease of use.

Quick Example

Cross-language serialization — serialize in Rust, deserialize in Python:

Rust

use fory::{Fory, ForyObject};

#[derive(ForyObject, Debug, PartialEq)]
struct User {
name: String,
age: i32,
}

fn main() {
let mut fory = Fory::default().xlang(true);
fory.register::<User>(1);

let user = User { name: "Alice".to_string(), age: 30 };
let bytes = fory.serialize(&user).unwrap();
let decoded: User = fory.deserialize(&bytes).unwrap();
println!("{:?}", decoded); // User { name: "Alice", age: 30 }
}

Python

import pyfory
from dataclasses import dataclass

@dataclass
class User:
name: str
age: pyfory.int32

fory = pyfory.Fory(xlang=True)
fory.register(User, type_id=1)

user = User(name="Alice", age=30)
data = fory.serialize(user)
decoded = fory.deserialize(data)
print(decoded) # User(name='Alice', age=30)

Key Features

🚀 High-Performance Serialization

Apache Fory™ delivers exceptional performance through advanced optimization techniques:

  • JIT Compilation: Runtime code generation for Java eliminates virtual method calls and inlines hot paths
  • Static Code Generation: Compile-time code generation for Rust, C++, and Go delivers peak performance without runtime overhead
  • Zero-Copy Operations: Direct memory access without intermediate buffer copies; row format enables random access and partial serialization
  • Intelligent Encoding: Variable-length compression for integers and strings; SIMD acceleration for arrays (Java 16+)
  • Meta Sharing: Class metadata packing reduces redundant type information across serializations

🔄 Cross-Language Serialization

The xlang serialization format enables seamless data exchange across programming languages:

  • Automatic Type Mapping: Intelligent conversion between language-specific types (type mapping)
  • Reference Preservation: Shared and circular references work correctly across languages
  • Polymorphism: Objects serialize/deserialize with their actual runtime types
  • Schema Evolution: Optional forward/backward compatibility for evolving schemas
  • Automatic Serialization: No IDL or schema definitions required; serialize any object directly without code generation

📊 Row Format

A cache-friendly row format optimized for analytics workloads:

  • Zero-Copy Random Access: Read individual fields without deserializing entire objects
  • Partial Operations: Selective field serialization and deserialization for efficiency
  • Apache Arrow Integration: Seamless conversion to columnar format for analytics pipelines
  • Multi-Language: Available in Java, Python, Rust and C++

🔒 Security & Production-Readiness

Enterprise-grade security and compatibility:

  • Class Registration: Whitelist-based deserialization control (enabled by default)
  • Depth Limiting: Protection against recursive object graph attacks
  • Configurable Policies: Custom class checkers and deserialization policies
  • Platform Support: Java 8-24, GraalVM native image, multiple OS platforms

Protocols

Apache Fory™ implements multiple binary protocols optimized for different scenarios:

ProtocolUse CaseKey Features
Xlang SerializationCross-language object exchangeAutomatic serialization, references, polymorphism
Java SerializationHigh-performance Java-onlyDrop-in JDK serialization replacement, 100x faster
Row FormatAnalytics and data processingZero-copy random access, Arrow compatibility
Python NativePython-specific serializationPickle/cloudpickle replacement with better performance

All protocols share the same optimized codebase, allowing improvements in one protocol to benefit others.

Documentation

User Guides

GuideDescriptionSourceWebsite
Java SerializationComprehensive guide for Java serializationJava Guide📖 View
Cross-Language SerializationMulti-language object exchangeXlang Guide📖 View
Row FormatZero-copy random access formatJava Row Format📖 View
PythonPython-specific features and usagePython Guide📖 View
RustRust implementation and patternsRust Guide📖 View
ScalaScala integration and best practicesScala Guide📖 View
GraalVMNative image support and AOT compilationGraalVM Guide📖 View
DevelopmentBuilding and contributing to ForyDevelopment📖 View

Protocol Specifications

SpecificationDescriptionSourceWebsite
Xlang SerializationCross-language binary protocolxlang_serialization_spec.md📖 View
Java SerializationJava-optimized protocoljava_serialization_spec.md📖 View
Row FormatRow-based binary formatrow_format_spec.md📖 View
Type MappingCross-language type conversionxlang_type_mapping.md📖 View

Compatibility

Schema Compatibility

Apache Fory™ supports class schema forward/backward compatibility across Java, Python, Rust, and Golang, enabling seamless schema evolution in production systems without requiring coordinated upgrades across all services. Fory provides two schema compatibility modes:

  1. Schema Consistent Mode (Default): Assumes identical class schemas between serialization and deserialization peers. This mode offers minimal serialization overhead, smallest data size, and fastest performance: ideal for stable schemas or controlled environments.

  2. Compatible Mode: Supports independent schema evolution with forward and backward compatibility. This mode enables field addition/deletion, limited type evolution, and graceful handling of schema mismatches. Enable using withCompatibleMode(CompatibleMode.COMPATIBLE) in Java, compatible=True in Python, compatible_mode(true) in Rust, or NewFory(true) in Go.

Binary Compatibility

Current Status: Binary compatibility is not guaranteed between Fory major releases as the protocol continues to evolve. However, compatibility is guaranteed between minor versions (e.g., 0.13.x).

Recommendations:

  • Version your serialized data by Fory major version
  • Plan migration strategies when upgrading major versions
  • See upgrade guide for details

Future: Binary compatibility will be guaranteed starting from Fory 1.0 release.

Security

Overview

Serialization security varies by protocol:

  • Row Format: Secure with predefined schemas
  • Object Graph Serialization (Java/Python native): More flexible but requires careful security configuration

Dynamic serialization can deserialize arbitrary types, which may introduces risks. For example, the deserialization may invoke init constructor or equals/hashCode method, if the method body contains malicious code, the system will be at risk.

Fory enables class registration by default for dynamic protocols, allowing only trusted registered types. Do not disable class registration unless you can ensure your environment is secure.

If this option is disabled, you are responsible for serialization security. You should implement and configure a customized ClassChecker or DeserializationPolicy for fine-grained security control

To report security vulnerabilities in Apache Fory™, please follow the ASF vulnerability reporting process.

Community and Support

Getting Help

  • Slack: Join our Slack workspace for community discussions
  • Twitter/X: Follow @ApacheFory for updates and announcements
  • GitHub Issues: Report bugs and request features at apache/fory
  • Mailing Lists: Subscribe to Apache Fory mailing lists for development discussions

Contributing

We welcome contributions! Please read our Contributing Guide to get started.

Ways to Contribute:

  • 🐛 Report bugs and issues
  • 💡 Propose new features
  • 📝 Improve documentation
  • 🔧 Submit pull requests
  • 🧪 Add test cases
  • 📊 Share benchmarks

See Development Guide for build instructions and development workflow.