• Stars
    star
    2,570
  • Rank 17,050 (Top 0.4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created 12 months ago
  • Updated 8 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Build Status Slack Channel Twitter Maven Version

Apache Fury (incubating) is a blazingly-fast multi-language serialization framework powered by JIT (just-in-time compilation) and zero-copy, providing up to 170x performance and ultimate ease of use.

https://fury.apache.org

Features

  • Multiple languages: Java/Python/C++/Golang/JavaScript/Rust/Scala/TypeScript.
  • Zero-copy: Cross-language out-of-band serialization inspired by pickle5 and off-heap read/write.
  • High performance: A highly-extensible JIT framework to generate serializer code at runtime in an async multi-thread way to speed serialization, providing 20-170x speed up by:
    • reduce memory access by inlining variables in generated code.
    • reduce virtual method invocation by inline call in generated code.
    • reduce conditional branching.
    • reduce hash lookup.
  • Multiple binary protocols: Object graph, row format, and so on.

In addition to cross-language serialization, Fury also features at:

  • Drop-in replace Java serialization frameworks such as JDK/Kryo/Hessian, but 100x faster at most, which can greatly improve the efficiency of high-performance RPC calls, data transfer, and object persistence.
  • 100% compatible with JDK serialization API with much faster implementation: supporting JDK writeObject/readObject/writeReplace/readResolve/readObjectNoData/Externalizable API.
  • Supports Java 8~21, Java 17+ record is supported too.
  • Supports AOT compilation serialization for GraalVM native image, and no reflection/serialization json config are needed.
  • Supports shared and circular reference object serialization for golang.
  • Supports scala serialization
  • Supports automatic object serialization for golang.

Protocols

Fury designed and implemented multiple binary protocols for different scenarios:

  • xlang serialization format:
    • Cross-language serialize any object automatically, no need for IDL definition, schema compilation and object to/from protocol conversion.
    • Support optional shared reference and circular reference, no duplicate data or recursion error.
    • Support object polymorphism.
  • Java serialization format: Highly-optimized and drop-in replacement for Java serialization.
  • Row format format: A cache-friendly binary random access format, supports skipping serialization and partial serialization, and can convert to column-format automatically.

New protocols can be easily added based on Fury existing buffer, encoding, meta, codegen and other capabilities. All of those share the same codebase, and the optimization for one protocol can be reused by another protocol.

Benchmarks

Different serialization frameworks are suitable for different scenarios, and benchmark results here are for reference only.

If you need to benchmark for your specific scenario, make sure all serialization frameworks are appropriately configured for that scenario.

Dynamic serialization frameworks support polymorphism and references, but they often come with a higher cost compared to static serialization frameworks, unless they utilize JIT techniques like Fury does. To ensure accurate benchmark statistics, it is advisable to warm up the system before collecting data due to Fury's runtime code generation.

Java Serialization

In these charts below, titles containing "compatible" represent schema compatible mode: type forward/backward compatibility is enabled; while titles without "compatible" represent schema consistent mode: class schema must be the same between serialization and deserialization.

Where Struct is a class with 100 primitive fields, MediaContent is a class from jvm-serializers, and Sample is a class from kryo benchmark.

See benchmarks for more benchmarks about type forward/backward compatibility, off-heap support, zero-copy serialization.

Installation

Java

Nightly snapshot:

<repositories>
  <repository>
    <id>apache</id>
    <url>https://repository.apache.org/snapshots/</url>
    <releases>
      <enabled>false</enabled>
    </releases>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </repository>
</repositories>
<dependency>
  <groupId>org.apache.fury</groupId>
  <artifactId>fury-core</artifactId>
  <version>0.5.0-SNAPSHOT</version>
</dependency>
<!-- row/arrow format support -->
<!-- <dependency>
  <groupId>org.apache.fury</groupId>
  <artifactId>fury-format</artifactId>
  <version>0.5.0-SNAPSHOT</version>
</dependency> -->

Release version:

<dependency>
  <groupId>org.furyio</groupId>
  <artifactId>fury-core</artifactId>
  <version>0.4.1</version>
</dependency>
<!-- row/arrow format support -->
<!-- <dependency>
  <groupId>org.furyio</groupId>
  <artifactId>fury-format</artifactId>
  <version>0.4.1</version>
</dependency> -->

Maven groupId will be changed to org.apache.fury when next version is released.

Scala

libraryDependencies += "org.furyio" % "fury-core" % "0.4.1"

Python

pip install pyfury

JavaScript

npm install @furyjs/fury

Golang

go get github.com/apache/incubator-fury/go/fury

Quickstart

Here we give a quick start about how to use Fury, see user guide for more details about java, cross language, and row format.

Fury java object graph serialization

If you don't have cross-language requirements, using this mode will result in better performance.

import org.apache.fury.*;
import org.apache.fury.config.*;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    SomeClass object = new SomeClass();
    // Note that Fury instances should be reused between
    // multiple serializations of different objects.
    {
      Fury fury = Fury.builder().withLanguage(Language.JAVA)
        // Allow to deserialize objects unknown types, more flexible
        // but may be insecure if the classes contains malicious code.
        .requireClassRegistration(true)
        .build();
      // Registering types can reduce class name serialization overhead, but not mandatory.
      // If class registration enabled, all custom types must be registered.
      fury.register(SomeClass.class);
      byte[] bytes = fury.serialize(object);
      System.out.println(fury.deserialize(bytes));
    }
    {
      ThreadSafeFury fury = Fury.builder().withLanguage(Language.JAVA)
        // Allow to deserialize objects unknown types, more flexible
        // but may be insecure if the classes contains malicious code.
        .requireClassRegistration(true)
        .buildThreadSafeFury();
      byte[] bytes = fury.serialize(object);
      System.out.println(fury.deserialize(bytes));
    }
    {
      ThreadSafeFury fury = new ThreadLocalFury(classLoader -> {
        Fury f = Fury.builder().withLanguage(Language.JAVA)
          .withClassLoader(classLoader).build();
        f.register(SomeClass.class);
        return f;
      });
      byte[] bytes = fury.serialize(object);
      System.out.println(fury.deserialize(bytes));
    }
  }
}

