When asking about a Mac desktop with longevity upgrade ability, that means the Mac Pro. The 27" iMac is a nice machine with a great display and its memory can be upgraded, but that's the extent of it. The iMac 21.5" models are not user upgradeable. The latest Mac Mini is actually more upgradeable than an iMac. (hard drive and memory) But you would have to supply a monitor, keyboard, and pointing device.
You also mentioned cost effective. A late model Mac Pro (depending on its configuration) can be expensive. And a new Mac Pro (2014 model) can easily exceed $3500, again depending on its configuration.