Students in my classes sit with their groups at tables every day in class. I change the groups after every two units, every 6-7 weeks or so. I use a pretty elaborate process to organize who works with whom, but sometimes random groups are faster and feel more fair to students. This allows for random grouping, based on content taught in a course.
For groups of four, find four related concepts that pertain to your content. The math example was the equation of a line, the graph of that line, the T-chart of some x and y values for the line, and a situation that the line could describe. Create as many of those corresponding examples as you want groups. For chemistry, I used a chemical formula for a compound, the molar mass of that compound, the percent composition of the compound, and a picture that represented it. Here is a screenshot of the one I created today:
Cut the above into horizontal strips and then each strip represents a group. Then cut the strip into 4 segments. As students enter the room, ask each student to choose a segment from a basket. Then they have to find the other members of their groups by applying what they have learned in class. If you want to use my version, you can access it here.
There could be many variations of this for other disciplines. I like a vocabulary option where you have a word, its definition, a picture to represent it, and a synonym or antonym. That would be a great way to revisit and practice key vocabulary words throughout a year. The possibilities are endless! Don't like the idea of random groups? You could write student names on each segment and then they still have the experience of finding their group members and practice the content but end up in a group you chose. I am looking forward to trying this the next time I change groups!