#Monsters and Armies are different problems.
Monsters and Armies are different problems.
With individual monsters, you probably want to catch all or most individuals. A leak rate of 20% or 30% is likely unacceptable. So you need enough troops on the wall, 24/7, to catch them. Call it a double patrol every 50m, plus a small squad every 400m or so -- enough to arrive at the midway point in a minute, even running in armor. Quadruple that for 24/7 duty and we're talking about 6,000 troops.
You need fewer troops on a nice, sunny day, but the garrison should be able to cope with rain and snow. Go with the worst weather assumption.
Against an army, you have the benefit of inner lines. The purpose of fortifications is not to be impenetrable, it is to buy time for a small number of defenders until the main defensive force arrives at the trouble spot, and to increase the effectiveness of the defenders. If a few scouts climb the wall, so what? They could just as well disguise themselvers as traders and bribe the gate watch.
An army of 20,000 with baggage and a siege train would do well to do 15 km in a day. By contrast, the defenders need one or two hours from the center of the city to the wall. So it should be possible for the defenders to match any attempt of the invaders at concentrating their force. The key question, then, how many people do you need on the walls to block the invaders below?
Look at the numbers for Chateau Gaillard, or the 1187 siege of Jerusalem (even if that ended in a capture).