This document examines the optimization problem of cost-effective resource allocation for overlay routing relay nodes, demonstrating that the problem is NP-hard and proposing a non-trivial approximation algorithm. The research shows that a minimal number of relay nodes can significantly enhance routing efficiency for TCP, VoIP applications, and BGP routing, potentially reducing path lengths by 40%. Practical implementations are illustrated using real data, highlighting the advantages of overlay routing for improving network performance.