Traffic congestion is common in most cities. It not only affects people's normal travel time but also causes more traffic crashes. To solve the traffic congestion and reduce the corresponding hazards, it is necessary to quickly detect the location of traffic congestion. In view of the fact that the trajectory data record the temporal and spatial information of moving objects, this article presents two methods for the real-time detection of traffic congestion through real-time processing of trajectory data. One is to use distributed densit-based spatial clustering of applications with noise (DBSCAN) clustering to detect the location of traffic congestion. The other is to perform distributed topology analysis of trajectory data to find congested areas. Finally, extensive experiments that involved using three real datasets to simulate both real-time detection methods on Spark Streaming demonstrated the efficiency of the two methods.