Random early detection (RED) is an active queue management mechanism designed to provide better performance than traditional DropTail. However, its parameter setting has proved to be very sensitive to network scenarios and needs constant tuning to achieve ideal performance under varying network conditions. In view of the fact that RED has not been understood well enough for an analytical approach, this paper takes advantage of network simulation techniques and formulates the optimal configuration of RED as a black-box optimization problem. An optimization objective is designed to effectively reflect the tradeoff between utilization and queueing delay. Based on the proposed RED optimization scheme, a general automatic network management system, i.e., on-line simulation system, has been used for the on-line tuning of RED under changing network conditions. The proposed approach is empirically validated with simulations and real network experiments. The simulation results show that RED controlled with on-line simulation system is able to stabilize around the expected equilibrium status under varying conditions and maintain high utilization.