The only rule is that you must have 730 days in Canada in your first 5 years as a PR counting from the day you landed in Canada and after you have been a PR for more than 5 years, you need 730 days in any rolling 5 year period.
730 days = 2 years and therefore you are allowed up to 3 years outside Canada at a time. However, if you spend 3 years outside Canada in one go, you will then have to come back and stay in Canada for 2 years straight to make up.