In P2P systems, especially in mobile environment, participating nodes may connect to or disconnect from the system frequently. This user-driven dynamic membership problem, called churn, may significantly reduce the routing robustness of a structured P2P system because of its fully-decentralized routing information. Most existing structured P2P systems use constant periodic maintenance approaches with static parameters to improve the routing robustness under churn. However, the cost-effectiveness of this strategy mostly depends on the churn rate of the system. In real dynamic P2P systems, using static parameters may result in unnecessary bandwidth cost under low churn, or low lookup success rate under high churn. We propose a flexible and cost-efficient method for structured P2P networks under churn taking the evolution of churn conditions into consideration. Self-tuning parameters are applied for failure detection and routing table maintenance by using the online time of nodes for predicting node availability. To achieve better cost-effectiveness, by allocating more maintenance bandwidth for those nodes considered unstable and less bandwidth for the long-lived nodes. Simulation results show that the proposed approach outperforms the traditional periodic maintenance method both under low churn and high churn. Under low churn, less bandwidth is consumed while the lookup success rate almost remains at the same level. Under high churn, the lookup success rate is higher with an acceptable amount of additional bandwidth consumed.