A method and apparatus for producing a biocide from a hypochlorite oxidant and an ammonium salt are provided. The method includes monitoring a control parameter to optimize the ratio between the hypochlorite oxidant and the ammonium salt. The control parameter may be oxidation-reduction potential, conductivity, induction or oxygen saturation.