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 4325458
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:16:09+00:00 2026-05-21T09:16:09+00:00

Previously I was using the class found here to convert userID to some random

  • 0

Previously I was using the class found here to convert userID to some random string.

From his blog:

Running:

alphaID(9007199254740989);

will return ‘PpQXn7COf’ and:

alphaID('PpQXn7COf', true);

will return ‘9007199254740989’

So the idea was that users could do http://www.mysite.com/user/PpQXn7COf and i convert that to a normal integer so i could do in mysql

"Select * from Users where userID=".alphaID('PpQXn7COf', true)

Now i’m just started working with Cassandra an i’m looking for some replacement.

  1. I want url like http://www.mysite.com/user/PpQXn7COf not like http://www.mysite.com/user/username1
  2. The “PpQXn7COf” uuid must be as short as possible.

In the Twissandra example explained here: http://www.rackspace.com/cloud/blog/2010/05/12/cassandra-by-example/

They create some long uuid (i guess it is so long because then its almost 100 percent sure its random).

In mysql i just had a userID column with auto increasement so when i used the alphaID() function i always got a very short random string.

Anyone an idea how to solve this as clean as possible?


Edit:

It is used for a social media site so it must be persistent.
Thats also why i don’t want to use usernames/realnames in urls, user cant remain google undetected if they need.

I just got a simple idea, however i don’t know how scalable it is

<?php
//createUUID() makes +- 14 char string with A-Z a-z 1-0 based on micro/milli/nanoseconds
while(get_count(createUUID()) > 0){//uuid  is unique
  //insert username pass, uuid etc into cassandra
  if($result == "1"){
      header('Location: http://www.mysite.com/usercenter');
  }else{
      echo "error";
  }
}
?>

When this gets the size of lets say twitter/facebook:

  1. Will it execute in acceptable time?
  2. Will it still generate unique uuid fast enough so if 10000 users/second are registering it isnt cluttering up?
  • 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-05-21T09:16:10+00:00Added an answer on May 21, 2026 at 9:16 am

    Auto-increments are not suitable for a robust distributed system. You can only assign a unique ID if every node in your system is available, to ensure it’s unique.

    You can of course, invent your own unique-id generator, but you must then ensure that it will generate unique IDs anywhere in your infrastructure.

    For example, each node can just have a file which it (with suitable locking etc) just increments, but you will also need to ensure that they don’t clash – for instance, by having the server ID included in the generation algorithm.

    This may be operationally nontrivial – your ops engineers will need to ensure that all the servers in the infrastructure are configured correctly with their own ID generators set up so that they don’t generate the same ID. However, it’s possible.

    UUIDs are the reasonable alternative, because they will definitely be unique.

    A UUID is 128 bits; if we store 6 bits per character (i.e. base64) then that takes 22 characters, which is quite a long URI. If you want it shorter, you will need to generate unique IDs a different way.

    Plus it all depends on “how unique” you actually need your IDs to be. If your IDs can safely be reused after a few months, you can probably do it in < 60 bits (depending also on the number of servers in your infrastructure, and how frequently you need to generate them).

    We use

    • Server ID
    • Time (granularity = 2 seconds), but wraps after a few months
    • A per-server counter (which wraps frequently, but not within 2 seconds)

    And stick all the bits together. This generates an ID which is < 64 bits long, but is guaranteed to be unique for the length of time it needs to be (which in our case is only a couple of months)


    Our algorithm will malfunction and generate a duplicate ID if:

    • The system clock on one of our nodes goes backwards by the same amount of time in which the counter wraps.
    • Our operations engineers make a mistake and assign the same server ID to two servers.
    • Eventually, after about 9 months.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Previously I have asked to strip text from a field and convert it to
Jeff has previously blogged about using the cache to perform "out of band" processing
Previously, I had a class that wrapped an internal System.Collections.Generic.List<Item> (where Item is a
I'm using .NET 2.0, and a recent code change has invalidated my previous Assert.AreEqual
On my previous machine I had IIS6 installed and created a web project using
Previously, I asked the question . The problem is the demands of our file
Previously I've asked about inserting a column into a dataset . I now have
I previously asked how to do this in Groovy. However, now I'm rewriting my
I previously asked about what Mixins were, and have begun to get the gist
I previously asked a question regarding MX records (and appreciate the thoughtful answers I

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.