Home

Awesome

Stellar.FastDB - High Performance Embedded Storage for C# (.NET)

Stellar.FastDB is an exceptionally fast document store for C# with speeds approximately 100 times faster than similar products. Designed for optimal performance and high concurrency, it excels in embedded workflows that demand efficiency.

image

Key Features


Benchmarks

A comprehensive list of benchmarks, along with a project for reproduction, is available.

Insert

MethodProductOp/sFileSize
Insert 10,000FastDB192,855653 KB
Insert 10,000VistaDB2,648940 KB
Insert 10,000LiteDB1,2511,656 KB
Insert 10,000SQLite753444 KB

Delete

MethodProductOp/sFileSize
Delete 10,000FastDB164,177653 KB
Delete 10,000VistaDB5,503940 KB
Delete 10,000LiteDB1,2071,664 KB
Delete 10,000SQLite757444 KB

Upsert

MethodProductOp/sFileSize
Upsert 10,000FastDB93,633653 KB
Upsert 10,000LiteDB3,1921,664 KB
Upsert 10,000VistaDB2,372940 KB
Upsert 10,000SQLite741444 KB

Bulk Insert

MethodProductOp/sFileSize
Bulk 10,000SQLite294,455444 KB
Bulk 10,000FastDB226,075653 KB
Bulk 10,000LiteDB44,2198 KB
Bulk 10,000VistaDB2,706952 KB

Query

MethodProductOp/sFileSize
Query 10,000FastDB12,080,699653 KB
Query 10,000SQLite2,227,601444 KB
Query 10,000VistaDB574,299940 KB
Query 10,000LiteDB497,7981,656 KB

Common Questions

Why was Stellar.FasbDB created?

As a game developer, I needed a high-concurrency storage solution suitable for player-managed game servers. Installing traditional local databases posed too high a demand on players. I found that the available storage solutions were either too slow or struggled with concurrency issues during high volumes of simultaneous reads and writes. Such limitations are impractical for game servers, which must support a large number of players efficiently.

Should I use Stellar.FastDB?

Use Stellar.FastDB if you need:

Do not use this database if you need:

What additional features are planned for Stellar.FastDB?

How to use Stellar.FastDB

Code Samples

Getting Started

Below is a basic example demonstrating how to interact with Stellar.FastDB. This includes creating a database instance, storing customer data, updating it, retrieving it, and properly closing the database connection:

// create a class
public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
    public DateTime DOB { get; set; }
    public string Phone { get; set; }
    public bool IsActive { get; set; }
}

// create database
FastDB fastDB = new FastDB();

// create a collection (key, value)
var customers = fastDB.GetCollection<int, Customer>();

// create your new customer instance
var customer = new Customer
{ 
   Name = "John Wick", 
   Phone = "555-555-5555"
   DOB = new DateTime(2000, 1, 1)
   IsActive = true
};

// add customer
customers.Add(customer.Id, customer);

// update customer
customer.Name = "John Wick's Dog";
customers.Update(customer);

// use LINQ to query documents
var matches = customers.Where(a => a.Name.StartsWith("John") && a.Telephone > 5555555);

// close database
fastDB.Close();

Encryption

FastDBOptions options = new FastDBOptions()
{
   IsEncrypted = true,
   EncryptionPassword = "open-sesame",
};
FastDB fastDB = new FastDB(options);

Compression

FastDBOptions options = new FastDBOptions()
{
   IsCompressed = true,
};
FastDB fastDB = new FastDB(options);

Large Record Parallelism

For operations involving serialization, compression, or encryption of large object graphs, enabling parallel data transformations can significantly enhance throughput, especially with large records. This method effectively leverages multiple processor cores to accelerate write operations.

FastDBOptions options = new FastDBOptions()
{
   BufferMode = BufferModeType.WriteParallelEnabled,
   MaxDegreesOfParallelism = 8,
   IsEncryptionEnabled = true,
   EncryptionPassword = "open-sesame",
   IsCompressed = true,
};
FastDB fastDB = new FastDB(options);
MethodProductOp/sFileSize
LargeFastDB140,47020,096 KB
Large EncryptedFastDB100,43520,205 KB
Large Encrypted CompressedFastDB68,06414,892 KB
Large Enc Cmp ParallelFastDB138,58814,892 KB

Optional Serialization Contracts

To achieve the smallest possible storage footprint, Stellar.FastDB supports serialization contracts using MessagePack. By adding MessagePack attributes to your data models (as shown in the example below), you can instruct the serializer to package the data more efficiently. Note that this feature is disabled by default and is typically not included in most benchmarks.

// create a class
public class Customer
{
    [Key(0)]
    public int Id { get; set; }
    [Key(1)]
    public string Name { get; set; }
    [Key(2)]
    public DateTime DOB { get; set; }
    [Key(3)]
    public string Phone { get; set; }
    [Key(4)]
    public bool IsActive { get; set; }
}

FastDBOptions options = new FastDBOptions()
{
   Serializer = SerializerType.MessagePack_Contract,
};
FastDB fastDB = new FastDB(options);

// create a collection (key, value)
var customers = fastDB.GetCollection<int, Customer>();

// add customer
customers.Add(customer.Id, customer);
customres.Flush()

// close database
fastDB.Close();
SerializerProductOp/sFileSize
Default 10,000FastDB198,628653 KB
Contract 10,000FastDB201,109370 KB

Contact

I may be contacted on the Stellar Conquest Discord (stonstad) and X (stonstad).