A membrane reactor produces high-quality biodiesel by combining both reaction and separation in a single unit. However, the reactor has disadvantages such as high operating expense and reduced efficiency over time due to membrane fouling. To solve this issue, frequent cleaning with physical and chemical methods is required. Membrane cleaning contributes to the reactor’s operating cost to a large extent, including energy, chemicals and even production loss. Although there have been studies undertaken focusing on improving membrane cleaning, optimizing the performance of the membrane reactor in biodiesel production has received limited attention. In this work, a novel membrane cleaning model is presented and used to optimize the membrane reactor efficiency in terms of biodiesel yield and cleaning costs. The model captures the dynamic states of reversible and irreversible membrane fouling during the cleaning process. It is further used to evaluate the effects of backwashing and chemical cleaning on the membrane reactor. The results show that the number of backwashes during operation is a crucial factor to improve reactor productivity and reduce the cleaning cost. The membrane reactor’s operating time rose 2 to 3 times when the operating period between two backwashes, or an operating cycle, reduced from 70 min to 15 min. The biodiesel yield increased significantly due to the extended operation. However, longer operating time led to an accumulation of more irreversible fouling, which could not be removed by backwashing. The cost of chemical cleaning rose as the irreversible fouling level increased. Regarding the cost-to-yield ratio of the biodiesel reactor, the best operating conditions were found at the operating cycle of 25 minutes between 2 backwashes. Overall, the cleaning model allows the prediction and reduction of the cleaning expense of the membrane reactor, increasing its potential as a biodiesel production technology significantly.