At present, blockchain technology is more and more widely used in the field of food traceability, and good results have been achieved. However, many of the current blockchain technologies and algorithms are not developed for the specific situation of food traceability, resulting in resource waste and low computational efficiency. In view of these problems, this paper analyzes and summarizes the classic distributed consensus mechanism in blockchain technology, focusing on the PBFT (practical Byzantine fault tolerance) consensus mechanism and the existing problems related to the improvement scheme. In order to solve the problem of low efficiency of a consensus algorithm in a food traceability scenario, this paper proposes a blockchain consensus algorithm suitable for the food traceability scenario based on clustering and food credit. In addition, the differences between the improved algorithm and the classical Byzantine consensus algorithm in consensus algorithm time and communication times are analyzed through experiments and simulations. The consensus efficiency of the improved algorithm in this paper is significantly improved, which can greatly reduce the application difficulty of blockchain in food traceability.