What are some of the software technologies behind "real-time" web apps, like Twitter, Trello, or even Gmail? I know there's a webserver and probably a database on the backend, but what are the software pieces that make for that rich web interaction that I'm seeing more of today?
Comet plays an important role in these applications.
Comet is a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it.
Besides comet, these applications also need a good backend. The solutions may be very specific to the problem.
Twitter, for example, has to stream tweets to all your followers for each of your tweets. Facebook has to run machine learning algorithms to select which stories to stream on your News Feed.
Although different, these applications have many things in common: heavy use of cache, data denormalization, asynchronous jobs, are highly distributed.
Server-side, a plethora of different technology stacks.. As Raynos eluded to in his comment, virtually anything can be used to build a real time web application...
Again, those are just a few examples of possibilities. The possible permutations of tech stacks for implementing server-side solutions is virtually endless.