Cross-language object graph serialization

Java

import org.apache.fury.*;
import org.apache.fury.config.*;
import java.util.*;

public class ReferenceExample {
  public static class SomeClass {
    SomeClass f1;
    Map<String, String> f2;
    Map<String, String> f3;
  }

  public static Object createObject() {
    SomeClass obj = new SomeClass();
    obj.f1 = obj;
    obj.f2 = ofHashMap("k1", "v1", "k2", "v2");
    obj.f3 = obj.f2;
    return obj;
  }

  // mvn exec:java -Dexec.mainClass="org.apache.fury.examples.ReferenceExample"
  public static void main(String[] args) {
    Fury fury = Fury.builder().withLanguage(Language.XLANG)
      .withRefTracking(true).build();
    fury.register(SomeClass.class, "example.SomeClass");
    byte[] bytes = fury.serialize(createObject());
    // bytes can be data serialized by other languages.
    System.out.println(fury.deserialize(bytes));
  }
}

Python

from typing import Dict
import pyfury

class SomeClass:
    f1: "SomeClass"
    f2: Dict[str, str]
    f3: Dict[str, str]

fury = pyfury.Fury(ref_tracking=True)
fury.register_class(SomeClass, type_tag="example.SomeClass")
obj = SomeClass()
obj.f2 = {"k1": "v1", "k2": "v2"}
obj.f1, obj.f3 = obj, obj.f2
data = fury.serialize(obj)
# bytes can be data serialized by other languages.
print(fury.deserialize(data))

Golang

package main

import furygo "github.com/apache/incubator-fury/go/fury"
import "fmt"

func main() {
	type SomeClass struct {
		F1 *SomeClass
		F2 map[string]string
		F3 map[string]string
	}
	fury := furygo.NewFury(true)
	if err := fury.RegisterTagType("example.SomeClass", SomeClass{}); err != nil {
		panic(err)
	}
	value := &SomeClass{F2: map[string]string{"k1": "v1", "k2": "v2"}}
	value.F3 = value.F2
	value.F1 = value
	bytes, err := fury.Marshal(value)
	if err != nil {
	}
	var newValue interface{}
	// bytes can be data serialized by other languages.
	if err := fury.Unmarshal(bytes, &newValue); err != nil {
		panic(err)
	}
	fmt.Println(newValue)
}

Row format

Java

public class Bar {
  String f1;
  List<Long> f2;
}

public class Foo {
  int f1;
  List<Integer> f2;
  Map<String, Integer> f3;
  List<Bar> f4;
}

