atomicdata-dev / atomic-server

An open source headless CMS / real-time database. Powerful table editor, full-text search, and SDKs for JS / React / Svelte.
https://atomicserver.eu
MIT License
1.02k stars 46 forks source link

Multi-node / distributed setup (scaling to huge datasets / multi-tenant) #213

Open joepio opened 2 years ago

joepio commented 2 years ago

Atomic-server has been designed to run on low-end hardware, as a self-hosted server. This was why I decided to use an embedded database (sled) and search engine (tantivy).

However, this introduces a problem. What do you do when the physical constraints of a single machine are exceeded by the demands? For example, when a single CPU is not fast enough to host your data, or if the RAM is bottlenecking performance, or if the disk size is insufficient? This is where distributed setups come in handy, but the current architecture is not designed to deal with this.

This thread is for exploring what might need to happen to facilitate a multi-node setup.

Thoughts

Interesting tools

jonassmedegaard commented 2 years ago

Perhaps there is some wisdom to borrow from 4store - or maybe ask its author, Steve Harris, to provide input here?

joepio commented 2 years ago

Thanks!

joepio commented 2 years ago

A different approach to multi-node, is FAAS. Convert all logic to stateless functions. Has some interesting benefits to scalability - no longer needed to copy instances and all their logic.

joepio commented 2 years ago

@AlexMikhalev has made some interesting progress on having a multi-node Atomic-Server setup. See the aws-ops repo.

He suggests:

One docker instance per user

Some thoughts about this approach:

joepio commented 2 years ago

Another approach:

Link Drives to Nodes

AlexMikhalev commented 2 years ago

Check out https://github.com/atomicdata-dev/atomic-data-rust/pull/463 - the sync between nodes was the whole point of using fluvio. The bit which I didn't finish - is to remap atomic data URLs inside the smart module before the record reaches the streaming platform.

joepio commented 1 year ago

Another approach:

Use a multi-node KV store

Wherever we're currently using sled, we could use tikv (for example). This means instead of using an embedded key-value store, we'll use an external one that supports multi-node setups.

The big advantage is that Atomic-Server instances are no longer tied to specific data. In other words, tikv deals with the complexities of having a multi-node system.

However, there are still some stateful resources that are currently linked to machines. Plugins, specifically. Also, we'll still need to make sure that the watched_queries are scoped to specific workspaces, but that's an easily fixable problem.

For now, let's ignore plugins. Because even if we fix that problem, I'm not sure the solution will be very performant. There is quite a bit of overhead required when our storage system is on a different machine. Where we now get nanosecond responses, this will definitely become milliseconds. However, tikv still is very fast - on average one response takes less than 1 ms as well. This only becomes a bit worrisome if we do multiple consecutive gets that require multiple round trips. There are probably ways to work around this. I'm assuming there are ways we can do batch requests in their client.

2024-01 EDIT: This doesn't solve all issues:

  1. What happens if the bottleneck isn't persistence, but compute? E.g. if a lot of Commits have to be processed at the same time. In that case, we can scale the KV all we want, but we're not fixing the core issue.
  2. How do we distribute search? We'll need another tool for this, too.

I think this approach will not be sufficient. Back to the drawing board.

joepio commented 1 year ago

https://github.com/lnx-search/datacake/tree/main/examples/replicated-kv

Data cake also seems interesting, I'll take a closer look soon

joepio commented 9 months ago

Coordinator node approach

This is a load balancer / proxy server / rust server (actix / axum?) that forwards requests to AtomicServer instances, depending on the used subdomain (drive). Note that it needs to be aware of which node hosts which drive.

This means:

Existing tools

Write our own