How would I go about writing a rant? Do I write it the way I talk? How long should it be? What's the purpose of a rant?
A rant is generally a form of diatribe—in other words, a composition in which the speaker engages in focused vituperation about some pet peeve. It is a genre typically found in stand up comedy. Unlike, for example, a passionate but serious speech condemning a deep social injustice, a rant usually concerns something annoying but ultimately trivial. Genocide or slavery would not be an appropriate subject for a rant, but people who are texting at checkout counters and holding up lines or sprawling across two seats in a crowded subway might be good topics.
You should never write the way you talk. Even a well-written speech designed for oral performance is far more concise, well-structured, and grammatical than everyday speech. Instead, you should aim for a tone that may be colloquial or conversational, but still conforms to the conventions of standard edited English.
There is no fixed length for the rant as a genre. It is usually assigned as a way for writers to develop fluency, and thus is relatively short (under 500 words), but the actual word count will be specified by your teacher; if you don't have a copy of the assignment, you should contact your teacher or a fellow student for details.