RowEncoder<Foo> encoder = Encoders.bean(Foo.class);
Foo foo = new Foo();
foo.f1 = 10;
foo.f2 = IntStream.range(0, 1000000).boxed().collect(Collectors.toList());
foo.f3 = IntStream.range(0, 1000000).boxed().collect(Collectors.toMap(i -> "k"+i, i->i));
List<Bar> bars = new ArrayList<>(1000000);
for (int i = 0; i < 1000000; i++) {
  Bar bar = new Bar();
  bar.f1 = "s"+i;
  bar.f2 = LongStream.range(0, 10).boxed().collect(Collectors.toList());
  bars.add(bar);
}
foo.f4 = bars;
// Can be zero-copy read by python
BinaryRow binaryRow = encoder.toRow(foo);
// can be data from python
Foo newFoo = encoder.fromRow(binaryRow);
// zero-copy read List<Integer> f2
BinaryArray binaryArray2 = binaryRow.getArray(1);
// zero-copy read List<Bar> f4
BinaryArray binaryArray4 = binaryRow.getArray(3);
// zero-copy read 11th element of `readList<Bar> f4`
BinaryRow barStruct = binaryArray4.getStruct(10);

// zero-copy read 6th of f2 of 11th element of `readList<Bar> f4`
barStruct.getArray(1).getLong(5);
RowEncoder<Bar> barEncoder = Encoders.bean(Bar.class);
// deserialize part of data.
Bar newBar = barEncoder.fromRow(barStruct);
Bar newBar2 = barEncoder.fromRow(binaryArray4.getStruct(20));

Python

@dataclass
class Bar:
    f1: str
    f2: List[pa.int64]
@dataclass
class Foo:
    f1: pa.int32
    f2: List[pa.int32]
    f3: Dict[str, pa.int32]
    f4: List[Bar]

encoder = pyfury.encoder(Foo)
foo = Foo(f1=10, f2=list(range(1000_000)),
         f3={f"k{i}": i for i in range(1000_000)},
         f4=[Bar(f1=f"s{i}", f2=list(range(10))) for i in range(1000_000)])
binary: bytes = encoder.to_row(foo).to_bytes()
foo_row = pyfury.RowData(encoder.schema, binary)
print(foo_row.f2[100000], foo_row.f4[100000].f1, foo_row.f4[200000].f2[5])

Compatibility

Schema Compatibility

Fury java object graph serialization supports class schema forward/backward compatibility. The serialization peer and deserialization peer can add/delete fields independently.

We plan to add the schema compatibility support of cross-language serialization after meta compression is finished.

Binary Compatibility

We are still improving our protocols, thus binary compatibility is not guaranteed between Fury major releases for now. However, it is guaranteed between minor versions. Please versioning your data by Fury major version if you will upgrade Fury in the future, see how to upgrade fury for further details.

Binary compatibility will be guaranteed when Fury 1.0 is released.

Security

Static serialization is relatively secure. But dynamic serialization such as Fury java/python native serialization supports deserializing unregistered types, which provides more dynamics and flexibility, but also introduce security 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.

Fury provides a class registration option that is enabled by default for such protocols, allowing only deserialization of trusted registered types or built-in 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 can configure org.apache.fury.resolver.ClassChecker by ClassResolver#setClassChecker to control which classes are allowed for serialization.

To report security vulnerabilities found in Fury, please follow the ASF vulnerability reporting process.

How to Build

Please read the BUILD guide for instructions on how to build.

How to Contribute

Please read the CONTRIBUTING guide for instructions on how to contribute.

License

Licensed under the Apache License, Version 2.0

More Repositories

1

echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
TypeScript
56,321
star
2

superset

Apache Superset is a Data Visualization and Data Exploration Platform
TypeScript
55,051
star
3

dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
Java
39,899
star
4

spark

Apache Spark - A unified analytics engine for large-scale data processing
Scala
36,719
star
5

airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
Python
33,999
star
6

kafka

Mirror of Apache Kafka
Java
27,068
star
7

incubator-seata

๐Ÿ”ฅ Seata is an easy-to-use, high-performance, open source distributed transaction solution.
Java
24,602
star
8

skywalking

APM, Application Performance Monitoring System
Java
22,610
star
9

flink

Apache Flink
Java
22,197
star
10

mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
C++
20,572
star
11

shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Java
19,287
star
12

rocketmq

Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications.
Java
18,578
star
13

brpc

