Currently E-commerce recommender systems are being used as an important business tool by an increasing number of E-commerce websites to help their customers find products to purchase. Collaborative filtering is the most successful and widely used recommendation technology in E-commerce recommender systems. However, traditional collaborative filtering algorithm faces severe challenge of sparse user ratings and real-time recommendation. To solve the problems, a collaborative filtering recommendation algorithm based on domain nearest neighbor is proposed. The union of user rating items is used as the basis of similarity computing among users, and the non-target users are differentiated into two types that without recommending ability and with recommending ability. To the former users, user similarity will not be computed for improving real-time performance; to the latter users, “domain nearest neighbor” method is proposed and used to predict missing values in the union of user rating items when the users have common intersections of rating item classes with target user, and then the needed items space for missing values predicting can be reduced to the few common intersections. Thus the sparsity can be decreased and the accuracy of searching nearest neighbor can be improved. The experimental results show that the new algorithm can efficiently improve recommendation quality.