The invention discloses a storage capacity optimal allocation method based on improved primary frequency modulation, belongs to the field of grid frequency modulation and is intended to provide a storage capacity optimal allocation method to reasonably plan and allocate the capacity of an energy storage system in order to solve the problem that the energy storage system has relatively high cost. The method herein comprises: S1, providing a capacity optimal allocation model, and calculating standard deviation R of grid frequency values at different moments according to sampling data; a) if thestandard deviation R increases, controlling storage output to carry out frequency modulation until the standard deviation R decreases; b) if the standard deviation R decreases, detecting SOC (stage ofcharge) of an energy storage battery; S2, detecting the SOC of the energy storage battery, wherein an SOC value of energy storage being in an interval near SOCref is most favorable for energy storageoperation; setting the interval to [SOC1, SOC2]; c), if the SOC value is not within [SOC1, SOC2], performing extra charging-discharging on the energy storage battery until the SOC value is within [SOC1, SOC2]; d) if the SOC value is within [SOC1, SOC2], calculating a storage capacity value according to a storage capacity calculating method.