My advice is to build as many as you can and see how much granite, copper, and KP you need to complete each tech and the ones after, keeping in mind that each foundry and higher-level upgrade eats up granite and copper and see if it's worth the time it will take to recover the cost. Of course it will depend on how much space you have (or are willing to sacrifice) and how willing you are to be tech locked.
Right now I have 38 mines and 13 foundries and I am still tech locked while waiting to finish the last tech in Dwarves -- I should be done with it in 3 days. I found the numbers and ratio of mines and foundries I needed to be different from what Mykan's and Platinum Leaf's guides recommend, perhaps because I didn't upgrade them to the max because I calculated the cost to be not worth it (I don't have any Lv3 foundries or Lv4 mines). I'm actually regretting upgrading 6 mines to Lv2 in the past week because it takes 20+ days to recover EACH mine's upgrade expense. I only found out when I created specific equations for each tech's goods requirement. Each copper foundry you build also eats up granite so I'm actually ahead in producing copper than granite and I have 3x more mines than foundries unlike the usually recommended ratio of twice. I was tech locked twice before so that makes it a total of 3 tech locks this chapter which I think isn't so bad considering that I participated heavily in two tourneys (13-15 provinces each), lightly in one (5 provinces), plus all the KPs I had to buy for the Flurry event.
EDIT: After this day's yield, I find myself needing 1-2 more foundries (I woke up quite a bit to collect from the low-level mines more often so thank you insomnia) and my granite can withstand building 2 foundries to better match copper and granite production time for research completion.