Usually a passport is renewed if it is within 6 months from its expiration. But as a special case, like going abroad, it can be considered.
You can renew it as early as you can.. Since you need the usual 6 months in it so that you can use it, typical people renew it within that month. But you can definitely renew earlier. =)