File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 1+ ### UUID
2+ 优:
3+
4+ 1 . 本地生成没有了网络之类的消耗,效率非常高
5+
6+ 缺:
7+
8+ 1 . 不易于存储:UUID太长,16字节128位,通常以36长度的字符串表示,很多场景不适用。
9+ 2 . 信息不安全:基于MAC地址生成UUID的算法可能会造成MAC地址泄露,这个漏洞曾被用于寻找梅丽莎病毒的制作者位置。
10+
11+ ### snowflake
12+ 这种方案把64-bit分别划分成多段(机器、时间)
13+
14+ 优:
15+
16+ 1 . 毫秒数在高位,自增序列在低位,整个ID都是趋势递增的
17+ 2 . 本地生成没有了网络之类的消耗,效率非常高
18+ 3 . 可以根据自身业务特性分配bit位,非常灵活。
19+
20+ 缺:
21+
22+ 1 . 强依赖机器时钟,如果机器上时钟回拨,会导致发号重复或者服务会处于不可用状态
23+
24+ ### 数据库
25+ 可以利用 MySQL 中的自增属性 auto_increment 来生成全局唯一 ID,也能保证趋势递增。 但这种方式太依赖 DB,如果数据库挂了那就非常容易出问题。
26+
27+ 优:
28+
29+ 1 . 非常简单,利用现有数据库系统的功能实现,成本小,有DBA专业维护。
30+ 2 . ID号单调自增,可以实现一些对ID有特殊要求的业务。
31+
32+ 缺:
33+
34+ 1 . 强依赖DB,当DB异常时整个系统不可用,属于致命问题。配置主从复制可以尽可能的增加可用性,但是数据一致性在特殊情况下难以保证。主从切换时的不一致可能会导致重复发号。
35+ 2 . ID发号性能瓶颈限制在单台MySQL的读写性能。
36+
37+ 参考:
38+ https://tech.meituan.com/MT_Leaf.html
39+ https://github.com/crossoverJie/Java-Interview/blob/master/MD/ID-generator.md
Original file line number Diff line number Diff line change 1+ 搜索引擎是因为个人项目关系,那个搜索引擎非常简单,但有很多东西可以问到,可选择性学习借鉴,了解到对项目是如何提问的,还有问题的深度
12
23![ ] ( https://github.com/xbox1994/2018-Java-Interview/raw/master/images/j10.png )
34
Original file line number Diff line number Diff line change @@ -30,13 +30,12 @@ PS:除开知识点,一定要准备好以下内容:
3030* [ 消息队列] ( https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/分布式-消息队列.md )
3131* [ 存储] ( https://blog.csdn.net/prettyeva/article/details/60146668 )
3232* [ 限流] ( https://crossoverjie.top/2018/04/28/sbc/sbc7-Distributed-Limit )
33- * [ ID生成方式] ( https://github.com/crossoverJie/ Java-Interview/blob/master/MD/ID-generator .md )
33+ * [ ID生成方式] ( https://github.com/xbox1994/2018- Java-Interview/blob/master/MD/ID生成方式 .md )
3434* [ 高并发场景解决思路] ( http://www.wangtianyi.top/blog/2018/05/11/javaduo-xian-cheng-yu-gao-bing-fa-liu-gao-bing-fa-jie-jue-si-lu/ )
3535### [ 在线编程] ( https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/在线编程.md )
3636### [ Linux] ( https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/Linux.md )
3737----------------
3838### [ 搜索引擎] ( https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/搜索引擎.md )
39- 搜索引擎是因为个人项目关系,那个搜索引擎非常简单,但有很多东西可以问到,可选择性学习借鉴,了解到对项目是如何提问的,还有问题的深度
4039### [ 秒杀架构] ( https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/秒杀架构.md )
4140### [ 问题排查] ( https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/问题排查.md )
4241### [ 从按下回车开始,到浏览器呈现出网页之间的发生了什么] ( http://www.wangtianyi.top/blog/2017/10/22/cong-urlkai-shi-,ding-wei-shi-jie/ )
You can’t perform that action at this time.
0 commit comments