Dynamic queue capacity algorithme