How to make two motors have really equal speed?

I want it to follow a specific degree like a car with IR sensors follows a black line, is it possible ?
And I heard the digital compass would be interfered by metal,So I still cant really figure out a nice &simple solution.

How to use two encoders to make sure it goes straight? I have install one to count its moving displacement& turning 90 degrees .

thanks