---
title: "Discussion on \"How Twitter generates millions of  unique ids per second?\" | Hashnode"
description: "Discussion on \"How Twitter generates millions of  unique ids per second?\". A note on system design of generating unique ids per second."
url: "https://hashnode.com/posts/how-twitter-generates-millions-of-unique-ids-per-second/61fc9eb18d15cb3e7ce5fd4e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How Twitter generates millions of unique ids per second?](https://blog.sagarmoy.work/how-twitter-generates-millions-of-unique-ids-per-second?utm_source=hashnode&utm_medium=feed)

A note on system design of generating unique ids per second.

Feb 4, 2022 · 5 min read · blog.sagarmoy.work  
Read the article

-   [#distributed-system](https://hashnode.com/tag/distributed-system)
-   [#system-architecture](https://hashnode.com/tag/system-architecture)

## Written by

[Sagar](https://hashnode.com/@sagars01)

@sagars01 · Bengaluru

  
[View profile](https://hashnode.com/@sagars01)

Staff Software Engineer with 10 years of building, breaking and gliding in the tech world

Staff Software Engineer experienced in building highly scalable software. Currently on mission to help frontend engineers move into fullstack engineering roles

## Responses 1

Markdown supported · ⌘↵ to post

[Miki Szeles](https://hashnode.com/@mszeles)

[Feb 4, 2022](https://hashnode.com/posts/how-twitter-generates-millions-of-unique-ids-per-second/61fc9eb18d15cb3e7ce5fd4e/comment/61fcac0efd8b083e57289c7e)

Interesting insights Sagar. Thanks. I am not an expert on the topic, so my question might be stupid: Why do we need a sortable id? Why don't we simply sort based on the creation timestamp?

[Sagar](https://hashnode.com/@sagars01)

[Feb 4, 2022](https://hashnode.com/posts/how-twitter-generates-millions-of-unique-ids-per-second/61fc9eb18d15cb3e7ce5fd4e/comment/61fcac0efd8b083e57289c7e#reply-61fd6069fd8b083e5728b241)

Hello Miklós, Thank you for your kind words, means a lot to me.

Now to answer your question in short.

Sortable UID are far more more easier to sort and you can set your index based on the uid’s timestamp.

Though you’re correct that we can store the timestamp in a tuple and sort based on it, but running that query will be a costly operation.

[Miki Szeles](https://hashnode.com/@mszeles)

[Feb 4, 2022](https://hashnode.com/posts/how-twitter-generates-millions-of-unique-ids-per-second/61fc9eb18d15cb3e7ce5fd4e/comment/61fcac0efd8b083e57289c7e#reply-61fd70c48d15cb3e7ce61813)

Thanks for the answer [Sagar Sengupta](https://hashnode.com/@compscieasy)
