Scaling your app simply means having more running dynos that are load balanced by a centralised load balancer used across the entire platform. So yes, interestingly there is a lot of duplication of the code base.
Services, like databases, are managed on their own separate servers/clusters and allow multiple connections and can be scaled/sharded separately from the dyno farms. Therefore they can be monitored, maintained, upgraded, etc, separately as well.
I'm a small-time contributor to http://github.com/openruko, an opensource Heroku clone.