Skip to content

IoT Rules 1000 limit/quota not allowing to scale

0

How are we going to use rules?

We were planning to use rules to create automations. Every IoT device(smart bulb) will have an individual rule with certain condition. If that condition is met then rule will trigger a lambda.

Let's say we have

  1. Smart bulb (thing_name Smart_Bulb)
  2. Light sensor (thing_name Light_Sensor, topic : sensor_values/Light_Sensor )

The smart bulb user has set itself to turn the bulb ON if light intensity goes below 30%. So the SQL query of the rule will look like :

SELECT light FROM 'sensor_values/Light_Sensor' WHERE light < 30

If the above rule is true then the rule will invoke a lambda which will send a command to Smart_Bulb to turn the light ON.

Now this approach is not scalable as there is a max quota of 1000 rules you can generate per region. Which means we can not have more than 1000 bulbs.

Do we easily get approvals to increase the quota and make it scalable and what might be the costly if that is so. If not then should we think of something else ?

Thanks

asked 3 years ago631 views
4 Answers
2

Hi. You will likely want to make use of wildcards in the FROM clause and the topic() function in the SELECT clause. To end up with something like this as the SQL statement for your rule:

SELECT light, topic(2) as thingName FROM 'sensor_values/+' WHERE light < 30

That way, one rule can process the 30% condition for all light sensors. If the 30% value is configurable, there are many possible ways to solve it.

More information here: https://docs.aws.amazon.com/whitepapers/latest/designing-mqtt-topics-aws-iot-core/best-practices-for-using-mqtt-topics-in-the-aws-iot-rules-engine.html

AWS
EXPERT
answered 3 years ago
  • Hello Greg,

    I understand what you mean by wildcard entries for select query, but our where condition is configurable and will be dynamic and different in every smart bulb.

    Example for 3 bulbs:

    SELECT light FROM 'sensor_values/Light_Sensor_1' WHERE light < 30

    SELECT light FROM 'sensor_values/Light_Sensor_2' WHERE light < 45

    SELECT light FROM 'sensor_values/Light_Sensor_3' WHERE light < 80

    How to achieve this?

  • Where will the threshold be stored? You might use get_dynamodb in the rule. Or you might check the threshold in the Lambda instead of the rule. Or you might send the threshold setting to the bulb so it only publishes a message when the value traverses the threshold. But I wouldn't recommend you dynamically replace/delete/create the rules because ReplaceTopicRule has a hard limit of just 5 TPS.

1

Hi,

As an alternative to DynamoDB to store the sensor specific thresholds, you can leverage named device shadows and use the following SQL:

SELECT light FROM 'sensor_values/+' WHERE light < get_thing_shadow(topic(2), "threshold", <IAM role arn>).state.desired.level

The content of the threshold named shadow for one of the sensors would be:

{
  "state": {
     "reported": {
        "level": 30
    }
  }
}

Documentation for get_thing_shadow

Cheers,

Massimiliano

AWS
EXPERT
answered 3 years ago
0

Hello Greg,

I understand what you mean by wildcard entries for select query, but our where condition is configurable and will be dynamic and different in every smart bulb.

Example for 3 bulbs:

SELECT light FROM 'sensor_values/Light_Sensor_1' WHERE light < 30

SELECT light FROM 'sensor_values/Light_Sensor_2' WHERE light < 45

SELECT light FROM 'sensor_values/Light_Sensor_3' WHERE light < 80

How to achieve this?

answered 3 years ago
  • Response in comment trail above.

0

Hello,

Thank you for your answers, gave us clarity for few things.

Here are few followups that might help us completely understand the problem statement.

Firstly, the using of function like get_thing_shadow & get_dynamodb in the rule sounds great to solve one-to-one relationships (1 Light_Sensor triggering 1 Smart_Bulb) but how to tackle one-to-many relationships (1 Light_Sensor triggering 3 Smart_Bulb).

Light_Sensor publishes real time light intensity on topic 'sensor_values/Light_Sensor' 

Smart_Bulb_1 has threshold 30%
Smart_Bulb_2 has threshold 45%
Smart_Bulb_3 has threshold 80%

Now using the rule statement as you suggested has one problem

SELECT light FROM 'sensor_values/+' WHERE light < get_thing_shadow(topic(2), "threshold", <IAM role arn>).state.desired.level

The problem is that it will return the thing name as Light_Sensor, and whose shadow will have no information about the threshold of individual smart bulbs. As thresholds of individual smart_bulbs will be stored in their respective shadows.

The same problem can be iterated in using the get_dynamodb function instead of get_thing_shadow.

Can we use rules to scale up in this situation ? Is there any chance AWS allows to increase the quota limit on requests for specific use.

Thanks.

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.