In this paper, we explore the optimal risk sharing problem in the context of peer-to-peer insurance. Using the criterion of minimizing total variance, we find that the optimal risk sharing strategy should take a linear form. Although linear risk sharing strategies have been examined in the literature, our study uncovers a significant finding: to minimize total variance, the linear strategy should be applied to the residual risks rather than the original risks, as commonly adopted in existing studies. By comparing with the existing models, we demonstrate the advantage of the linear residual risk sharing model in variance reduction and robustness. Furthermore, we develop and study a number of new models by incorporating some constraints, to reflect desirable properties required by the market. With those constraints, the optimal strategies turn out to favor market development, such as incentivize participation and guarantee fairness. A relevant model is considered at last, which establishes the connection among multiple optimization problems and provides insights on how to extend the models into a more general setup.