Hello,
The cic website clearly states that you can apply as soon as you get your letter of acceptance it would be good to do so. If you are going through an agent then they might suggest you the best. I applied 8 months prior to my semester start date and got my visa.
Regards,
Khaja.