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:
| Protocol | Use Case | Key Features |
|---|---|---|
| Xlang Serialization | Cross-language object exchange | Automatic serialization, references, polymorphism |
| Java Serialization | High-performance Java-only | Drop-in JDK serialization replacement, 100x faster |
| Row Format | Analytics and data processing | Zero-copy random access, Arrow compatibility |
| Python Native | Python-specific serialization | Pickle/cloudpickle replacement with better performance |
All protocols share the same optimized codebase, allowing improvements in one protocol to benefit others.
Documentation
User Guides
| Guide | Description | Source | Website |
|---|---|---|---|
| Java Serialization | Comprehensive guide for Java serialization | Java Guide | 📖 View |
| Cross-Language Serialization | Multi-language object exchange | Xlang Guide | 📖 View |
| Row Format | Zero-copy random access format | Java Row Format | 📖 View |
| Python | Python-specific features and usage | Python Guide | 📖 View |
| Rust | Rust implementation and patterns | Rust Guide | 📖 View |
| Go | Go implementation and usage | Go Guide | 📖 View |
| Scala | Scala integration and best practices | Scala Guide | 📖 View |
| GraalVM | Native image support and AOT compilation | GraalVM Guide | 📖 View |
| Development | Building and contributing to Fory | Development | 📖 View |
Protocol Specifications
| Specification | Description | Source | Website |
|---|---|---|---|
| Xlang Serialization | Cross-language binary protocol | xlang_serialization_spec.md | 📖 View |
| Java Serialization | Java-optimized protocol | java_serialization_spec.md | 📖 View |
| Row Format | Row-based binary format | row_format_spec.md | 📖 View |
| Type Mapping | Cross-language type conversion | xlang_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:
-
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.
-
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=Truein Python,compatible_mode(true)in Rust, orNewFory(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.