Hard-won lessons on scaling teams and technology from a CTO who's made the mistakes so you don't have to.