duanan5940 2017-08-02 23:27
浏览 25
已采纳

网站内容和成员数据库ID [关闭]

Why are some websites programmed to start member ids at 1 where as some websites start off the member ids like 30000000000000000 or even a random hash?

For example, popular forum software such as vbulletin, invision power board, xenforo, etc have their members ids starting at 1. Then you look at steam for example, take a look at a profile and look at that huge member id.

I've also noticed that some websites use uuids for basically member ids. Like mojang (yes, I know stay with me). They later on added a UUID to each account.

What are the benefits of each one? Wouldn't starting at the id of 1 use less database storage?

  • 写回答

1条回答 默认 最新

  • douliandan7340 2017-08-02 23:51
    关注
    1. Steam IDs are from 0x0110000100000001 to 0x01100001FFFFFFFF, always 17 digits long.

      It is a steam64, also there are steam2, steam3 and steam32 versions made in different times. It includes more data than just serial number, like "the universe" number it belongs. Also my guess is that it may include region, country and other additional data.

      On top of Steam ID there are Account ID, Community ID and others which are also different in length - that fact only confirms that length is chosen on purpose.

    2. For ordinary software like forums and web-sites there is usually no need to do such complicated IDs and for optimization and simplicity ordinary incrementing serial number is used.

    3. But sometimes UUID and other tricky hashes or huge random numbers are to be used. For example such approach will help to avoid stealing users list by crawling from 1 to N (where N is latest registered user's ID) or allow to avoid a time/ID-incremental atacks based on knowledge which ID will be next.

    4. Other reason why huge random numbers may be used is by their magic property to be evenly distributed between MIN and MAX values. It may help to mathematically arrange them between N servers with ServerNumber=ID/((MAX-MIN)/NumberOfServers) formula without any additional effort.

    5. And one more case to think about is situation where there are more than one server may create a new user: if ID will be simply incremental the possibility that two servers will try to create user with same ID (current ID+1) is a real thing. But when you have random ID or UUID/GUID your chance to collide are going to zero.

    So, yes, 1++ IDs are most convenient to work for, but there are also many cases where other approaches will have huge benefit for your software.

    I hope you enjoyed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了