It seems to be portrayed as commonplace in modern literature, but how common was it in reality?
Actual ritual suicide was not as common as it is made out to be, although its portrayal has such definitely increased the proclivity of people to do so.
The most common form of seppuku was as punishment. Samurai that had committed crimes could be asked to commit seppuku. If they refused, they would have either been actually executed, or simply forced into it. The idea was that it allowed the samurai to save some face, that "he killed himself because he was ashamed," and so retained his honor.
Historically, seppuku has been seen as an almost romantic way to die. For instance, Minamoto no Yoshitsune, a great general, was defeated in battle and retreated to commit suicide rather than face inglorious defeat and execution. His follower, Benkei, famously defended him against attack until he did so, and it was said that he died standing up, frightening enemy soldiers until they realized he was dead for an hour.
Similarly, Oda Nobunaga, a great warlord during the Sengoku Period, was betrayed and cornered at Honnouji Temple. He too, committed suicide by seppuku, capping off a rather legendary reputation with this rather romanticized method of death.
More recently, after the death of the Emperor Meiji, General Nogi, commander of Japanese ground forces during the Russo-Japanese War, committed seppuku out of grief and his belief in junshi, which is the belief that vassals should not outlive their lord (compare this with the Indian tradition of Sati, for example, where the wife of a dead lord would be thrown onto his funeral pyre). It was likely his death that helped revitalize the practice to the modern day, where every now and then you hear about white-collar employees killing themselves out of shame or to make a protest.
Sources:
Mason, A History of Japan
de Bary, Sources of Japanese Tradition
Tale of the Heike (Heike Monogatari)