Upcoming: Method Throttles

Some methods will now be throttled to prevent abuse. A throttled method will throw a ThrottledException if it has been used too many times in too short of a time span. These throttles are scene-wide so once they are hit by any script in the scene it can affect all scripts in the scene.

The ThrottledException will have details on the particular throttle hit which can be useful in debugging or actively avoiding the throttle (and retrying when clear).

  • MaxEvents: The number of events allowed during Interval before the throttle is hit.
  • Interval: The TimeSpan during which MaxEvents is allowed
  • Elapsed: The TimeSpan from Now to the MaxEvent'th oldest event. The smaller this time the faster the throttle is being hit. The next method call will be allowed in (Interval - Elapsed) from Now. For example if a throttle allows 32 events, Elapsed is how long ago that 32nd (the oldest) event happened. If the throttle allows 32 events in 4s and the Elapsed is 3s then in 1s more that oldest event will "fall off" the throttle history and a new method call will be possible.

Exact Throttle Rates

  • Chat.MessageAllUsers: 32 per 4s
  • AgentPrivate.SendChat: 32 per 4s
  • Scene.CreateCluster: 64 per 4s

Example Use

Here is an example code snippet to Wait() in a coroutine until the throttle clears at least one event from its history which is the minimum wait to possibly succeed.

   // Something that could throttle
catch(ThrottleException e)
   Log.Write($"Throttle rate is {e.MaxEvents} per {e.Interval.TotalSeconds}.");
   Wait(e.Interval - e.Elapsed); // Wait out the rest of the interval before trying again.

If instead you want to wait for the throttle to clear entirely you could use Wait(e.Interval) instead.


Please sign in to leave a comment.