There is a serious problem with the water heater. It could be getting too little oxegon but I think it's more of a problem with the burner assembly. It needs too be checked by a licensed plumber. If the water heater is not too old the burner needs to be removed and cleaned as well as the pilot ect. The pilot and burner need to be checked for proper flame output. And a gas leak test should be performed. If you must do this yourself take great care. You might shut it down and try vacuuming the firebox out while lightly scrubbing the dirty areas being extra careful around smaller parts. After turning it on spray soapy water on the external gas connections and around the controller which is located on the front of the heater. Active bubbling indicates leaks. Be careful relghting the water heater, you could get burned.