I wrote this a couple of years ago for my alliance on evolliance others have copied and pasted into thiers , nobody uses evo anymore so not to be lost forever.

There is no one size fit's all defence set up and there are two main types of wall defences that change the range in which the battle begins which in turn changes what order your troops fight, so i will give 3 examples of what you need to build using a traffic light system that is tough to clear quickly.

Red Zone- defence under severe threat of multiple heavy attacks.
Amber Zone - defence set up were you have enemies close by.
Green Zone - defence set up were your cities have no enemies nearby.

Example 1 - Green Zone Range Defence total cost -3 million food p/h

[li]Worker.....................500..........Warrior... ..............300,000[/li]
[li]Scout........................500..........Pikeman. ...............10,000[/li]
[li]Sword.................10,000..........Archer...... ............150,000[/li]
[li]Cavalry.................1,000.........Cataphract.. .............1,000[/li]
[li]Transports...............500.........Ballista..... .................5,000[/li]
[li]Battery Ram............500.........Catapult............... .....1,000
[/li]

Workers/Scouts/Transports are none combatants so i just put 500 in for layering and Rams are only useful in large numbers which is too expensive so i put 500 here for layering too.

When i say range defence this means city walls with Traps/abatis and defensive Trebuchet in.
This is the order in which your troops fight/defend.
Cav protect your phracts, phracts protect your Pike, Pike protect your Sword, Sword protect your Warriors, Warriors protect your Archers, Archers protect your Archers Towers and other range units.

Archbow attacks have 4 rounds before they are in range of your archers so they work there way through your Cav/phract/pike/sword before your archers will hopefully one shot kill. depending also how well layered his archbow is, your city is and number of your archers you have left and hero levels, plus other item buffs.

Scoutbombs go straight through TnA and don't stop for $hit, they fight at zero range and target your highest attack value group.Best defence against scoutbombs is to have equal number of Pikeman to archers because they have a higher total attack value but in a range defence they are in easy range of an archbow and die fast, so no good here, warriors are the next best option.

Troops Numbers- reasons for said amounts in example 1

You only need 1 Cav/1 Phract/1 pike/1 sword to give your warriors 4 rounds of protection against archbow and even if you only have a 10% heal rate you can heal pike/sword three times and cav/phract twice.But it's better to have 10x that amount so when you are online you can reinforce each of your Valley's with 1k pike/sword and 100 Cav/phract and recall whenever you need to replace layers.
So you see if you're online you can fend off archbow after archbow before any reinforcments arrive.
Warriors are not as cost effective as pikeman when it comes to protecting against scoutbombs but they do have four layers infront of them so are more practical.
300,000 warriors won't stop scoutbombs from hitting your archers at first but they will stop your archers from falling to a critical level.
Ballista and Catapult don't fight until later rounds but they will help clear a well layered archerbow(in theory, not 100% sure).

----------------------end of example one--------------------------

Example 2 - Amber Zone - Range Defence total cost -5 million food p/h


[li]Worker......................500........Warrior.... ..............500,000[/li]
[li]Scout.........................500........Pikeman.. ...............10,000[/li]
[li]Sword................200,000........Archer........ ...........150,000[/li]
[li]Cavalry..................1,000.......Cataphract... ..............1,000[/li]
[li]Transports................500.......Ballista...... .................5,000[/li]
[li]Battery Ram.............500.......Catapult................ .....1,000
[/li]

Same as example 1 but with 200k sword and 500k warriors for better defence against multiple scoutbombs and archbow, costing an extra 2 million food per hour.
Better to have this set up if you are expecting an attack while offline or have red flags close by or if your city is close to enemy border.
Mechanized attacks are the biggest threat here, but it will probably take two large mech waves to clear you.

------------------------end of example two------------------------

Example 3 - Red Zone- Flat/Compact Defence total cost -9 million p/h


[li]Worker.....................500..........Warrior... .................10,000[/li]
[li]Scout........................500..........Pikeman. .............250,000[/li]
[li]Sword.................10,000..........Archer...... .............250,000[/li]
[li]Cavalry..............50,000..........Cataphract... ..........90,000...................Example of Compact Defence[/li]
[li]Transports..............500..........Ballista..... ...............10,000[/li]
[li]Battery Ram.......1,000..........Catapult................. ...2,000
[/li]

Flat or Compact defence is when your walls have Archers Towers and rolling logs ONLY,no abatis,no traps,no rock fall!
This alters starting range of attacks and changes the order in which your troops fight dramatically, almost the complete reverse of a range defence.
The attackers range units are now in range of your Archers Towers and attack them first followed by your archers and other range units before taking on your ponies then mele units.
Previously ponies and pikeman were rubbish for defence because they were targeted first but now they are awesome.

Troop Numbers - reason for said amounts in example 3

You need more archers because they get targeted after AT's and now you can have equal number of pikeman to archers for defence against scoutbombs, because mele units get targeted last by archbow or Ballistae attacks.
You don't need lots of sword or warriors for the same reason but just keep 10k of each i will explain why later.
With nothing to slow down enemy attacks your ponies can now rush out and rout the enemy making them vital to have in large numbers and they suffer very few losses, the more Cavalry and Cataphracts you have the better but i tried to keep the food bill down as much has possible here by just saying 50k Cav and 90k phracts.
I have added a few more mech's here as they will play a bigger roll now in defence too.
This city set up is a must for keeping Cavalry and Cataphracts safe and is regarded by some as the best defence to have while offline.
With no TnA you can build extra AT's, ideally you want 18k of them but leave a few spaces open in your walls to pop out the odd TnA so you can reverse the order in which your troops fight/defend to protect your last few archers, which is why you want 10k sword and 10k warriors.
The only attack that is devastating against you here is one with mass Battery rams and all you have to do is build a few trebs to create range and wipe them out.

---------------------------end of post---------------------------