It's easy to be cynical about Edinburgh in August, especially if you happen to live in the city all year round. The traffic clogs; desperate students thrust flyers into uninterested hands; litter-bins are routinely kicked over into the street of a drunken night. This most bridled of cities suddenly has its stays loosened by force, and this year is no exception. In fact, records seem set to tumble - more shows, more visitors, bigger audiences - confounding the doom-mongers who had started the finger- wagging even earlier than usual. A fire in the Old Town in December led to the demolition of the Gilded Balloon, a premier Fringe venue, but replacement sites have been found. There are more Spiegeltents than ever, while Edinburgh's mazy, cavernous nature has been exploited - all those tunnels and underground vaults coming to life as venues called things like "the Underbelly", hinting at a fringe beyond the Fringe and pointing to Edinburgh as a hidden city, a place with the continual ability to surprise.
Everybody likes to be in on a secret, in at the start of something big. No Festival Fringe is allowed to pass without mention of the greats of the past: Beyond the Fringe, or Eddie Izzard playing to an audience of four. We all wish we'd been there, and we cherish the notion of finding some future star tucked away near the foot of a bill of stand-up comedians. It's what I call PSG: "plus special guests". These are the opening acts, the hungry performers. They yearn to be headliners some day, and have heard that Edinburgh in August is awash with agents and talent-spotters, TV execs with fat chequebooks and schedules to fill, and reviewers who can flag up the unheralded genius. You will find them supporting a better-known stand-up, or performing for free on the Royal Mile, or opening for a band.
So far this year, I've paid to see four shows. Two of these were for children: Dr Bunhead's Bananas of Doom and the comedian James Campbell. I enjoyed both, even though they were aimed at my 11-year-old son rather than his 43-year-old father. The third and fourth shows were music events, one of the tickets to which bears the legend "Durutti Column (plus special guests)". Arriving early at the venue, I asked who the special guests were. No one seemed to know. We took our seats, and duly two figures arrived on the stage: a young woman with an acoustic guitar and a bloke with an electric guitar. I never did catch their names, but gradually came to admire them, representing as they did the unsung stalwarts of an entire creative industry. Some may be plucked from obscurity eventually; others are destined to languish for ever as PSGs. A few will have headliner status thrust upon them, as has happened with the hapless Aaron Barschak. The media interest generated by his antics at Windsor Castle may have helped popularise his appearance at the Fringe, but it hasn't made him many friends among his peers. Quality acts don't like it when upstarts get more recognition than they are due. Barschak has suffered from a critical panning, failed press conferences, exhaustion and a stage invasion by a Saddam Hussein lookalike. I'm told his show is improving, but it may already be too late: there's nowt so fickle as unearned fame.
I've been a PSG myself, a warm-up man for better-known writers. In fact, this is still my status in the US . (I toured in March this year, opening for my bestselling colleague George Pelecanos.) My first appearance at the Edinburgh Book Festival was as third string of a trio that included Colin Dexter and Michael Dibdin. This was in the early 1990s, and I was pretty much an unknown, even to my home crowd. The Rebus novels had yet to make any impact on the bestseller lists, while Dexter's Morse had become a TV phenomenon and Dibdin was one of the few crime writers around with a generous amount of literary kudos to his name. All I could hope to do was get myself noticed by cracking a few jokes and appearing to be different from my fellow performers. I seem to remember that a few souls bought books afterwards, so maybe it worked, but it was another eight or nine years before I moved on to headliner status.
To be noticed, you have to be bloody good, or bloody lucky. Barschak was lucky (or so some would say); the Durutti Column support was good, but probably not different enough to be plucked out from the crowd. Yet Edinburgh in August seems to many performers like the right place to be noticed. It helps if you can serve up a generous helping of controversy, which may go some way to explaining the plays about paedophiles and prostitutes, though it's harder these days to shock, and Moira Knox is no longer on hand as a Tory councillor to denounce any such offerings.
Novelty is also useful. If your drama is set in a public toilet, you can be assured media interest and a few photos in the broadsheets. Otherwise, only the true blockbusters gain much in the way of attention. This year we've got Scottish Opera's complete Ring cycle, Monet at the refurbished Royal Scottish Academy and Ewan McGregor in Young Adam. Not a bad triumvirate, though I'm sure Knox would have had something to say about the third's mix of sex, drugs and murder.
For a long time, there was a commonly held belief that Edinburgh's various festivals were "for other people", that locals fled to the hills in August (having first arranged to let their homes out to performers and tourists for outrageous sums). But thanks to computerised ticketing, we now know that most Festival tickets are bought by people with EH postcodes, and so the secret is out: much as Edinburgh likes to grumble about the litter, the crowds, the noise . . . secretly, we love the festival. It lets us see what it would be like to be a truly international, cosmopolitan city, a city of world renown. For a while, we can forget about the day-to-day problems that fill the pages of the local evening paper: the introduction of ugly communal rubbish-bins; the pervasiveness of our "Grey Meanie" parking enforcers; the ever-rising overspend on the new parliament building.
The original Edinburgh International Festival was dreamt up as an antidote to the glum aftermath of the Second World War. It was supposed to cheer us up and make us forget our woes. It still has that function, and continues to amaze with its ability to embrace multitudes, be they headliners or PSGs.
Book any Fringe ticket on 0131 226 0000 or at www.edfringe.com 
Ian Rankin's latest novel, A Question of Blood, is published by Orion