you should apply about 3 months in advance, so you don't have lapses. USCIS says you can appy as early as 6 months in advance, but I believe that shortens your EAD eligibility period, since the new EAD might be valid from the date long before your old one expires.