We present SoFiA 2, the fully automated 3D source finding pipeline for the WALLABY extragalactic HI survey with the Australian SKA Pathfinder (ASKAP). SoFiA 2 is a reimplementation of parts of the original SoFiA pipeline in the C programming language and makes use of OpenMP for multi-threading of the most time-critical algorithms. In addition, we have developed a parallel framework called SoFiA-X that allows the processing of large data cubes to be split across multiple computing nodes. As a result of these efforts, SoFiA 2 is substantially faster and comes with a much reduced memory footprint compared to its predecessor, thus allowing the large WALLABY data volumes of hundreds of gigabytes of imaging data per epoch to be processed in real-time. The source code has been made publicly available to the entire community under an open-source licence. Performance tests using mock galaxies injected into genuine ASKAP data suggest that in the absence of significant imaging artefacts SoFiA 2 is capable of achieving near-100% completeness and reliability above an integrated signal-to-noise ratio of about 5-6. We also demonstrate that SoFiA 2 generally recovers the location, integrated flux and w20 line width of galaxies with high accuracy. Other parameters, including the peak flux density and w50 line width, are more strongly biased due to the influence of the noise on the measurement. In addition, very faint galaxies below an integrated signal-to-noise ratio of about 10 may get broken up into multiple components, thus requiring a strategy to identify fragmented sources and ensure that they do not affect the integrity of any scientific analysis based on the SoFiA 2 output.