With the increasing penetration of renewable energy, it is critical to ensure that energy storage have the capability to perform peaking and frequency regulation service. The traditional energy storage operation mode may become impracticable due to conflicting interests, insufficient utilization, and poor interoperability. Riding on the wave of the proliferation of sharing economy, storage energy sharing expands application scenario of energy storage without requiring costly and time-consuming infrastructure investments. This paper proposes a framework for using a shared energy storage (SES) to undertake the primary frequency response (PFR) for multiple renewable generation stations and provide peaking and commercial automatic generation control (AGC) service simultaneously. Furthermore, a two-stage capacity optimization base on robust theory is proposed to minimize the investment cost of SES, considering peaking and frequency regulation performance, battery degradation cost and the state of charge (SOC) limits. The goal is to maximize social welfare and ensure the benefits of SES. The numerical simulation is carried out based on the data from northwest China to validate the result.