In the new energy interconnection environment, microgrid is an excellent means to solve the local energy supply and demand balance. In microgrid, due to the randomness and volatility of energy, it is necessary to configure certain energy storage units in the system to maintain the balance of real-time power and ensure the reliability of microgrid power supply. In this paper, combined with the engineering practice, the hybrid energy storage system of lithium battery and supercapacitor is adopted to establish the objective function based on the whole life cycle of the energy storage system, construct energy constraints, power constraints and load constraints, and use particle swarm optimization algorithm to solve it, fully tap the role of different energy storage systems in the balance of power and electricity of microgrid, and verify the superiority of the hybrid energy storage system.