I kind of feel that each task should have a notion of a 'created time' or something that returns the priority of the task. For now I am putting it here. Tasks are sorted in the pending queue based on their created time. There is also a notion of a 'queue insert time'. This is because when a task is inserted into a pending queue, it may still be a few millseconds before the task is actually run. During this time, it is possible that the auto scaling stuff will look at the pending queue, see that something is pending, and then create a new worker. To get around this, the scaling strategy makes sure anything that is in the pending queue has been there for at least 30 seconds (this is configurable).