In the beginning phases of the game do you focus on teching or expanding?

Typically I hammer out a horsearmy or 2 and then begin to expand my empire.

I grow my cities to 3, bank food, then create a settler. I repeat this with every city I create while my horsearmys wreak havoc.

I get about 10 cities going, and my horsearmys get stalled at this point by archer armies. I check the tech tree and I see whoever I am playing against at this point is way ahead of me in techs because I have been busy expanding. By the time I get to the point that I get some Knight armies going I am so far behind in the tech race that its game over.

How do you balance expanding and teching?