I started monitoring the temperature of my beehive a few weeks ago. The result was a deeper appreciation for the beauty of decentralized algorithms.
A few weeks ago, I used a Twine to monitor the internal and external temperatures of my beehive. I threaded the external temperature probe into the back of the hive and down between the frames at about the middle of the hive. Here's a picture of the Twine hanging off the back of the hive:
I'm not the first person to measure hive temperature, of course, and I kind of knew what to expect, but still it was amazing to see with my own eyes. The bees kept the hive at a steady 93-94°F (34°C) regardless of outside temperature.
The screenshot on the left shows the output of the twine one cloudy afternoon. Even though it's 81°F outside, the inside of the hive is 94°F. (Note: the "external temperature" reading is the probe that is inside the hive while "temperature" is the Twine itself which is outside the hive. So the terminology on the screen is a little confusing.) In the morning when it was 60°F outside, it was still 93°F inside the hive. On one hot afternoon when the external temperature was 101°F outside, the internal temperature was still 93°F.
As an aside: I'd love to show you a graph of the temperature reading over time, but Twine makes getting regular readings extremely difficult. Consequently, I don't have one. I really can't recommend the Twine for this sort of project, or any project where data collection is a key part. Its a fun little gizmo, but it's really just a toy with limited capabilities—a shame considering how much it costs.
Bees regulate the temperature of the hive because a constant 34°C is necessary for normal brood development. A healthy beehive produces tens of thousands of new bees every year, so brood production is critical to the colony's survival.
Everyone I told about this asked "how do the bees do that?" The straightforward answer is that some bees go to the entrance of the hive and fan air to increase circulation when the internal temperature gets too high and bees cluster in the center and generate heat by shivering when it gets too low (see Endothermic heat production in honeybee winter clusters by Stabentheiner et. al.).
The more interesting question is "how do the bees know to do that?" If you asked most people they'd assume the queen bee tells the workers to go fan. But the queen isn't that smart. She does control many things that happen in the hive through the release of pheromones, but she doesn't make conscious decisions the way we would. And it turns out that she has little to do with thermoregulation (and most other tasks). Those decisions are made in a completely decentralized fashion.
But it's not as simple as every bee making independent decisions. They have to be coordinated—bees are social, after all. If every bee who felt hot went down to the entrance and started fanning, there wouldn't be any bees left to tend brood, clean cells, carry out dead bees, guard, or forage. And too many bees fanning would make the hive swing wildly to the "too cool" side. The actual mechanism for regulating temperature is startling in its simplicity and amazing in its elegance.
Division of Labor
Bees use division of labor in the spring and summer when there are large nectar flows to ensure they get all the honey socked away they can. The division of labor is based on age with the youngest workers cleaning cells and moving onto nursing functions, mortuary activities, guarding the hive, and finally, in the last weeks of their lives, to foraging for water, nectar, and pollen. Foraging bees literally work themselves to death in a few weeks with their phenomenal metabolic rates. This progression from one job to another is largely based on age. (See Models of Division of Labor in Social Insects by Beshars and Fewell and Division of labor in honeybees: form, function, and proximate mechanisms by Johnson for more details). In the winter, bees are mostly concerned with surviving the winter and become generalists with all bees doing all functions.
But if workers merely moved from tasks to task based on a strict age-based criteria, the hive wouldn't be able to respond to changing conditions like a cold snap or an unusual nectar flow. And inflexibility is something nature punishes severely. Thermoregulation is an excellent case in point. If a certain number of bees always fanned or generated heat simply because that was their job without any feedback, the hive wouldn't hold a steady temperature.
Rather, bees appear to have different thresholds for performing certain tasks. A young bee has a very high threshold for foraging. The stimuli that encourage foraging have to be very high before a young bee with leave the hive to forage. Similarly, an older bee, while having a low threshold for foraging, will have a higher threshold for performing guard duties. But if the hive is under attack, even older bees will take up guard duties to defend the hive. (See Quantitative Study of the Fixed Threshold Model for the Regulation of Division of Labour in Insect Societies by Bonabeau et. al.)
Further, these thresholds vary by patriline. While all the bees in the hive have a single mother (the queen), they have different fathers (the drones). Queens mate with drones from other hives (another fascinating process) and this causes diversity in the gene pool. One advantage of this diversity is a variety of thresholds for a given job even among bees of the same age. This diversity promotes even responses to changes in stimuli. As the hive gets hotter a few bees will take up fanning duties. As the temperature continues to climb, even more will join the work, and so on. (See Honey Bee Nest Thermoregulation: Diversity Promotes Stability by Jones et. al.)
One other interesting question is "how do they know when to stop doing a task like fanning?" Turns out they just quit after some period of time, also related to their genetically programmed thresholds. If the hive still needs increased air circulation, some other bee will eventually take their place in response to the temperature stimulus. So, they don't really decide to quit so much as get bored and go do something else.
Decentralized Decision Making
The introduction to Jones el. al. concisely and nicely describes the end result:
In many human workplaces, tasks are allocated by a system of centralized control. Managers are aware of the needs of their organization, the abilities of each of their employees, and the available materials. On the basis of these various pieces of information, managers try to allocate tasks to their workers in a way that maximizes the profits of the company. In contrast to this hierarchical system of task allocation, workers in insect societies are not allocated tasks in any way. Rather, they engage in tasks on the basis of local information gained from their immediate nest mates and environment. Nonetheless, despite this highly distributed nature of organization, insect colonies respond extremely well to changes in task demand.
The end result of genetically diverse thresholds to stimuli is a hive that responds in a way that is even and measured to the changing conditions it encounters without any kind of centralized control. The hive is a super organism with its intelligence spread out among its tens of thousands of constituent members. Life and death decisions are made on a daily basis in a completely decentralized fashion.