Intelligent Internet Computing (IIC) is emerging rapidly including grid, cluster computing, and peer-topeer computing to provide computing and communication services any time and anywhere. IIC foresees the integration of communicating and computational devices and applications in our heterogeneous computing environments. In this paper, we focus on the task allocation, which is a typical problem in the area of high performance computing and has been extensively studied in the past. Efficient task allocation is critical for achieving secure and high performance in a heterogeneous computing (HC) environment. In addition, the problem of allocating these tasks to the machines of a HC environment has been shown, in general, to be NP-complete, requiring the development of heuristic techniques. Therefore, a task allocation algorithm based on discrete particle swarm optimization (PSO) algorithm in the HC environment is proposed in this paper. Firstly, a new structure of cluster system is designed, and a mathematical model is built for dynamic server alliance according to practical tasks and situations of servers. Then an efficient discrete PSO with a well-designed particle position code and fitness function is proposed. A mutation operator which can effectively improve the algorithm's ability of global search and population diversity is also introduced in this algorithm. Finally, the simulation results compared with other algorithms show that this proposed algorithm produces better results in terms of both quality of solution and convergence speed.