SkillAgentSearch skills...

Fory

A blazingly fast multi-language serialization framework powered by JIT and zero-copy.

Install / Use

/learn @apache/Fory

README

<div align="center"> <img width="65%" alt="Apache Fory logo" src="docs/images/logo/fory-horizontal.png"><br> </div>

Build Status Slack Channel X Maven Version Crates.io PyPI

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.

https://fory.apache.org

[!IMPORTANT] Apache Fory™ was previously named as Apache Fury. For versions before 0.11, please use "fury" instead of "fory" in package names, imports, and dependencies, see Fury Docs for how to use Fury in older versions.

Key Features

High-Performance Serialization

Apache Fory™ delivers excellent 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
  • Meta Packing & Sharing: Class metadata packing and sharing reduces redundant type information across objects on one stream

Cross-Language Serialization

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

  • 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: Serialize domain objects automatically, no IDL or schema definitions required

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

Built for production environments with secure defaults and explicit control:

  • Class Registration: Whitelist-based deserialization control is enabled by default to block untrusted classes.
  • Depth Limiting: Configurable object graph depth limits mitigate recursive and stack exhaustion attacks.
  • Configurable Policies: Custom class checkers and deserialization policies let teams enforce internal security rules.
  • Platform Support: Runs on Java 8 through 25, supports GraalVM native image, and works across major operating systems.

Protocols

Apache Fory™ provides three protocol families optimized for different scenarios:

| Protocol Family | Use Case | Key Features | | ------------------------------------------------------------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Xlang Serialization | Cross-language object exchange | Automatic serialization, reference preservation, polymorphism | | Row Format | Analytics and data processing | Zero-copy random access, partial operations, Apache Arrow compatibility | | Native Serialization | Language-specific optimization | Native protocol implementations per language, including Java Serialization and Python Native. Python Native extends Xlang with more type support and better performance. |

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

Benchmarks

Java Serialization Performance

Charts labeled "compatible" show schema evolution mode with forward/backward compatibility enabled, while others show schema consistent mode where class schemas must match.

Serialization Throughput:

<p align="center"> <img src="docs/benchmarks/java/java_repo_serialization_throughput.png" width="95%" alt="Java Serialization Throughput"> </p>

Deserialization Throughput:

<p align="center"> <img src="docs/benchmarks/java/java_repo_deserialization_throughput.png" width="95%" alt="Java Deserialization Throughput"> </p>

See Java Benchmarks for more details.

Rust Serialization Performance

<p align="center"> <img src="docs/benchmarks/rust/throughput.png" width="95%"> </p>

For more detailed benchmarks and methodology, see Rust Benchmarks.

C++ Serialization Performance

<p align="center"> <img src="docs/benchmarks/cpp/throughput.png" width="95%"> </p>

For more detailed benchmarks and methodology, see C++ Benchmarks.

Go Serialization Performance

<p align="center"> <img src="docs/benchmarks/go/benchmark_combined.png" width="95%"> </p>

For more detailed benchmarks and methodology, see Go Benchmark.

Python Serialization Performance

<p align="center"> <img src="docs/benchmarks/python/throughput.png" width="95%"> </p>

For more detailed benchmarks and methodology, see Pythonk.

C# Serialization Performance

Fory C# demonstrates excellent performance compared to protobuf-net and MessagePack-CSharp:

<p align="center"> <img src="docs/benchmarks/csharp/throughput.png" width="95%"> </p>

For more detailed benchmarks and methodology, see C# Benchmarks.

Swift Serialization Performance

<p align="center"> <img src="docs/benchmarks/swift/throughput.png" width="95%"> </p>

For more detailed benchmarks and methodology, see SwiftBenchmarks.

Installation

Java:

<dependency>
  <groupId>org.apache.fory</groupId>
  <artifactId>fory-core</artifactId>
  <version>0.16.0</version>
</dependency>

Snapshots are available from https://repository.apache.org/snapshots/ (version 0.16.0-SNAPSHOT).

Scala:

// Scala 2.13
libraryDependencies += "org.apache.fory" % "fory-scala_2.13" % "0.16.0"

// Scala 3
libraryDependencies += "org.apache.fory" % "fory-scala_3" % "0.16.0"

Kotlin:

<dependency>
  <groupId>org.apache.fory</groupId>
  <artifactId>fory-kotlin</artifactId>
  <version>0.16.0</version>
</dependency>

Python:

pip install pyfory

# With row format support
pip install pyfory[format]

Rust:

[dependencies]
fory = "0.16"

C++:

Fory C++ supports both CMake and Bazel build systems. See C++ Installation Guide for detailed instructions.

Golang:

go get github.com/apache/fory/go/fory

Quick Start

This section provides quick examples for getting started with Apache Fory™. For comprehensive guides, see the Documentation.

Native Serialization

Always use native mode when working with a single language. Native mode delivers optimal performance by avoiding the type metadata overhead required for cross-language compatibility. Xlang mode introduces additional metadata encoding costs and restricts serialization to types that are common across all supported languages. Language-specific types will be rejected during serialization in xlang-mode.

Java Serialization

When you don't need cross-language support, use Java mode for optimal performance.

import org.apache.fory.*;
import org.apache.fory.config.*;

public class Example {
  public static class Person {
    String name;
    int age;
  }

  public static void main(String[] args) {
    // Create Fory instance - should be reused across serializations
    BaseFory fory = Fory.builder()
      .withLanguage(Language.JAVA)
      .requireClassRegistration(true)
      // replace `build` with `buildThreadSafeFory` for Thread-Safe Usage
      .build();
    // Register your classes (required when class registration is enabled)
    // Registration order must be consistent if id is not specified
    fory.register(Person.class);
    // Serialize
   
View on GitHub
GitHub Stars4.3k
CategoryDevelopment
Updated21h ago
Forks409

Languages

Java

Security Score

100/100

Audited on Mar 28, 2026

No findings