As with many historical styles, there are many varying versions on exactly hose the imperial stout style came into being. Basics: stouts stemmed from porters. A stronger version of the porter, a "stout" porter was made and the porter part eventyally dropped. Stout became its own style that branched off into other categories as well. The Imperial Stout was a stronger version of the stout, supposedly made specifically to last the journey to Russia. Though there may have been other reasons as well, it did gain the name "imperial" due to its popularity with the imperial court of Russia. This was the first time "imperial" was attributed to a beer. It is now used in conjunction with many other styles, indication it is a stronger version of that style (usually 8% abv and above).
Barrels have been around for a crazy long time & have been used in the storage and transportation of all sorts of cool stuff, from denarii (Roman coins) and crackers early on to olive oil, vinegar and wine in the middle ages. The design of the barrel, with its bulbous midsection, made it easy to pivot and roll heavy loads from place to place. Of course, beer made its way into a barrel too...
However, flavors from the wood were not desirde at first. To prevent this, the wood was soaked in boiling water, hydrochloric acid or lined with pitch or tar. Now, we have stainless steel kegs for general storage, so if wood barrels are used, imparted flavors from the wood is usually desired. Most often, brewers take previously used barrels from the world of wine and spirites. Wood flavors are softened and you get the bonus flavors of the pervious inhabitant. We typically let our already fermented beer rest in barrels for close to a year. These barrels sit in the ambient temperature of our brewery. The brewery is not temperature controlled, so heat and humidity change with the seasons. This lack of control would usually cause great concern; however, temperature swings are a friend to barrel aging. With those changes, the beer inside the barrel works its way in and out of the walls, soaking up all the delicious flavors of the wine or spirit and flavor compounds from the wood itself. These flavors can include cherry, vanilla, coconut, and more depending on the type of wood used in its cooperage. Since the base beer has already gone through fermentation, it contains thebulk of its booze before entering the barrel. However, it can pick up a percent or two after soaking up the spirit from the walls. You can barrel age any style in any type of barrel. We've barrel aged an Imperial IPA in gin barrels, a Belgian single in Tequila barrels, a Belgian stout in cognac barrels...whatever flavor combination is desired. Howzabout a barleywine aged in Malort barrels? That'd be something.

We make this imperial stout every year in late December & early January. After fermentation, the beer goes into used Woodford Reserve Bourbon barrels to sit in ambient temperature for the rest of the year. With temperature changes, the beer will expand and contract in and out of the walls, picking up delicious flavors from the bourbon soaked wood, as well as flavors of toasted coconut, cinnamon and vanilla (imitation vanilla comes from wood as opposed to the actual vanilla beans). We do intensify these flavors by adding vanilla beans and cinnamon sticks to the barrels towards the end of the process. In late December, we take the beer out of the barrels, carbonate it, and put it into bottles and a few kegs. While consistency is usually desired in most of our beers, this is one where the difference year to year are part of what makes it so cool. The base beer is always the same; however, with variances in temperature and other factors throughout each year, the flavors brought out from the abrrel will also vary. For example the 2015 version had quite a bit of cherry flavor, while the 2016 had very little cherry but was more intense in coconut. This year, 2018, coconut aroma is robust. Flavors like silky dark chocolate and cherry are present. Roasty, warm cinnamon undertones round it all out. It is quite the cozy experience...like your mouth is relaxing by a fireplace in a log cabin.
Aging Astronaut Status in the Bottle
Once in the bottle, one could age it (if it is possible to have it in your possession and not drink it). Some flavors will fade (like cinnamon) while others will intensify (like sherry), so the desired length of aging time really depends on what you want out of it. It will smooth out a bit after a month as the heat from the booze fades. So, if you wanted to get some drink now and some for later (or even some to drink much much later), well, that'd be cool...