How are record producers compensated?

I was reading a print article (sorry no cite) on Sir George Martin the other day which gave the impression that while certainly comfortable, he wasn’t particularly wealthy, which kind of surprised me considering how much money The Beatles as an entity generated in record sales during their career.

Now I assume that in the early days nobody made a lot of money, except perhaps the concert promoters and record company itself, but after a while I would thing he would have been paid handsomely for the producer credit on who-knows-how-many gold and platinum albums.

Although I know something about how performers, songwriters and managers are compensated I realized I knew nothing about how a record producer was paid. Do they get a flat fee for each song or albumn? A percentage of the gross sales? A combination of both? Can someone in the record biz fill me on how this is normally handled?

I realize, of course, that every deal is different… but how much does a record producer make relatively to everyone else who has their hands in the pie?

I read one production contract that was tangentially related to a case I worked on for a fairly big rock star. The deal was in the high five figures, plus a percentage of the royalties–somewhere in the range of 5%–that kicked in after the album sold x number of copies.

(Interestingly, I just looked up the album on Amazon and discovered that he only got credit as the engineer. Go figure.)