In this paper, an optimal resource allocation strategy is proposed to enhance traffic dynamics in complex networks. The network resources are the total node packet-delivering capacity and the total link bandwidth. An analytical method is developed to estimate the overall network capacity by using the concept of efficient betweenness (ratio of algorithmic betweenness and local processing capacity). Three network structures (scale-free, small-world, and random networks) and two typical routing protocols (shortest path protocol and efficient routing protocol) are adopted to demonstrate the performance of the proposed strategy. Our results show that the network capacity is reversely proportional to the average path length for a particular routing protocol and the shortest path protocol can achieve the largest network capacity when the proposed resource allocation strategy is adopted.