If it's your first step (no steps you have done before) then it's advisable to apply at least six months before you intended eligibility period.
For example if you are planning to have an eligibility period in October-November-December then it's recommended you start your application in April.
Sometimes delays in the application might pop specially in regard to your medical education credentials and ECFMG-school correspondence. So you have to finish this headache as early as you can.
Note that ECFMG will not send you a scheduling permit if you apply more than six months before your intended eligibility period. So in our example above if you apply in February, they'll process your online application but they'll will not send you a scheduling permit.
Another advantage of early application is that you will get more serious and enter the exam mode once your application is ready and you "money" is paid. Many students did not study seriously before their application approved.