ABSTRACT For lofting the performance of wireless sensor networks, a lightweight gradient elevator algorithm model is improved using a virtual resource scheduling model and sparrow search algorithm particle swarm optimization algorithm. A new network intrusion detection method (SSAPSO-LightGBM) has been proposed to improve detection accuracy and efficiency. Then, the data security transmission level and user historical priority resource scheduling model (SDT-HRU-VRSM) are used to schedule resources to ensure network resource revenue. The results show that the SSAPSO LightGBM algorithm has a detection accuracy of 99.61% for Normal, 98.42% for R2L, 97.03% for U2R, 96.01% for Probe, and 98.41% for DoS. The SDT-HRU-VRSM model not only meets the needs of secure data transmission, but also takes into account the stickiness of increasing high-quality users. And according to security requirements, the number of virtual resource scheduling is increased, reducing the number of service network slicing instances and improving security. This model can effectively increase the attack cost of malicious users and increase network revenue, which is crucial for ensuring the security and efficient operation of wireless sensor networks.