Implementing a Chat backend, what would be the best way to generate and retrieve room ids?

37 Views Asked by At

I wonder what are the pros and cons of the two approachs I am thinking about.

  • 1/ Create room_id by combining users UUID (unique 32 chars) orderered ASCII wise so it would become: 85f14807b0dc470fb42b9df53c55abfb87f14807b0dc470fb42b9df53c55zbfx where we have a new uuid each 32 chars (here it is a room with 2 users), it would however become increasingly long.
  • 2/ create room_id by combining users ID ordered from smallest int to bigger so it would be like: |1|3|7|9|13| for a room with 5 users having the respective ids, using a special characters to make it as a string.

I think the second approach (using sequential IDs) make more sense as it takes less space into the database than by using the UUID.

Still I think there should be a better way than the two solutions I have envisioned, so I am looking for advice from engineers who have implemented or tinkered with such backend.

0

There are 0 best solutions below