
As the yeast goes about its fermentation, carbon dioxide is released as a byproduct. The purpose of the stopper and airlock is to act as a one way valve that allows for the release of pressure from within the fermenter, while preventing air from entering.
If a fermenter is sealed, pressure would build up. If the pressure were to get to high, one of two things could happen. Either the fermenter would rupture (possibly explode), or the high pressure would cause the yeast to stop fermenting.
If a fermenter is left open to air, the ferment would soon become oxidized. Another certainty is that airborne bacteria, yeast, mold etc... would come into contact with the precious contents, causing contamination.
The combination of stopper and airlock allows us to prevent the above from happening. In the home environment, the stopper is a tapered rubber bung with a hole drilled through it. Stoppers come in a variety of sizes to fit the many different containers that can be used. Airlocks come in a variety of styles, and are made of glass or plastic. They work by directing the carbon dioxide to up into the lock, then down through a reservoir of water or alcohol. After the gas bubbles through the liquid, it escapes to the atmosphere. This same reservoir, plus the slight positive pressure inside the fermenter keeps air and airborne contaminents out.
Glass airlocks are more expensive and fragile than their plastic counterparts. I recommend using the plastic ones, and always having one or two extras on hand in case of breakage.
In addition to airlocks, some brewers/winemakers use blow-off tubes during primary fermentation. During active fermentation, varying levels of foam will be produced as the carbon dioxide bubbles out of the ferment. The amount of foam produced is somewhat dependant on the product being fermented. In my experience, beer produces more than wine, mead or cider.
While yeast selection plays a role in this, the sugar concentration and temperature of the ferment has a more direct relation to this foam production. If enough of this foam is produced, it would take up all of the headspace, then be forced out through the airlock. If this thick foam dries out and plugs up the airlock, pressure will build up in the fermenter until the stupper is blown out along with some of the foam. This can create quite a mess.
A blow-off tube could be used when you expect very active fermentation, or have a small head space available to contain the foam. The tube is made out of large diameter 'food grade' plastic tubing. It should be sized to fit firmly into the opening of the fermenter without any gaps between it and the fermenter. The other end of the tube is placed into a bucket, jar, etc... which is partially filled with water. This creates the barrier which allows the carbn dioxide to escape, while preventing air from traveling to the fermenter.
The advantage of the blow-off tube is that it is harder to create a blockage in the larger diameter tubing than in the smaller airlock. As the head/foam settles, the tubing can be replaced with a stopper and airlock.
Although I have never used a blow-off tube, it should be something for you to consider. It is a lot more effective when you are using a 6.5 gal carboy as your primary fermenter rather than the 7 gal plastic ones I use. Even though the plastic fermenter provides me with more head space, I still have the occasional overflow which I have to contend with. So far, none of the airlocks have become clogged and blown their top. I always keep a fresh stopper and airlock in a sanitizing solution if I feel an overflow is possible.
The options of using the stopper and airlock and/or a blow-off tube is something that you can discuss with your local retailer or other hobbyist.