a method of optimizing system parameters in a crude unit to reduce corrosion and corrosion byproduct deposition in the crude unit is disclosed and claimed . the method includes measuring or predicting properties associated with the system parameters and using an automated controller to analyze the properties to cause adjustments in the chemical program to optimize the system parameters . adjusting the system parameters effectively controls corrosion in the crude unit by reducing the corrosiveness of a fluid in the process stream and / or by protecting the system from a potentially corrosive substance . system parameter sensing probes are arranged at one or more locations in the process stream to allow accurate monitoring of the system parameters in the crude unit .