Essentially in primary drying you are removing water from the ice crystals via sublimation. During secondary drying you are (trying to) remove the more closely bound water molecules, things that stick to your active or excipiants. There are many factors affecting the time of each stage, the formulation (cryoprotectants which are frequently sugars love to hold on to water), and the freeze drying methodolgy employed (freezing process which controls ice crystal size, pressure, shelf temperature). I cannot under emphasise how critical the freezing process is to achieving a good result. Typically where one makes adjustment to increase speed of drying in one stage, it can, if not controlled well, create issues in another stage of drying.
There is a good Basic introduction to Freeze Drying paper available here (albeit you will have to register to access it):
Secondary drying in some applications can be very important. As Rob mentioned, the water that remain after primary drying is still there and can cause serious problems for example during enzyme and cells storage, especially at room temperatures.
I imagine the question refers to primary and secondary drying as others have surmised.
can I also assume that your drug is a bio pharmaceutical? That is protein-based? I also assume that your container is a vial and not a syringe or spray-drying. I also assume you are not performing bulk freeze drying. So my answer contains those contingencies.
i think the differences have been explained, sublimation and desorption. The best cycle must be empirically derived, but the best place to start is to look at patents involving similar drugs. This will save you time.. Then there is that old trial and error, that applied science loves. For this, Use the buffer so you don't waste product. You will need several accessories. Minimally these would be product temperature probes(Tempris, for example) and a pirani gauge. Make sure the pirani does not control the vacuum, use an MKS or something like that. The difference between MKS pressure and calibrated pirani pressure shows the profile of water removal in primary drying. Read up on it. Freeze drying is pressure, temperature and time. Many large scale manufacturing lyophilizers do not incorporate pirani gauges. This is a mistake! Quality by design and continual process improvements on that basis will save you company tons of money, and will not require resubmission of a product following a design change (just an aside...)
secondary drying determination is more difficult to assess and depends on how dry you product needs to be to fulfill stability specs. There are many ways to do this available, removing a vial (theiving) is one way. Residual water is typically measured destructively (Karl Fischer), however I prefer NIR since it is cheap and faster. NIR can also be used in QC to test all the vials in a batch. As mentioned above a target of 0.5% water (w/w) is a good place to start. Secondary drying is accelerated by raising the heat. This can be done in a stepwise fashion up to 50°C depending on the melting point of you excipients. Given the right vials and stoppers, this will allow for room temperature storage. In a previous job, I stabilized enzymes for 60°C storage. Yes, DOD work for desert warfare, not my favorite employment of my skills, but it paid well.
So, timing: again, trial and error. Just pay attention to the data, and stability studies. While at Baxter we developed methods for drying 5 ML in about 45 minutes. Primary and secondary drying were combined. Any cycle must have cost effectiveness, which can be a balancing act. Be sure to keep in contact with the accountants!
There you go. Now go and learn all about it by reading, say stuff by Mike Pikal, or Steve Nail, or any others. Talk to the experts! Get technicians in to help. Don't be afraid to make mistakes! Then there are always the CRO's that will do all of this for you for a price. I have enjoyed working with LTI in the past. Bio-harms Solutions is good too. I may be biased here since I used to work with them while I was at Baxter.