Professors get requests for LoRs regularly, it's part of their job, they're used to it. It's not like you're asking them to donate a kidney. Of course it does take them significant time and effort, if they're writing a good letter, and of course you should be polite and give them plenty of time and all the information they need, and leave them room to decline, and express your gratitude if they accept, and so on. Maybe send a sample of work you did in their class to jog their memory. But, while there are plenty of things you can do wrong, there's no secret key to making someone write a good letter for you. It depends if they were genuinely impressed with you, how much time you give them, how many other letters they've already agreed to write, what's going on in their personal lives right now -- some stuff you can control and some stuff you can't.