Due to the complexity of shale gas development formations, high-speed reciprocating compressors must be able to operate in harsh pressurization conditions, such as multiwall operation conditions and changing well conditions, resulting in high shaft system impact loads and poor cooperative matching of the rotation speed, which can easily cause shaft system torsional vibration and significantly reduce the performance and operational safety of shale gas compressors. The vibration test results of the shaft system at the Weiyuan site show that there were 3rd- and 7th-order torsional vibration phenomena in the shaft system. For this reason, in this study, the shaft system of a shale gas compressor at the Weiyuan site was used as the research object, a dynamic model of the shaft system under full-cycle alternating loads was established, and the correctness of the model was verified by the shaft system field vibration test Finally, an optimization study of the shaft system structure based on the response surface method was conducted, and the results show that the optimized shaft system increased the 1st-order natural frequency by 4.5% and reduced the peak velocity of the coupling in the vertical direction by 27.7%, improving the service life and operating reliability of the shaft system.