Skip to content

smp-server: process forwarded commands concurrently on relay - #1911

Open
shumvgolove wants to merge 4 commits into
sh/fix-proxy-leakfrom
sh/fix-proxy-mesh
Open

shumvgolove wants to merge 4 commits into
sh/fix-proxy-leakfrom
sh/fix-proxy-mesh

Conversation

@shumvgolove

@shumvgolove shumvgolove commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Depends on #1905

The relay processed forwarded commands from each proxy connection one at a time, with a PostgreSQL round trip each, so under load the backlog piled up on the proxy (thread + ~16 KB block per forward) until forwards timed out.

  • forkCmd holds its concurrency slot until the command completes (the limit was not enforced).
  • The relay processes forwarded commands concurrently, up to client_concurrency per connection.
  • The proxy no longer keeps the forwarded block while waiting (53.0 → 36.8 KiB per in-flight forward).
  • At most 512 forwards in flight per relay (new INI [PROXY] relay_concurrency); above it the client gets PROXY BROKER TIMEOUT.

1000 forwards/s for 20 s, proxy and relay in separate processes:

Before After
proxy live heap 192-200 MiB 13 MiB
proxy memory in use 653-672 MiB 325 MiB
proxy threads ~4,000 420

Not done: per-queue response order. protocol/simplex-messaging.md

The router should send queueIds, error and ok responses in the same order within each queue ID as the commands received in the transport connection, so that they can be correlated by the clients.

Concurrent processing can reorder responses to forwarded commands for the same queue. SimpleX clients keep one message in flight per queue, so they are not affected; serializing forwarded commands per queue ID would restore it.

@shumvgolove shumvgolove changed the title smp-server: fix memory leak of failed proxy forwards smp-server: process forwarded commands concurrently on relay Oct 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant