The Great White Way flows red for four out of five musical shows, according to top Broadway producers.

But producing that rare hit play has more to do with backstage decisions than what the audience sees.

Broadway musicals typically take years to produce and tens of millions of dollars to mount, with 80 percent commonly bleeding red ink. But those few that make it into the black often have profit returns that could make Warren Buffett blush.

“Some 21 percent of musical shows recouped their costs while 79 percent did not,” says Ken Davenport of Davenport Theatrical Enterprises. He has produced hits such as “Kinky Boots” and “Godspell.”

Davenport’s numbers come from a study he and his associate, Dylan Jarrett, conducted via the Web site The Producer’s Perspective.

Broadway musicals from 1994 to 2014 were analyzed.

While the Great White Way came out of 2014 as strong as ever, it was on the backs of the few shows that were monetary winners, says the Broadway League.

Besides box-office receipts, some of the concerns that keep producers up at night include choosing the right theater, keeping costs in line with revenue expectations and proper marketing, according to Davenport.

“Broadway is a very special world,” write Jeff and Todd Brabec, “one that defies reality in any discussion of whether something is a good or a risky investment. Because of this, knowledge of how things work behind the scenes is many times more important than what happens on stage.”

The Brabecs are the authors of “Music, Money and Success: The Insider’s Guide to Making Money in the Music Business.” The play’s not always the thing — it’s who writes the checks, they say.

“Even with significant weekly box-office ticket receipts, a sustainable hit depends on the difference between the box-office income and the costs of the musical. If the costs are greater than the income, or if the income barely exceeds the costs, the musical is on the way to closure,” the Brabecs say.

Industry observers say an example of a popular show that was too costly was “Spider-Man: Turn Off the Dark.”

It opened in November 2011. Throughout 2012, it grossed about $1.5 million a week, a huge amount. But industry observers say it had a bad cost structure and would have had to average $1.5 million every week for three years just to break even.

“Spider-Man,” which was one of the most expensive shows ever mounted (Davenport estimates the cost at $80 million), closed in January 2014.

Besides lack of cost controls, Davenport says there are other reasons plays don’t cover costs:

Producers often don’t have the right material — the book isn’t good.

They fail to market shows properly and don’t understand the importance of word of mouth.

Sometimes shows are in the wrong house — producers forget that their target audience member is usually a woman in her mid-40s.

However, find the right play, reach the right audience and keep costs under control, and a hot play can be as good or better than the riskiest alternative investment that hits the jackpot.

The Brabecs say it usually can take two years for a successful show to recoup costs, But it sometimes can be as little as a year.

Indeed, the success of the few shows that found the right money formula lifted the entire industry in 2014.

Last year was the best-attended and highest-grossing calendar year in Broadway history, according to the Broadway League. The total gross was $1.362 billion and total attendance was 13.13 million.

Charlotte St. Martin, executive director of the Broadway League, said the fat year was because of “record-breaking holiday weeks, including Thanksgiving, Christmas and New Year’s.”