element-hq / element-hq/dendrite

Implement QoS measures

Open
#1,622 3 comments 0 reactions 0 assignees View on GitHub
design:components security T-Task X-Needs-Discussion
Dominant language
Go
Stars
965
Forks
101
PR merge metrics
No merged PRs in 30d

Description

*This issue was originally created by [**@kegsay**](https://github.com/kegsay) at .*

At present, we trust users to play nice and not flood the server with rooms, messages, account data, etc. This isn't feasible long term, but works for now as Dendrite is still immature and experimental. We need to think about how to implement Quality of Service metrics to prevent a single user from being able to take out a server. This issue is a melting pot for ideas of how to do this.

I brought this up [in the before times](https://github.com/matrix-org/dendrite/issues/8) and suggested bundling metrics into `Context`. I still feel this is a feasible solution. Each user would get a certain number of "credits" which get consumed (akin to AWS EC2 CPU credits) which get replenished over time. Any operation which uses resources would decrease the credits. If the credits reach zero we either cancel the context, aborting the request, or we tarpit the request by sleeping until we have sufficient credits.

A few random questions:
- How many credits do users get and are they all equal or can it be configured in some way?
- How do you track resource usage (and which resources are tracked)? In a perfect world we would track CPU time and memory consumption for all operations initiated by that user, but we often share resources (e.g room caches) and Go doesn't have that level of granularity on its metrics.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the Context proposal and the earlier issue #8 linked in the description, then map how user operations consume shared resources. The issue needs a concrete QoS scope, credit and replenishment policy, resource-tracking approach, and enforcement behavior before implementation can be considered complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.