This ensures balancing when working with dynamically resolved upstream servers with multiple addresses. Based on patch by Anton Jouline.