A composition's duration is heavily dependent on the tempo at which it's performed, and so there is no universally accepted "longest piece ever". The longest piece ever performed (and still being performed) is John Cage's "As Slow As Possible". It is currently being performed on an organ in Halberstadt, Germany. The performance began in 2001, is still ongoing, and is due to finish in 2640.
Read more