We’re changing throttling in Adafruit IO for the better. We’re moving from a fixed-window, long period throttle rate that can lock out clients for up to 15 minutes in some cases to a rolling-window, short period throttle rate that can reset sooner when clients are well behaved.

In the past, hitting our authentication or data limits could result in a lock on your account for up to 15 minutes. If you’ve ever seen the red bar at the top of your browser window while you’re working on an IoT project, that was most likely a throttle. The short explanation for that is that we were using a fixed-window throttling algorithm that resulted in message bursting when we made the window of time too small. The best solution we had at the time was to make the window longer, which resulted in the 15 minute lock-outs mentioned above.

With our new system, very similar to the one described here, once you’re throttled on authentication or sending data, stopping sending will be guaranteed to reset your throttle in less than 1 minute. The tradeoff is that continuing to send messages at a greater-than-limit rate will cause you to remain throttled forever. Where the old system would let you back in for authentication after 15 minutes, the new system could lock you out forever if you have a large enough collection of misbehaving devices you’re unable to stop.

To avoid being throttled, make sure you set delays on all reconnection attempts of at least 10 seconds and make sure you’re sending at most 1 message per second across all your devices and browser sessions. For example, our Arduino library delays for 60,000 milliseconds between reconnection attempts after it’s been throttled. Client libraries will let you post data as fast as you’d like, so it’s a good idea to keep a subscription to the MQTT $username/throttle topic open somewhere you can see it while you’re writing code.

Some additional benefits of the new system going forward:

  • We can now manage throttling across the MQTT and HTTP APIs.
  • We now have a few additional variables we can tweak to make the experience of building an IoT device or application nicer. For example, we can set minimum distances between messages and scale the rate/window to smaller slices (10 messages / 10 seconds rather than 60 / 60). We’ll be keeping an eye on throttling once we’ve deployed the new system.
  • Refactoring our throttle logic lets us customize throttle rates across accounts, which will support Adafruit IO paid subscriptions in the future.

It’s tricky to be brief, but we put a lot of thought into changes like this and we like to share. :D

Please speak up on the forums with any questions or thoughts. We’d love to hear how you’re using IO!