A networking apparatus comprising: a plurality of communication interfaces configured to receive and send data over one or more networks; packet-switching logic configured to determine how to process data units, including forwarding at least some of the data units to other network devices via the plurality of communication interfaces; one or more buffer memories configured to store the data units while the data units await processing by the packet-switching logic; queueing logic configured to utilize a plurality of queues to manage an order in which the buffered data units are processed by the packet-switching logic; delay-tracking logic configured to calculate delay measures associated with the queues based on arrival timestamps associated with at least certain data units in the queues; policy management logic configured to determine one or more policies to apply to particular data units assigned to particular queues based on particular queue delay measures calculated for the particular queues; wherein the packet-switching logic is further configured to implement the determined one or more policies by performing one or more actions indicated by the one or more policies on at least a subset of the particular data units; wherein the packet-switching logic is further configured to determine whether a given data unit is in the subset of the particular data units based on a counter associated with a policy that the policy management logic determined to be applicable to the given data unit, a size of the counter having been determined based on a queue delay measure associated with a given queue to which the given data unit was assigned. a plurality of communication interfaces configured to receive and send data over one or more networks; packet-switching logic configured to determine how to process data units, including forwarding at least some of the data units to other network devices via the plurality of communication interfaces; one or more buffer memories configured to store the data units while the data units await processing by the packet-switching logic; queueing logic configured to utilize a plurality of queues to manage an order in which the buffered data units are processed by the packet-switching logic; delay-tracking logic configured to calculate delay measures associated with the queues based on arrival timestamps associated with at least certain data units in the queues; policy management logic configured to determine one or more policies to apply to particular data units assigned to particular queues based on particular queue delay measures calculated for the particular queues; wherein the packet-switching logic is further configured to implement the determined one or more policies by performing one or more actions indicated by the one or more policies on at least a subset of the particular data units; wherein the packet-switching logic is further configured to determine whether a given data unit is in the subset of the particular data units based on a counter associated with a policy that the policy management logic determined to be applicable to the given data unit, a size of the counter having been determined based on a queue delay measure associated with a given queue to which the given data unit was assigned.