Pick the right person.
Asking the right instructor, mentor, boss, or coach who knows you well and can speak to your character on a personal level, is the key to getting the best letter possible. Just because you got a good grade in their class doesn't necessarily make them the right person. Choose the instructor who you go to for extra tutoring, the coach who stays after practice with you to help with your free throws, or the mentor who's seen your growth over the years.
Start by making a list of three to four people in order of priority and then ask them one at a time. Wait for their response before you ask the next person. Let's avoid awkward moments where you'll have to tell someone "never mind." If you sense hesitation, go with someone else. That hesitation may not have anything to do with you, but they just might not feel qualified to write a letter for you or they may simply be too busy at that moment.
Plan time to ask them in person first.
If you're able to, try to ask them in person first and then follow up with a formal, written email. Explain why you chose to ask them in particular and what you're asking for. Of course, if you won't see them for a while and want to make sure you give them enough time, asking via email is perfectly fine too.
Don't wait until the last minute.
Chances are your recommender has other projects they're working on and might even have other letters to write. Try to give them at least two weeks, so they can write the recommendation letter to end all recommendation letters. You want the Thanksgiving mac and cheese your grandma spent all day on, not the boxed stove top!