brpc is an Industrial-grade RPC framework using C++ Language, which is often used in high performance system such as Search, Storage, Machine learning, Advertisement, Recommendation etc. "brpc" means "better RPC".
C++
14,261
star
14

incubator-weex

Apache Weex (Incubating)
C++
13,884
star
15

hadoop

Apache Hadoop
Java
13,855
star
16

arrow

Apache Arrow is a multi-language toolbox for accelerated data interchange and in-memory processing
C++
13,226
star
17

pulsar

Apache Pulsar - distributed pub-sub messaging system
Java
13,062
star
18

druid

Apache Druid: a high performance real-time analytics database.
Java
12,843
star
19

predictionio

PredictionIO, a machine learning server for developers and ML engineers.
Scala
12,556
star
20

zookeeper

Apache ZooKeeper
Java
11,532
star
21

doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
Java
11,180
star
22

apisix

The Cloud-Native API Gateway
Lua
11,031
star
23

incubator-answer

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
Go
10,948
star
24

thrift

Apache Thrift
C++
9,900
star
25

dolphinscheduler

Apache DolphinScheduler is the modern data workflow orchestration platform with powerful user interface, dedicated to solving complex task dependencies in the data pipeline and providing various types of jobs available `out of the box`
Java
9,619
star
26

cassandra

Mirror of Apache Cassandra
Java
8,187
star
27

shardingsphere-elasticjob

Distributed scheduled job
Java
7,965
star
28

tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators
Python
7,828
star
29

shenyu

Apache ShenYu is a Java native API Gateway for service proxy, protocol conversion and API governance.
Java
7,541
star
30

beam

Apache Beam is a unified programming model for Batch and Streaming data processing.
Java
7,410
star
31

jmeter

Apache JMeter open-source load testing tool for analyzing and measuring the performance of a variety of services
Java
7,335
star
32

tomcat

Apache Tomcat
Java
6,926
star
33

storm

Apache Storm
Java
6,480
star
34

zeppelin

Web-based notebook that enables data-driven, interactive data analytics and collaborative documents with SQL, Scala and more.
Java
6,162
star
35

openwhisk

Apache OpenWhisk is an open source serverless cloud platform
Scala
6,130
star
36

couchdb

Seamless multi-master syncing database with an intuitive HTTP/JSON API, designed for reliability
Erlang
5,810
star
37

incubator-kie-drools

Drools is a rule engine, DMN engine and complex event processing (CEP) engine for Java.
Java
5,542
star
38

iceberg

Apache Iceberg
Java
5,365
star
39

dubbo-spring-boot-project

Spring Boot Project for Apache Dubbo
Java
5,355
star
40

mesos

Apache Mesos
Java
5,111
star
41

hive

Apache Hive
Java
5,053
star
42

camel

Apache Camel is an open source integration framework that empowers you to quickly and easily integrate various systems consuming or producing data.
Java
5,042
star
43

groovy

Apache Groovy: A powerful multi-faceted programming language for the JVM platform
Java
4,977
star
44

hbase

Apache HBase
Java
4,971
star
45

incubator-weex-ui

๐Ÿ„ A rich interaction, lightweight, high performance UI library based on Weex.
Vue
4,788
star
46

pinot

Apache Pinot - A realtime distributed OLAP datastore
Java
4,766
star
47

ignite

Apache Ignite
Java
4,548
star
48

rocketmq-externals

Mirror of Apache RocketMQ (Incubating)
Java
4,474
star
49

seatunnel

SeaTunnel is a distributed, high-performance data integration platform for the synchronization and transformation of massive data (offline & real-time).
Java
4,459
star
50

incubator-pagespeed-ngx

Automatic PageSpeed optimization module for Nginx
C++
4,381
star
51

lucene-solr

Apache Lucene and Solr open-source search software
4,349
star
52

dubbo-go

Go Implementation For Apache Dubbo
Go
4,315
star
53

shiro

Apache Shiro
Java
4,164
star
54

calcite

Apache Calcite
Java
4,028
star
55

nifi

Apache NiFi
Java
4,006
star
56

maven

Apache Maven core
Java
3,836
star
57

hudi

Upserts, Deletes And Incremental Processing on Big Data.
Java
3,804
star
58

dubbo-admin

The ops and reference implementation for Apache Dubbo
Java
3,707
star
59

incubator-heron

Apache Heron (Incubating) is a realtime, distributed, fault-tolerant stream processing engine from Twitter
Java
3,646
star
60

