This paper deals with a congestion control framework for elastic and real-time traffic, where the user's application is associated with a utility function. We allow users to have concave as well as non-concave utility functions, and aim at allocating bandwidth such that utility values are shared fairly. To achieve this, we transform all utilities into strictly concave second order utilities and interpret the resource allocation problem as the global optimization problem of maximizing aggregate second order utility. We propose a new fairness criterion, utility proportional fairness, which is characterized by the unique solution to this problem. Our fairness criterion incorporates utility max-min fairness as a limiting case. Based on our analysis, we obtain congestion control laws at links and sources that (i) are linearly stable regardless of the network topology, provided that a bound on round-trip-times is known, (ii) provide a utility proportional fair resource allocation in equilibrium. We further investigate the efficiency of utility fair resource allocations. Our measure of efficiency is defined as the worst case ratio of the total utility of a utility proportional fair rate vector and the maximum possible total utility. We present a generic technique, which allows to obtain upper bounds on the efficiency loss. For special cases, such as linear and concave utility functions, and non-concave utility functions with bounded domain, we explicitly calculate such upper bounds. Then, we study utility fair resource allocations with respect to bandwidth fairness. We derive a fairness metric assessing the aggressiveness of utility functions. This allows us to design fair utility functions for various applications. Finally, we simulate the proposed algorithms using the NS2 simulator.