Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8835139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:11:30+00:00 2026-06-14T09:11:30+00:00

I am building my own sharding solution. Each ID is constructed as follows: shard

  • 0

I am building my own sharding solution. Each ID is constructed as follows:

  • shard id (small int)
  • table type id (small int)
  • incremental number (big int)

ex. 00001000010000000015

I use virtual shards, so I can point all the shards to a single server and when I need more capacity, I just add another server and point some of the virtual shards to that server, so next time the data will be written onto the new server and not the first one, although read will go to the two servers, at least until I move the data and change it in the config file.

My problem is with the incremental number. I want those to be unique. Using the build int incremental id in mysql for a specific table is not good, because I might move the data to another server, and there I might have another data that use the increment number of its table, so I might get duplicate IDs.

So my question is how can I generate a unique ID in a scalable fashion, without using an external table that will generate that ID, because it won’t scale. I can point you to how Pinterest has solved this here which might help. I thought about giving each table a incremental value that skips at different values for every shard, so they incremental values on all shards are never the same.

The idea is to build my own sharding solution with Amazon RDS, so replicas are already there, balancing is easy because I can take advantage of the promote slave to master and just delete data on both servers and change my sharding config file. I think it’s possible to build a solution that can easily scale using Amazon RDS and it will be MUCH cheaper than what other companies offer today (already did my homework on that).

I don’t want to use GUID in my URLs. I don’t mind using long numbers. Pinterest, Tumblr, Facebook and many others don’t use Guid, so I know that their is a solution out there, and just want to know which solution do you think works best, taking into consideration that I want to use numerical IDs. 

I’m developing my application in ASP.NET C#

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:11:31+00:00Added an answer on June 14, 2026 at 9:11 am

    In a nutshell, your approach to generate IDs is doomed: If you want to generate unique IDs, you need a central service which will eventually become a bottleneck.

    Also including the shard ID smells bad; what happens when you move data to a new shard? Will you have to update all the IDs?

    If you want a scalable solution, you will have to look at UUIDs or similar approaches.

    Alternatively, you could use a central service and allocate a block of IDs (say 10’000) per call. That way, you wouldn’t need to hammer the central service that often but if the service fails, the whole system will be dead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building my own sharding solution with ASP.NET C# and MySQL. For the
I'm building an Android app with OpenGL.I created 2 squares, each with their own
On the road of building my own game, I got a big error. I
I'm building my own C2DM application right now. I first started with a small
Recently I started building my own big Windows 8 Store App. Working on UI
I am currently building my own small scale Blog CMS with ASP MVC C#.
I am building my own home page. I find someone's page good, and downloaded
I am building my own torrent site and after doing some research I have
I am building my own local search UI element that gives local search suggestions
I'm currently building my own login script and have noticed that most append the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.