Due to the complex structure of a distributed energy resources system (DES) and a large amount of sensor data, local computers cannot provide enough computing resources to process the related data in a short time. Moreover, network integration causes a power system vulnerable to denial of service (DoS) attacks. DoS attacks result in the loss of partial sensor data, which affects the control performance of local computers on a power system. Therefore, this paper proposes a power system structure optimization strategy based on both sparse constraint optimization and cloud computing to solve the lack of computing power from local computers and prevent DoS attacks. Cloud computing is introduced to provide powerful computing resources for processing the related data in the proposed solution. The blocking probability of sensor data caused by DoS attacks is reduced by optimizing the sensor layout of a power system and reducing the transmission of sensor data. This paper also proposes a control strategy based on actor–critic reinforcement learning (RL) to maintain the stability of a power system during the structure optimization process. Three IEEE bus test systems are used to verify the effectiveness of the proposed structure optimization method and control strategy. The experimental results confirm that the proposed structure optimization method and control strategy can maintain the stability of a power system under DoS attacks.