Congestion is one of the factors that affects evacuation efficiency in emergencies. In this study, we focus on shortening the total evacuation time (TET) by setting obstacles near the exit. For this purpose, we add a probability-based obstacle avoidance strategy to modify the original social force model to simulate pedestrians’ obstacle avoidance behaviour. Using the model, we analyse the influence of the number of obstacles, their position and their distance to the wall with the exit on the TET. In addition, we discuss the relationship between the average density at the exit and the TET, which shows that crowd diversion is an effective method to alleviate congestion and shorten the TET. The simulation results show that the evacuation efficiency can be improved by reasonably setting obstacles near the exit. This study can provide some guidance for the management of crowds during emergency evacuations.