Skip to content
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

Improve safekeeper to pageserver protocol #5543

Open
Tracked by #9329
petuhovskiy opened this issue Oct 12, 2023 · 2 comments
Open
Tracked by #9329

Improve safekeeper to pageserver protocol #5543

petuhovskiy opened this issue Oct 12, 2023 · 2 comments
Labels
a/performance Area: relates to performance of the system a/scalability Area: related to scalability c/storage/safekeeper Component: storage: safekeeper

Comments

@petuhovskiy
Copy link
Member

petuhovskiy commented Oct 12, 2023

Motivation

Currently we use a standard postgres way to download WAL – START_REPLICATION described in the postgres docs https://www.postgresql.org/docs/current/protocol-replication.html

The main problem with it is scalability, because each connection uses a separate TCP connection. TCP connections are not cheap to establish and maintain, and number of concurrent ps<->sk TCP connections is limited by the ports count.

The less improtant problem is protocol extensibility, which can also be improved, but may be ommitted in the first iteration since there is no bottleneck in it.

We already saw issues with network overloading, which manifested in DNS resolution failures. These issues were reproduced around pageserver/safekeeper restarts in a presence of 10k+ active timelines.

DoD

TCP connections between pageservers and safekeepers should be multiplexed, and there should be O(1) real network connections between specific pageserver and safekeeper.

Implementation ideas

https://neondb.slack.com/archives/C039YKBRZB4/p1683125758173469?thread_ts=1683097406.177109&cid=C039YKBRZB4

Use gRPC. It has HTTP/2 to multiplex many streams within a single TCP connection. It also provides convenient protocol extensibility.

I also think if we will have a gRPC connection between every safekeeper and pageserver, we can use it to bypass broker in delivering timeline updates from safekeepers to pageserver.

@petuhovskiy petuhovskiy added c/storage/safekeeper Component: storage: safekeeper t/Epic Issue type: Epic a/scalability Area: related to scalability a/performance Area: relates to performance of the system labels Oct 12, 2023
@problame
Copy link
Contributor

problame commented Oct 13, 2023

One advantage of one TCP connection per tenant is, though, that we get

  1. observability through standard tools
  2. fairness between tenant connections through TCP

I haven't kept up with how good gRPC is in either of those areas.

Let's perhaps turn this into a short RFC to discuss there?

@petuhovskiy
Copy link
Member Author

petuhovskiy commented Oct 13, 2023

RFC with implementation details make sense, I can create it later when/if I'll start working on this task. For now it should be ok to have a small conversation here.

observability through standard tools

What standard tools do you have in mind? netstat can show port and destination safekeeper address, and we can count number of active sockets, but it's hard associate specific tenant/timeline with a socket.

fairness between tenant connections through TCP

HTTP/2 streams are fair by default, and we also can specify weights if needed. I wouldn't expect any fairness differences from existing setup.

@VladLazar VladLazar removed the t/Epic Issue type: Epic label Oct 11, 2024
@VladLazar VladLazar changed the title Epic: Improve pageserver<-safekeepers WAL retrieval Improve safekeeper to pageserver protocol Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a/performance Area: relates to performance of the system a/scalability Area: related to scalability c/storage/safekeeper Component: storage: safekeeper
Projects
None yet
Development

No branches or pull requests

3 participants