khonsulabs / bonsaidb

A developer-friendly document database that grows with you, written in Rust
https://bonsaidb.io/
Apache License 2.0
1.02k stars 37 forks source link

Add IPC Socket support #165

Open ecton opened 2 years ago

ecton commented 2 years ago

This issue is to add support for IPC sockets using whatever technology the platform provides. The ability to have the server listen for traffic over an IPC socket and the client be able to connect to a local IPC socket would remove a significant amount of overhead that the networking stacks incur.

The idea occurred to me while thinking of ways to potentially synchronize multiple processes against a Nebari tree. Interestingly, I've thought a lot about multi-lingual support for BonsaiDb. I hadn't considered the idea that due to some language's lack of concurrency support that some workloads employ multiple processes rather than using a single process with multiple preemptive threads.

The other use case would be for users who want to split their app into multiple processes that operate independently and synchronize through the database server without any network traffic.

ecton commented 1 year ago

~Rust 1.70 is coming out today with UnixDatagram stabilized. While this doesn't offer a way to do IPC on Windows, it provides a std-only way to do IPC on Unix-like systems. Maybe an IPC crate using UnixDatagram and some Windows-native solution will arise by the time we tackle this.~

Turns out UnixStream was already stable, and the parts that are being stabilized for UnixDatagram aren't really relevant.