I’m visiting the Russian River Brewing company, in Santa Rosa, California — about an hour north of San Francisco. To the untrained eye, the only thing that gives the warehouse away as a brewery is a large grain mill jutting out of the back and a small pile of colorful kegs. But come closer to the massive open door, and it becomes immediately clear that magic is being made here. Liquid magic.

Standing beneath a massive, stainless steel tank that regularly holds 100 barrels worth of beer, it’s hard to imagine how something smaller than a human hair could mean tossing all of it out. Yet the tiny bacteria that could turn this brew into an acrid, undrinkable slop are lurking all around us, entirely invisible to the naked eye. These microbes are both a brewer’s best friend and worst nightmare.

This is a small facility, though Russian River has managed to turn out award-winning beers that have inspired a cult-like following. The brewery is best known for Pliny the Elder and Pliny the Younger, both of which sit in the highest of the high ratings on Beer Advocate and Ratebeer, two immensely popular beer review sites. "I want to make babies with this beer and pick out window treatments on a Sunday while the big game is on and you know what I don't care about missing the game because I'm in love!," gushes one reviewer of Pliny The Elder on Beer Advocate. "The flavor will cause the uninitiated to dial 911," writes another. "I want to make babies with this beer."

They’re not exaggerating. Drive a few miles up the road to the company’s pub (where smaller batches of beer are also being brewed), and you’ll see a seemingly never-ending parade of people hobbling out the doors with boxes of the beer in hand. In part, that’s because the brew can be difficult to find, but also because Pliny begins losing its hoppy flavor shortly after it’s bottled. Unlike some wines and many other types of beers, the sooner you drink this one, the better it tastes. But something very simple can throw that flavor off before most types of beer are even bottled, and cause further troubles once it’s left the brewery: Pediococcus and Lactobacillus, two types of bacteria with voracious appetites that can wreak havoc by leaving an undesirable sour taste in their wake. They can be crucial to making some beer styles, but if unchecked in others (like say an India Pale Ale), they can ruin a batch. That’s why I’m here: Russian River is among the first breweries to try a new test for these germs, one that promises to take a week-long test that has become the standard among brewers, and do it in just under three hours. "If you lose one turn, you’ll lose thousands and thousands of dollars."

One of the big reasons so much testing is done is that these bacteria can be found just about everywhere if you’re brewing beer. The microbes are naturally occurring in malted barley, and can thrive in the nooks and crannies of brewing equipment — from drain pipes and hoses, to foam that may not have been washed away. Breweries put in place numerous safeguards to keep contamination from happening. Russian River is in a rather unique situation because, alongside its hoppy beers, it’s also brewing sour beers, which are steeped with Pediococcus and Lactobacillus to produce a flavorful, funky taste. Like a Kosher kitchen, the brewery keeps the equipment completely separated from one another, so things like hoses, kegs, and even lifts are labeled with red tapes or "funky" warnings. Workers who have been producing one of those sour beers will even go home, take a shower, and come back later with a new pair of clothes to avoid cross-contamination. For years, the prescribed method for seeking out certain types of bacteria was a system called plating. That involves taking a very small sample of beer, then putting it onto a plate of what is basically bacteria food. The whole thing is sealed up, then put in an incubator. Breweries usually put plated samples of the same batch both in open air and in a special anaerobic chamber to simulate the oxygen-free existence of life in a bottle. Wherever the plate is, the bacteria will either grow into a colony that can very clearly be seen with the naked eye, or never appear at all. Knowing whether these bacteria are in the brew is something you just can’t do by looking at beer on its own. "It’s not like yeast, where you can take a look at it and say ‘okay there are 10 per mil[lileter] or like a million per mil, says Mike Guilford, who runs Russian River’s quality control operations. "Bacteria is really small, and can move around."

While accurate, plating’s biggest downside is that it takes time. And with beer, like most businesses, time is money. Breweries of all sizes are constantly juggling a fresh supply of ingredients with space on their brewery floors, where complex chemistry is happening around the clock. And when hiccups happen, it can take days to get a rhythm back. "Every time you can turn [around] that tank, fill it up, and empty it, that’s another batch of beer you can sell," Guilford says. "Anything in the line that holds that up pushes everything off. If you lose one turn, you’ll lose thousands and thousands of dollars." To speed up turnaround time, Philadelphia-based company Invisible Sentinel has come up with a new rapid testing kit called the BrewPal that identifies isolated chunks of DNA from problem bacteria. It’s not meant to diagnose every potential problem that could threaten a good beer; rather, it’s designed to target the specific types of Pediococcus and Lactobacillus bacteria that are responsible for serious, and often irreversible damage.

Invisible Sentinel is not the only game in town for beer, but it claims to have one of the smallest and most inexpensive solutions thus far. A full system costs less than $5,000, which puts it out of the range of home-brewers, though on the bottom end of these types of brewery tools. "All the other PCR-based instruments out there are way more expensive," Guilford says. "We’re talking $30- or $40,000, and they take up way more counter space, and you have to grow [bacteria] on some of them, or you have to enrich them over the course of a day or two, so we never thought of purchasing one." Competitors include Sigma-Aldrich, whose HybriScan system promises results in 2 to 2.5 hours, and can limit its screening to only living bacteria (unlike Invisible Sentinel, whose positive includes dead bacteria). There’s also a cartridge-based testing tool from the Pall Corporation that came out in mid-2012, which plugs into a master system that can scan for other microorganisms. If someone's beer is bad, they might not ever buy it again All these companies are trying to solve the beer spoilage problem because it’s the kind of thing that can keep beer customers, both old and new, from buying a beer again. While seasonal beers can vary based on differences in ingredients, people expect a certain beer from a brewery to taste the same every time they buy it, much like they would a dish at a chain restaurant. But bacterial infections can very easily keep that from happening. "One of the reasons it’s such a difficult problem is that it’s so difficult to catch it, and to prevent it," says Adam Bartles, the director of brewing operations at Victory Brewing across the country in Philadelphia. "These bacterias, once they start producing acid, there’s no rectification — you can’t neutralize the sourness." That’s why brewers have long turned to early warning systems, he says.

"One of the reasons it’s such a difficult problem is that it’s so difficult to catch it, and to prevent it." Victory Brewing, which brews approximately 100 times as much beer as Russian River does each year, has also been using the kits as part of a validation test. Basically, this means Invisible Sentinel making sure its creation works before selling it on the open market, a process that has involved brewers continuing to run plating tests alongside the BrewPal, and comparing the results to make sure they match up. The idea behind the BrewPal is that you can simply get a yes or no for if the bacteria is there, much like an over-the-counter test for pregnancy. The test uses a polymerase chain reaction, or PCR for short. The process was developed in the early 1980s, and effectively works as a photocopier for DNA, amplifying a relatively small sample into something that can be more accurately measured. It’s been used in everything from criminal forensics and paternity tests to helping enforce overfishing tied to black caviar. Testing using the BrewPal is a fairly simple three-step process, but still requires precision, training, and several pieces of extra equipment. First, a sample of beer is collected and run through a centrifuge, sending all the bacteria and solids down to the bottom of the tube. A liquid buffer is added, then the liquid part of the sample is piped into a much smaller tube that goes into the BrewPal hardware. Then, the sample is carefully heated and cooled for about two and a half hours so that the bacteria’s DNA can be amplified. The final step involves taking the sample and dropping it into a disposable plastic reader that looks a lot like a pregnancy test. Three minutes later, you can see if you’ve got the bacteria there, or you don’t. The reading will also say whether you have a mild infection, or a very bad one.