Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

A client can easily overwhelm the servers memory by constantly sending to a broadcast hub method #2084

Closed
BrennanConroy opened this issue Apr 18, 2018 · 1 comment
Assignees
Labels
3 - Done cost: S Will take up to 2 days to complete type: Bug
Milestone

Comments

@BrennanConroy
Copy link
Member

BrennanConroy commented Apr 18, 2018

We currently fire-and-forget hub invocations

_ = _dispatcher.DispatchMessageAsync(connection, message);

This can cause high lock contention and quickly grow the servers memory when many invocations are trying to write to the same connection. A quick test where we await the invocations shows stable low memory without affecting RPS in the load test that found this.

Server Hub

public class BroadcastHub : Hub
{
    public Task Broadcast(string message)
    {
        return Clients.All.SendAsync(message);
    }
}

Client

while (true)
{
    hubConnection.SendAsync("Broadcast", "flood server");
}
@muratg
Copy link

muratg commented Apr 19, 2018

Approved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3 - Done cost: S Will take up to 2 days to complete type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants