-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: create rfc 008 Dataplane #2841
Open
chronark
wants to merge
8
commits into
main
Choose a base branch
from
rfc-0008-dataplane
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4581bdc
docs: create rfc 008 Dataplane
chronark f162826
[autofix.ci] apply automated fixes
autofix-ci[bot] a6d4b81
chore: spelling
chronark a85b1cf
Merge branch 'rfc-0008-dataplane' of https://github.com/unkeyed/unkey…
chronark c014984
Merge branch 'main' into rfc-0008-dataplane
ogzhanolguncu 9486836
Merge branch 'main' of https://github.com/unkeyed/unkey into rfc-0008…
chronark 33641ae
docs: add dynamodb
chronark b8fc2e8
docs: pricing
chronark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ export const deleteKeys = t.procedure | |
); | ||
}) | ||
.catch((err) => { | ||
console.error(err) | ||
console.error(err); | ||
throw new TRPCError({ | ||
code: "INTERNAL_SERVER_ERROR", | ||
message: "We are unable to delete the key. Please try again or contact [email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--- | ||
title: 0008 Dataplane | ||
description: Global Unkey Deployment Architecture | ||
date: 2025-01-26 | ||
authors: | ||
- Andreas Thomas | ||
--- | ||
|
||
|
||
We need to design a globally distributed architecture for Unkey where the dataplane can operate independently of the primary database for improved availability. | ||
|
||
## Goals | ||
|
||
- Achieve 100% dataplane availability independent of primary database | ||
- Provide fast access to dynamic data across global regions | ||
- Propagate data across the system quickly | ||
- Minimize load on expensive storage | ||
- Enable efficient cache invalidation | ||
- Can run on any cloud or on premise | ||
|
||
## Options | ||
|
||
### 1. Direct S3 + In-Memory Cache with SWR | ||
|
||
```ascii | ||
┌─────────────────────┐ ┌─────────┐ | ||
│ Gateway │ │ │ | ||
│ ┌───────────────┐ │────►│ S3 │ | ||
│ │ Memory Cache │ │ │ │ | ||
│ └───────────────┘ │ │ │ | ||
└─────────────────────┘ └─────────┘ | ||
``` | ||
|
||
#### Pros | ||
- Simple, straightforward design | ||
- Low architectural complexity | ||
|
||
#### Cons | ||
- Cache invalidation requires communication with all machines or really low TTLs (\<10s) | ||
- Inefficient cache refresh patterns | ||
- High load on S3 due to concurrent SWR requests from multiple machines | ||
|
||
### 2. S3 + In-Memory Cache with Gossip Protocol | ||
|
||
```ascii | ||
┌─────────────────────┐ | ||
│ Gateway │ | ||
│ ┌───────────────┐ │──┐ | ||
│ │ Memory Cache │ │ │ | ||
│ └───────────────┘ │ │ | ||
└─────────────────────┘ │ | ||
▲ │ | ||
│ Gossip │ ┌─────────┐ | ||
▼ ├───►│ │ | ||
┌─────────────────────┐ │ │ S3 │ | ||
│ Gateway │ │ │ │ | ||
│ ┌───────────────┐ │──┘ └─────────┘ | ||
│ │ Memory Cache │ │ | ||
│ └───────────────┘ │ | ||
└─────────────────────┘ | ||
``` | ||
|
||
If we had global fast and efficient eviction, we could set much higher TTLs. | ||
|
||
#### Pros | ||
- Efficient cache invalidation through gossip, allowing higher TTLs | ||
- Reduced load on primary storage | ||
- Only need to notify one node for changes | ||
|
||
#### Cons | ||
- Need to implement ordering mechanism (timestamps/Lamport clocks) | ||
- More complex system architecture | ||
- Global gossip cluster management overhead | ||
|
||
### 3. S3 + Dedicated Cache Layer | ||
|
||
```ascii | ||
┌─────────────────┐ | ||
│ Gateway 1 │───┐ | ||
└─────────────────┘ │ | ||
│ | ||
┌─────────────────┐ │ ┌────────────┐ | ||
│ Gateway 2 │───┼───►│ Load │ ┌────────────┐ | ||
└─────────────────┘ │ │ Balancer │───►│ Cache │──┐ | ||
│ │ │ │ Node 1 │ │ | ||
┌─────────────────┐ │ │ │ └────────────┘ │ | ||
│ Gateway 3 │───┤ │ │ │ ┌─────────┐ | ||
└─────────────────┘ │ │ │ ├───►│ S3 │ | ||
├───►│ │ ┌────────────┐ │ └─────────┘ | ||
┌─────────────────┐ │ │ │───►│ Cache │──┘ | ||
│ Gateway 4 │───┤ │ │ │ Node 2 │ | ||
└─────────────────┘ │ └────────────┘ └────────────┘ | ||
│ | ||
┌─────────────────┐ │ | ||
│ Gateway n │───┘ | ||
└─────────────────┘ | ||
``` | ||
|
||
Gateways still use an in-memory SWR cache. The cache nodes help reduce the cost | ||
and latency of S3, but will likely have the same freshness/staleness as the | ||
gateways. TBD.. | ||
|
||
Everything here, except the S3 bucket, would be duplicated per region. | ||
|
||
#### Pros | ||
- Better cache retention due to less frequent reboots | ||
- Optional global eviction via gossip/kafka later | ||
- Maybe we only need 1 S3 region now instead of replicating it | ||
|
||
#### Cons | ||
- Additional infrastructure to manage |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the date field.
The date is set to 2025-01-26, which is in the future. Please update it to the current date.
📝 Committable suggestion