The IEEE 802.16 standard has been developed for metropolitan broadband wireless access systems. As part of the standard, the random access scheme is used for initial ranging. The ratio between the numbers of initial ranging slots and data slots in the uplink subframe decides the contention throughput, access delay and data throughput. However, no specific ratio is standardized in the protocol, so it is still necessary to determine the optimal number of initial ranging slots which is the decisive factor of the ratio. In this paper, we analyze the three parameters above, contention throughput, access delay and data throughput, each of which can be expressed as a function of the number of initial ranging slots. In addition, we define an objective function and derive the exact equation of the optimal number of ranging slots. Based on the equation, we propose an optimal dynamic controller to allocate the initial ranging region in the uplink subframe. We also propose an estimation scheme to obtain the number of contention users using Newton Iteration method. To verify the correctness of the analysis and the efficiency of the controller, we conduct extensive simulations. The simulation and analytical results match very well. The results show that good system performance can be achieved with the optimal dynamic controller.