cordova-android

Apache Cordova Android
JavaScript
3,539
star
61

kylin

Apache Kylin
Java
3,526
star
62

httpd

Mirror of Apache HTTP Server. Issues: http://issues.apache.org
C
3,376
star
63

linkis

Apache Linkis builds a computation middleware layer to facilitate connection, governance and orchestration between the upper applications and the underlying data engines.
Java
3,223
star
64

incubator-kie-optaplanner

AI constraint solver in Java to optimize the vehicle routing problem, employee rostering, task assignment, maintenance scheduling, conference scheduling and other planning problems.
Java
3,152
star
65

logging-log4j2

Apache Log4j 2 is a versatile, feature-rich, efficient logging API and backend for Java.
Java
3,151
star
66

iotdb

Apache IoTDB
Java
3,000
star
67

arrow-datafusion

Apache Arrow DataFusion SQL Query Engine
Rust
2,998
star
68

curator

Apache Curator
Java
2,997
star
69

singa

a distributed deep learning platform
C++
2,968
star
70

incubator-streampark

StreamPark, Make stream processing easier! easy-to-use streaming application development framework and operation platform
Scala
2,820
star
71

nutch

Apache Nutch is an extensible and scalable web crawler
Java
2,653
star
72

guacamole-server

Mirror of Apache Guacamole Server
C
2,601
star
73

avro

Apache Avro is a data serialization system.
Java
2,571
star
74

commons-lang

Apache Commons Lang
Java
2,539
star
75

netbeans

Apache NetBeans
Java
2,532
star
76

flume

Mirror of Apache Flume
Java
2,458
star
77

incubator-devlake

Apache DevLake is an open-source dev data platform to ingest, analyze, and visualize the fragmented data from DevOps tools, extracting insights for engineering excellence, developer experience, and community growth.
Go
2,346
star
78

geode

Apache Geode
Java
2,244
star
79

incubator-seata-samples

seata-samples
Java
2,196
star
80

maven-mvnd

Apache Maven Daemon
Java
2,191
star
81

activemq

Mirror of Apache ActiveMQ
Java
2,184
star
82

gobblin

A distributed data integration framework that simplifies common aspects of big data integration such as data ingestion, replication, organization and lifecycle management for both streaming and batch data ecosystems.
Java
2,183
star
83

incubator-hugegraph

A graph database that supports more than 100+ billion data, high performance and scalability (Include OLTP Engine & REST-API & Backends)
Java
2,156
star
84

parquet-mr

Apache Parquet
Java
2,153
star
85

incubator-kvrocks

Kvrocks is a distributed key value NoSQL database that uses RocksDB as storage engine and is compatible with Redis protocol.
C++
2,147
star
86

pdfbox

Mirror of Apache PDFBox
Java
2,131
star
87

cordova-ios

Apache Cordova iOS
JavaScript
2,130
star
88

mahout

Mirror of Apache Mahout
Java
2,095
star
89

lucenenet

Apache Lucene.NET
C#
2,031
star
90

ambari

Apache Ambari simplifies provisioning, managing, and monitoring of Apache Hadoop clusters.
Java
1,990
star
91

libcloud

Apache Libcloud is a Python library which hides differences between different cloud provider APIs and allows you to manage different cloud resources through a unified and easy to use API.
Python
1,956
star
92

tika

The Apache Tika toolkit detects and extracts metadata and text from over a thousand different file types (such as PPT, XLS, and PDF).
Java
1,860
star
93

drill

Apache Drill is a distributed MPP query layer for self describing data
Java
1,841
star
94

dubbo-samples

samples for Apache Dubbo
Java
1,839
star
95

servicecomb-java-chassis

ServiceComb Java Chassis is a Software Development Kit (SDK) for rapid development of microservices in Java, providing service registration, service discovery, dynamic routing, and service management features
Java
1,829
star
96

tinkerpop

Apache TinkerPop - a graph computing framework
Java
1,825
star
97

bookkeeper

Apache BookKeeper - a scalable, fault tolerant and low latency storage service optimized for append-only workloads
Java
1,785
star
98

rocketmq-spring

Apache RocketMQ Spring Integration
Java
1,775
star
99

kudu

Mirror of Apache Kudu
C++
1,743
star
100

trafficserver

Apache Traffic Serverโ„ข is a fast, scalable and extensible HTTP/1.1 and HTTP/2 compliant caching proxy server.
C++
1,718
star