-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
2414 lines (1709 loc) · 97.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.3.0">
<link rel="apple-touch-icon" sizes="180x180" href="/favicon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon.png">
<link rel="mask-icon" href="/favicon.png" color="#222">
<meta name="baidu-site-verification" content="qxFtDn0ziX">
<meta name="sogou_site_verification" content="Wj1N74IImQ" />
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Consolas:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">
<script id="hexo-configurations">
var NexT = window.NexT || {};
var CONFIG = {"hostname":"nullwy.me","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
</script>
<meta property="og:type" content="website">
<meta property="og:title" content="nullwy's blog">
<meta property="og:url" content="https://nullwy.me/index.html">
<meta property="og:site_name" content="nullwy's blog">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="nullwy">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://nullwy.me/">
<script id="page-configurations">
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome : true,
isPost : false,
lang : 'zh-CN'
};
</script>
<title>nullwy's blog</title>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Y4LE29KVMN"></script>
<script>
if (CONFIG.hostname === location.hostname) {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-Y4LE29KVMN');
}
</script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?928b3d50428cc362a2d2ed846517583e";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<noscript>
<style>
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-header { opacity: initial; }
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
</style>
</noscript>
<!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/style.css">
<!-- hexo injector head_end end --><link rel="alternate" href="/atom.xml" title="nullwy's blog" type="application/atom+xml">
</head>
<body itemscope itemtype="http://schema.org/WebPage">
<div class="container use-motion">
<div class="headband"></div>
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<h1 class="site-title">nullwy's blog</h1>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger">
<i class="fa fa-search fa-fw fa-lg"></i>
</div>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="main-menu menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>
</li>
<li class="menu-item menu-item-about">
<a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>
</li>
<li class="menu-item menu-item-search">
<a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
</a>
</li>
</ul>
</nav>
<div class="search-pop-overlay">
<div class="popup search-popup">
<div class="search-header">
<span class="search-icon">
<i class="fa fa-search"></i>
</span>
<div class="search-input-container">
<input autocomplete="off" autocapitalize="off"
placeholder="搜索..." spellcheck="false"
type="search" class="search-input">
</div>
<span class="popup-btn-close">
<i class="fa fa-times-circle"></i>
</span>
</div>
<div id="search-result">
<div id="no-result">
<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
</div>
</div>
</div>
</div>
</div>
</header>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
<main class="main">
<div class="main-inner">
<div class="content-wrap">
<div class="content index posts-expand">
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://nullwy.me/2024/02/java-synchronization-implementation/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://static.nullwy.me/avatar.png">
<meta itemprop="name" content="nullwy">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="nullwy's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/02/java-synchronization-implementation/" class="post-title-link" itemprop="url">Java 线程同步实现原理深度解析</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-02-10 15:58:00" itemprop="dateCreated datePublished" datetime="2024-02-10T15:58:00+08:00">2024-02-10</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
</span>
</span>
<span class="post-meta-item">
<i class="far fa-comment"></i>
<a title="disqus" href="/2024/02/java-synchronization-implementation/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2024/02/java-synchronization-implementation/" itemprop="commentCount"></span>
</a>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>31k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>28 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>本文内容主要是,以官方文档资料和 Java 8 的 JDK 和 HotSpot 源码为依据,对 Java 的基于 <code>synchronized</code> 和 <code>ReentrantLock</code> 线程同步的底层实现原理进行总结梳理和深度解析。同时,也在广度上对线程同步相关的基础概念做总结概括。</p>
<h1 id="基础概念">基础概念</h1>
<p>在并发编程模型中,需要处理的两个最关键的问题就是<strong>通信</strong>(communication)和<strong>同步</strong>(synchronization)<sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup>。通信指线程可用于获得其他线程产生的信息的各种机制。通信机制通常都基于<strong>共享内存</strong>(<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Shared_memory">shared memory</a>)或<strong>消息传递</strong>(<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Message_passing">message passing</a>)。在共享内存的编程模型中,某些或全部程序变量可以由多个线程访问。如果一对线程之间需要通信,只要一个线程将值写入某个变量,另一线程来读它即可。在消息传递编程模型中,不同线程没有公共的状态。当一对线程之间需要通信时,其中的一个必须执行一次明确的 send 操作,将数据传送给另一个线程。</p>
<p><strong>同步</strong><sup class="footnote-ref"><a href="#fn1" id="fnref1:1">[1:1]</a></sup>是控制不同线程之间操作发生的相对顺序的各种机制,用以排除导致不正确结果的交错。消息传递模型中的同步通常是隐式的,消息的发送必须在接收之前。如果某个线程企图接收一个尚未发送的消息,那么它就必须等到发送方赶上来。在共享内存编程模型中,同步通常不是隐式的,除非我们做了某些特殊的事情,否则“接收方”就可能在某个变量被“发送方”修改之前读到其中的“老”值。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2024/02/java-synchronization-implementation/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://nullwy.me/2024/01/rocketmq-kafka-sharding-replication/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://static.nullwy.me/avatar.png">
<meta itemprop="name" content="nullwy">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="nullwy's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/01/rocketmq-kafka-sharding-replication/" class="post-title-link" itemprop="url">RocketMQ 和 Kafka 的数据分片和复制策略</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-01-18 20:36:00" itemprop="dateCreated datePublished" datetime="2024-01-18T20:36:00+08:00">2024-01-18</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%9E%B6%E6%9E%84/" itemprop="url" rel="index"><span itemprop="name">架构</span></a>
</span>
</span>
<span class="post-meta-item">
<i class="far fa-comment"></i>
<a title="disqus" href="/2024/01/rocketmq-kafka-sharding-replication/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2024/01/rocketmq-kafka-sharding-replication/" itemprop="commentCount"></span>
</a>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>10k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>9 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>为了提升系统的<strong>可扩展性</strong>(scalability),分布式数据库或分布式存储系统通常支持数据<strong>分区</strong>(partitioning)或<strong>分片</strong>(sharding),即将完整的数据拆分存放在多个服务器节点上,拆分后的部分数据称为“partition”或“<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Shard_%28database_architecture%29">shard</a>”。数据被拆分后多个服务器节点能分摊负载压力,从而提升系统性能。“分区”和分片”,这两个术语,在很多情况下不区分,可以混用。如果严格区分的话,<strong>分片</strong>拆分的数据分布在多个服务器节点上,而<strong>分区</strong>拆分的数据在单个服务器节点。另外,<strong>复制</strong>(<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Replication_%28computing%29">replication</a>)也典型的分布式技术,多个数据副本能实现读请求的负载均衡,提升系统性能。同时复制也提供了冗余容错的能力,提升系统的<strong>可用性</strong>(availability)。本文关注消息中间件的消息存储系统,解析并对比 RocketMQ 和 Kafka 的消息数据的分片和复制的具体实现策略。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2024/01/rocketmq-kafka-sharding-replication/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://nullwy.me/2023/12/website-scalability-reliability-resilience/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://static.nullwy.me/avatar.png">
<meta itemprop="name" content="nullwy">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="nullwy's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/12/website-scalability-reliability-resilience/" class="post-title-link" itemprop="url">大型网站的稳定性、可靠性和韧性</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2023-12-25 10:36:00" itemprop="dateCreated datePublished" datetime="2023-12-25T10:36:00+08:00">2023-12-25</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%9E%B6%E6%9E%84/" itemprop="url" rel="index"><span itemprop="name">架构</span></a>
</span>
</span>
<span class="post-meta-item">
<i class="far fa-comment"></i>
<a title="disqus" href="/2023/12/website-scalability-reliability-resilience/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2023/12/website-scalability-reliability-resilience/" itemprop="commentCount"></span>
</a>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>14k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>12 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>为了应对负载的增长,提升系统性能,目前大型网站普遍都是分布式架构,采用微服务架构风格。分布式系统的最重要的架构特性是<strong>伸缩性</strong>(scalability),伸缩性的系统具备应对增长的工作负载的能力。关于性能和伸缩性,可以参阅笔者的文章《<a href="https://nullwy.me/2023/12/website-performance-scalability/">大型网站的性能和可伸缩性</a>》。相对于采用单体架构的系统,分布式系统中有大量的服务器及设备,各服务之间存在错综复杂的依赖关系,存在更多的不确定性。整个系统的故障率会随服务节点的增加而呈指数级增加,单一节点问题可能会被无限放大,日常运行过程中一定会伴随故障发生。所以构建分布式系统需要关注的另外一个重要架构特性是<strong>稳定性</strong>(stability)。有关减少系统故障以及快速从故障中恢复的工程实践,国内通常称为“稳定性建设”,而国外类似的工程实践更多称为“站点可靠性工程”(SRE, <a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Site_reliability_engineering">Site reliability engineering</a>)。稳定性(stability)、可靠性(reliability)、韧性(resilience)、可用性(availability)等架构特性,相似并且相关,虽然严格区分的话,含义并不相同,但是很多时候在探讨这些架构特性时往往涵盖的是类似的内容。本文的内容主要是总结稳定性、可靠性、韧性这些架构特性的内涵,以及如何建设分布式系统的这些特性。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2023/12/website-scalability-reliability-resilience/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://nullwy.me/2023/12/website-performance-scalability/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://static.nullwy.me/avatar.png">
<meta itemprop="name" content="nullwy">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="nullwy's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/12/website-performance-scalability/" class="post-title-link" itemprop="url">大型网站的性能和可伸缩性</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2023-12-08 21:08:00" itemprop="dateCreated datePublished" datetime="2023-12-08T21:08:00+08:00">2023-12-08</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%9E%B6%E6%9E%84/" itemprop="url" rel="index"><span itemprop="name">架构</span></a>
</span>
</span>
<span class="post-meta-item">
<i class="far fa-comment"></i>
<a title="disqus" href="/2023/12/website-performance-scalability/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2023/12/website-performance-scalability/" itemprop="commentCount"></span>
</a>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>12k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>11 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>互联网网站在初期用户量和访问量一般都很小,往往只需要采用最简单的技术架构就能对外提供稳定服务。最简单的架构通常采用的是单机应用服务器、单机数据库服务器这样的单体架构。成功的互联网网站,比如电商平台,流量、用户量、交易量等核心指标是呈指数增长的,所以就需要提升网站系统的性能,来应对更大的负载。通过向系统中增加资源来提升系统性能的能力,被称为可伸缩性(<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Scalability">scalability</a>)。为了提升系统的可伸缩性,典型的大型网站,比如 eBay、Amazon 和淘宝等,几乎都经历过从单体架构向分布式架构演进的过程。本文主要关注大型网站或 Web 服务这类系统,解释系统的性能和可伸缩性相关的核心概念,并介绍系统的性能指标、系统的扩展策略和分布式架构风格,同时也总结分析典型大型网站的可扩展性架构演进案例,案例包括 eBay、Amazon、淘宝等。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2023/12/website-performance-scalability/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://nullwy.me/2023/12/popular-websites-tech-stack/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://static.nullwy.me/avatar.png">
<meta itemprop="name" content="nullwy">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="nullwy's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/12/popular-websites-tech-stack/" class="post-title-link" itemprop="url">流行互联网网站技术栈整理(万字长文)</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2023-12-03 23:37:00" itemprop="dateCreated datePublished" datetime="2023-12-03T23:37:00+08:00">2023-12-03</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%9E%B6%E6%9E%84/" itemprop="url" rel="index"><span itemprop="name">架构</span></a>
</span>
</span>
<span class="post-meta-item">
<i class="far fa-comment"></i>
<a title="disqus" href="/2023/12/popular-websites-tech-stack/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2023/12/popular-websites-tech-stack/" itemprop="commentCount"></span>
</a>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>35k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>32 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>本文整理总结主要的流行互联网网站技术栈,以及这些网站的技术栈和架构的历史演进过程。涉及的网站大部分都是当前或曾经访问量或月活用户量 Top 的网站(参见 Similarweb 网站的统计<sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup>,或访问量 Top 10 网站的历史演变<sup class="footnote-ref"><a href="#fn2" id="fnref2">[2]</a></sup>,或 wiki 整理的至少 1 亿月活用户量的社交平台<sup class="footnote-ref"><a href="#fn3" id="fnref3">[3]</a></sup>)。国内网站或 APP 涵盖了主流<sup class="footnote-ref"><a href="#fn4" id="fnref4">[4]</a></sup>的阿里、腾讯、百度、美团、字节、京东等大厂的互联网产品。整理的技术栈主要是流行网站的服务端业务系统的技术栈,包括编程语言、数据库、RPC 框架等,同时也简单整理了大数据技术栈,前端和客户端技术栈等不涉及。除了对大部分流行网站的技术栈做系统性梳理外,本文还挑选部分有代表性的网站,对这些网站的技术栈和架构的历史演进做详细解析。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2023/12/popular-websites-tech-stack/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://nullwy.me/2023/11/amazon-architecture-evolution/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://static.nullwy.me/avatar.png">
<meta itemprop="name" content="nullwy">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="nullwy's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/11/amazon-architecture-evolution/" class="post-title-link" itemprop="url">亚马逊网站架构演进</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2023-11-20 12:45:00" itemprop="dateCreated datePublished" datetime="2023-11-20T12:45:00+08:00">2023-11-20</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%9E%B6%E6%9E%84/" itemprop="url" rel="index"><span itemprop="name">架构</span></a>
</span>
</span>
<span class="post-meta-item">
<i class="far fa-comment"></i>
<a title="disqus" href="/2023/11/amazon-architecture-evolution/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2023/11/amazon-architecture-evolution/" itemprop="commentCount"></span>
</a>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>6.3k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>6 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="SOA-与微服务">SOA 与微服务</h1>
<p>Amazon,1994 年创立,早期网站是单服务、单数据库的单体架构的系统<sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup><sup class="footnote-ref"><a href="#fn2" id="fnref2">[2]</a></sup><sup class="footnote-ref"><a href="#fn3" id="fnref3">[3]</a></sup>,全部代码由 C++ 编写,编译成单个二进制文件,整个代码仓库被命名为 <a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Obidos_(software)">Obidos</a>。Obidos 是底层是一个 Web 页面渲染引擎,是一个框架,业务逻辑基于这个框架开发,Obidos 渲染引擎和业务逻辑共同组成整个代码仓库。随着时间的推移,Obidos 变得越来越复杂,编译 Obidos 整个代码库耗时 12 小时,开发调试效率低下<sup class="footnote-ref"><a href="#fn2" id="fnref2:1">[2:1]</a></sup>。另外,全部业务逻辑在单个二进制文件中,导致紧耦合,新功能特性无法快速发布上线。1995 年,Amazon 网站的技术架构,如下图所示<sup class="footnote-ref"><a href="#fn3" id="fnref3:1">[3:1]</a></sup>:</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2023/11/amazon-architecture-evolution/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://nullwy.me/2023/10/reliability-engineering/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://static.nullwy.me/avatar.png">
<meta itemprop="name" content="nullwy">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="nullwy's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/10/reliability-engineering/" class="post-title-link" itemprop="url">可靠性工程概述</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2023-10-19 12:43:00" itemprop="dateCreated datePublished" datetime="2023-10-19T12:43:00+08:00">2023-10-19</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%9E%B6%E6%9E%84/" itemprop="url" rel="index"><span itemprop="name">架构</span></a>
</span>
</span>
<span class="post-meta-item">
<i class="far fa-comment"></i>
<a title="disqus" href="/2023/10/reliability-engineering/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2023/10/reliability-engineering/" itemprop="commentCount"></span>
</a>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>17k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>16 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>为了应对负载的增长,目前大型网站普遍都采用分布式架构。相对于采用单体架构的系统,分布式系统中有大量的服务器及设备,各模块之间存在错综复杂的依赖关系,存在更多的不确定性。整个系统的故障率会随设备的增加而呈指数级增加,单一节点问题可能会被无限放大,日常运行过程中一定会伴随故障发生。所以,可靠性开始成为大型网站关注的最重要的质量属性之一,并因此发展出了站点可靠性工程(<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Site_reliability_engineering">Site reliability engineering</a>,SRE)。站点可靠性工程,是从可靠性工程发展而来的,从可靠性工程中借鉴了概念和成果。本文溯本求源,内容主要是总结概括,可靠性工程的历史演进和核心概念,软件可靠性工程的核心概念,以及可靠性设计的方法。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2023/10/reliability-engineering/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://nullwy.me/2023/07/io-multiplexing-network-server/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://static.nullwy.me/avatar.png">
<meta itemprop="name" content="nullwy">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="nullwy's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/07/io-multiplexing-network-server/" class="post-title-link" itemprop="url">I/O 多路复用与网络服务器并发策略</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2023-07-26 00:44:00" itemprop="dateCreated datePublished" datetime="2023-07-26T00:44:00+08:00">2023-07-26</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%9E%B6%E6%9E%84/" itemprop="url" rel="index"><span itemprop="name">架构</span></a>
</span>
</span>
<span class="post-meta-item">
<i class="far fa-comment"></i>
<a title="disqus" href="/2023/07/io-multiplexing-network-server/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2023/07/io-multiplexing-network-server/" itemprop="commentCount"></span>
</a>
</span>
<br>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>19k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>17 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>目前主流的网络服务器,网络 I/O 相关的底层最核心的技术都是 I/O 多路复用(I/O Multiplexing),比如 Apache HTTP Server、Nginx、Redis 等。本文尝试解释各种 I/O 模型,包括解释什么是 I/O 多路复用,同时也总结 I/O 多路复用底层的系统调用 select、poll、kqueue 和 epoll 的演进和区别,并编写了使用这些函数的示例代码。另外,本文还总结了各种基于 I/O 多路复用实现的网络服务器的并发策略的三种模式,包括对 Apache HTTP Server、Nginx 和 Redis 等网络服务器的并发策略的具体案例的解析。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2023/07/io-multiplexing-network-server/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://nullwy.me/2023/07/innodb-locking/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://static.nullwy.me/avatar.png">