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

Rate limiting for scheduling #306

Open
nhoening opened this issue Jan 7, 2022 · 5 comments · May be fixed by #587
Open

Rate limiting for scheduling #306

nhoening opened this issue Jan 7, 2022 · 5 comments · May be fixed by #587

Comments

@nhoening
Copy link
Contributor

nhoening commented Jan 7, 2022

Scheduling is the first operation we should start to rate-limit, as it is most expensive. Foremost, this protects against bad/rogue client implementations.

My suggestion (taking into account the state before Project 6 is implemented:

  • Make a new field on GenericAssets: max-actuation-rate (a timedelta). How often we allow someone to re-compute things for their asset is a business decision I believe, so this is where it belongs.
  • Update the sensor/<id>/schedules/trigger endpoint, so it checks when the last scheduling job happened and if it was too recently, it does not make a new one, or it schedules one into the future (in this option we also need to check if in the future a scheduling job already exists).
@nhoening
Copy link
Contributor Author

nhoening commented Jan 7, 2022

Curious to hear @Flix6x thoughts.

@Flix6x
Copy link
Contributor

Flix6x commented Jan 7, 2022

I like it. I think this parameter would also be suited for being coupled to the organisation account instead: for example, a "plan" JSON column for Accounts similar to our "attributes" JSON column for GenericAssets.

@nhoening
Copy link
Contributor Author

nhoening commented Jan 7, 2022

I agree that this has consequences for the "plan" of customers, as pricing could be derived from this (among other things).

Why a JSON column?

Also, they might want to rate Assets differently within their account.

@Flix6x
Copy link
Contributor

Flix6x commented Jan 7, 2022

Why a JSON column?

A max_actuator_frequency field feels like it would be part of a blob of attributes assigned to something.

they might want to rate Assets differently within their account.

True. I'd start with implementing the default value on the Account plan, and we could consider whether it makes sense to write plan searching logic like we have attribute searching logic on the Sensor class, which first checks whether the attribute exists on the Sensor, and if it doesn't, looks for the attribute on the GenericAsset. Similarly, we could elevate a plan attribute search on the GenericAsset to a plan attribute search on the Account.

@nhoening
Copy link
Contributor Author

A max_actuator_frequency field feels like it would be part of a blob of attributes assigned to something.

Well, in relational databases, we'd usually make a table called "plan", with a foreign key to Account, and store plan details there. That's what I'd recommend.

@nhoening nhoening linked a pull request Mar 31, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants