The answers to this will probably vary, because my question is pretty broad--I want to know about the whole range of castles through different histories and cultures. How many people worked behind the scenes to keep a castle running for King Henry, for example, and what were all those different jobs? What about more in medieval times or even ancient times like for pharaoh or Caesars? How many people washed dishes, how many people cared for animals, how many people cleaned the chamber pots, how many were around just to deliver messages and run errands at the beck and call of their masters? Were there tailors and jewelers and such employed by the castle or were those kinds of things outsourced? How many people lived in the castle who weren't actually the royal family? When I watch movies or read books like Elizabeth or the Tudors or even The Princess Bride or Game of Thrones, I want to know how all of those castles functioned behind the scenes. I'd appreciate any explanations as well as any resources you can direct me to!
Basically, the castle as we generally think of it is a uniquely medieval entity. While at times performing the same functions as a palace or a fort, it was really an oddity. It was not a community in the way a town or a village was, or a center of production, or a trading hub. It was a fortified dwelling for an aristocrat, his family, and his household (hangers-on), running from humble local lords who might possess only one relatively small castle, to kings who might possess dozens, some of which could be quite massive painstakingly constructed. In the latter case, it's necessary to distinguish between castles that were royal residences, and castles that were basically forts, built primarily for military purposes.
Few castles had large permanent staffs. Generally, the staff was attached to the lord, and if he had multiple castles in which he resided, the staff (household is the catch-all term) moved with him. Thus we see the kings of England moving around the country with huge groups of followers, ranging from aristocrats - his household officers and knights - to more mundane common servants. How many of the latter there were is not something they really kept track of. We only have accurate records of household knights for a handful of English kings, especially John and Edward I, and these were aristocrats! If you're wondering, at one point Edward had 600-odd knights attached to him, although not all were with him in person - some being farmed out to royal lands, or acting as castellans (sort of like a governor/commander) for royal castles.
A castle which did not have a lord in residence, such as royal castles located along borders, might have very small groups of people in residence, basically a skeleton force of soldiers and perhaps a few servants to keep the place up. One of Edward I's Welsh castles had a garrison of around 20 men when it was attacked by rebels! On the other hand, if it was strategically vital, it could have quite a large permanent garrison; Chateau Gaillard in Normandy was defended by 500 men when it fell to Philip II.