flexmeasures
flexmeasures copied to clipboard
Rate limiting for scheduling
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).
Curious to hear @Flix6x thoughts.
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.
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.
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.
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.