This is probably the worst situation an author has to write, mostly because readers hate is that you kill off characters, but also because you become personally attached to your characters. Now, when I was younger, I thought that MCs couldn't die, but now that I've read more and have more experience with books, my faith has been shaken. Killing characters could mean one of two things: 1) There's an amazing fight scene and at least two people have to die and 2) It keeps the story going and helps the MC grow more into a character. I've killed off many characters (minor or main), and it was either really easy and I didn't think about it, or I cried for, like, two hours.
Character killing is not murder! But most readers do think it is so. Therefore I would steer clear of killing off characters if it is not necessary for the plot or main character. It can also cause your book to become boring because of lack of a character's personality or simply having an extra body for a character to rant to.
Now, for the 'How To' part. The effective way to kill off a character is to have immediate reaction from the surrounding characters. If this does not happen either you just forgot, or that death is not important to be in the plot (this happens so rarely I don't even think it's a thing). If you feel that the plot is becoming two boring, or if your writing a fight scene, throw in some D-E-A-T-H.
D- Description of how the death accrued.
E- Electrify a scene by having a dramatic response by characters.
A- An Action on how and when the death accrued during your story.
T- Trauma is a key element of death, loss and all over grief; make a character depressed if you have to.
H- Hell, make a compassionate character go completely wild after a death of another character, this builds up for a great plot and can cause amazing suspense for that character.
All in all, it can be tough to kill of a character, especially if s/he is a main character or a minor main character. Happy killing!
this is where i ramble; have fun