Also don't forget that militia units in a City can, up to a point receive free upkeep. Get the Faust, find out which ones and garrision cities for Free.

The HRE is somewhat different from the Byzantines but I find that the 3:1 city-castle ratio gives you too many castles. I try not to have more than a 4:1 ration and maybe less than that.

Example out of an empire of 31 provinces:
Zagreb
Budapest
Raggusa
Durazzo
Sophia
Bran
Bucharest
Corinth
Thessaloníki
Constantinople
Nicaea
Smyrna
Iconium
Trebizond
Cesarea
Tbilisi
Yerevan
Mosul
Baghdad
Edessa
Aleppo
Antioch
Adana
Nicosia
Iraklion
Rhodes
Acre
Damascus
Jerusalem
Alexandria

I have only
Ragussa
Bran
Cesarea
Acre
Tbilsi
Mosul
as castles which is a 5:1 ratio. Of those only Ceasarea is not on or near a border.

But, if you do that kind city/castle ratio you MUST build up the drill square in the cities to get whatever pale and barely adequate HRE equivalent to the Varangian Guard is. Otherwise you will probably not have access to enough good troops