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.”

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.