Optimal Operation of Queues