To achieve high efficiency and stability in dye-sensitized solar cells (DSSCs), it is crucial to optimize porosity by maximizing the surface area available for dye absorption and charge transport, while minimizing charge carrier recombination through the use of appropriate materials and interfaces. This study presents a numerical simulation that incorporates charge carrier transport and recombination to investigate the impact of changes in porosity and recombination rate on DSSC performance. The results indicate that increasing porosity enhances performance by increasing the surface area for dye adsorption and light absorption. However, excessively high porosity can lead to lower efficiency due to increased recombination losses. Finding the optimal porosity for a specific DSSC system is critical for achieving high efficiency and stable performance. A model porosity of 0.4 was determined to be optimal. Moreover, increasing the recombination rate can significantly reduce DSSC efficiency, underscoring the importance of minimizing recombination losses in device design.