A primitive called the resource controller is introduced that abstracts the problem of controlling the total amount of resources consumed by a distributed algorithm. An efficient distributed algorithm to implement this abstraction is presented. The message complexity of the algorithm per participating node is polylogarithmic in the size of the network, compared to the linear cost per node of the naive algorithm. The implementation of the algorithm is simple and practical; the techniques used are based around a global quantity being managed in a distributed way. The resource controller can be used to construct efficient algorithms for a number of important problems, such as the problem of bounding the worst-case message complexity of a protocol and the problem of dynamically assigning unique names to nodes participating in a protocol.