Currently, the integration of new energy sources into the power system poses a significant challenge to frequency stability. To address the issue of capacity sizing when utilizing storage battery systems to assist the power grid in frequency control, a capacity optimal allocation model is proposed for the primary frequency regulation of energy storage. Due to the requirement of a large number of actual parameters for the optimal allocation model, a simulation model of energy storage capacity is constructed based on the characteristics of primary frequency control to provide the necessary parameters. Subsequently, the primary frequency modulation output model of energy storage is established by considering the basic action output, the action in the frequency modulation dead zone, and a certain capacity margin. The antlion algorithm is employed to solve the capacity optimal allocation model. Finally, three groups of experiments are designed and compared to demonstrate the effectiveness of the proposed method in setting the capacity margin, which can increase profit to a certain extent.