-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlecture8.html
More file actions
918 lines (858 loc) · 30.7 KB
/
lecture8.html
File metadata and controls
918 lines (858 loc) · 30.7 KB
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
<!DOCTYPE html>
<!--
Middleware and Web Services, CTU course slides
(cc) 2010-2023 Tomas Vitvar, http://vitvar.com
written for Humla, an open source HTML5 presentation environment
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="course" content="Middleware Architectures 1" />
<meta name="lecture" content="Lecture 8" />
<meta name="keywords" content="High Availability, Load Balancer, Replication" />
<link type="text/css" rel="stylesheet" href="css/meta.css">
</link>
<link type="text/css" rel="stylesheet" href="css/ctu-fit.css">
</link>
<link type="text/css" rel="stylesheet" href="humla/lib/core/humla.css">
</link>
<script type="text/javascript" src="humla/lib/humla.js"></script>
<title>High Availability and Performance</title>
</head>
<body>
<footer>
<p><b>#META_LECTURE#: #TITLE#</b>, <span class="meta_semester" />,
<span class="meta_twitter" />
</p>
<p><b>‒ #SLIDE_NO# ‒</b></p>
</footer>
<div class="slide intro">
<hgroup>
<h1><span class="meta_course" /></h1>
<h2>#META_LECTURE#: #TITLE#</h2>
</hgroup>
<div class="author">
<p class="meta_author" />
<p><span class="meta_email" /> • <span class="meta_twitter" /> •
<span class="meta_web" />
</p>
</div>
<center>
<div class="meta_logo"></div>
</center>
<div class="org">
<p class="meta_org" />
<p><span class="meta_orgfac" /> • <span class="meta_field" />
• <span class="meta_orgweb" /></p>
</div>
<div class="etc">
<div class="text-info">
Modified: #LAST_MODIFIED#<br />
Humla v#HUMLA_VERSION#
</div>
<a href="http://creativecommons.org/licenses/by-sa/3.0/">
<div class="license"></div>
</a>
<div class="oppa"></div>
</div>
</div>
<div class="slide">
<hgroup>
<h1>Good Performance</h1>
</hgroup>
<ul class="small">
<li>What influences good performance?</li>
<ul>
<li>Number of users and concurrent connections</li>
<li>Number of messages and messages' sizes</li>
<li>Number of services</li>
<li>Infrastructure – capacity, availability, configuration, ...</li>
</ul>
<li>How can we achieve good performance?</li>
<ul>
<li>Infrastructure</li>
<ul>
<li>Scalability, failover, cluster architectures</li>
</ul>
<li>Performance tuning</li>
<ul>
<li>Application Server, JVM memory, OS-level tuning, Work managers configuration</li>
</ul>
<li>Service configuration</li>
<ul>
<li>Parallel processing, process optimization</li>
</ul>
</ul>
</ul>
</div>
<div class="slide outline"></div>
<section>
<header>Definitions</header>
<div class="slide">
<hgroup>
<h1>Definitions</h1>
</hgroup>
<ul class="xx-small">
<li>Scalability</li>
<ul>
<li>server scalability</li>
<ul>
<li>ability of a system to scale – when input load changes</li>
<li>users should not feel a difference when more users
access the same application at the same time</li>
<li><b>horizontal scaling</b></li>
<ul>
<li>adding new instances of applications/servers</li>
</ul>
<li><b>vertical scaling</b></li>
<ul>
<li>adding new resources (CPU, memory) to a server instance</li>
</ul>
</ul>
<li>network traffic</li>
<ul>
<li>bandwidth capacity influences performance too</li>
<li>service should limit the network traffic through caching</li>
</ul>
</ul>
<li>Availability</li>
<ul>
<li>probability that a service is operational at a particular time</li>
<ul>
<li>e.g., 99.9987% availability – downtime ~44 seconds/year</li>
</ul>
</ul>
<li>SLA – Service Level Agreement</li>
<ul>
<li>Guarantee of service availability</li>
<li>When availability is below a guaranteed value, a customer can get a discount</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Definitions (Cont.)</h1>
</hgroup>
<ul class="x-small">
<li>High Availability</li>
<ul>
<li>When a server instance fails, operation of the application can continue</li>
<li>Failures should affect application availability and performance as little as possible</li>
</ul>
<li>Application Failover</li>
<ul>
<li>When an application component performing a job becomes unavailable,
a copy of the failed object finishes the job.</li>
<li>Issues</li>
<ul>
<li>A copy of the failed object must be available</li>
<li>A location and operational status of available objects must be available</li>
<li>A processing state must be replicated</li>
</ul>
</ul>
<li>Load Balancing</li>
<ul>
<li>Distribution of incoming requests across server instances</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>RED Metrics: Rate</h1>
</hgroup>
<ul class="xx-small">
<li>Rate: Requests per Second (RPS/QPS)</li>
<ul>
<li>How many requests the service handles</li>
<li>A core server-side throughput metric</li>
</ul>
<div class="h-drawing" style="height: 250px; margin-left: -200px"
id="1BhopVXexuS5coYLBbcrBi1SiUY3YNcr-K4usFXU6IwM"></div>
</ul>
<ul class="xx-small">
<li>High Rate implications</li>
<ul>
<li>Caching can dramatically improve throughput</li>
<li>Even frequently changing data benefits from short-TTL cache</li>
<li>Load balancing and autoscaling rely on Rate metrics</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>RED Metrics: Errors</h1>
</hgroup>
<ul class="x-small">
<li>Errors: Failed Requests</li>
<ul>
<li>Rate of requests that fail or return unexpected result</li>
<li>Includes: 4xx/5xx codes, timeouts, retries, broken dependencies</li>
</ul>
</ul>
<ul class="x-small">
<li>Why errors matter</li>
<ul>
<li>Service health is mostly determined by error spikes</li>
<li>Errors propagate upstream causing cascading failures</li>
</ul>
<li>Mitigation strategies</li>
<ul>
<li>Circuit breakers and retries</li>
<li>Graceful degradation</li>
<li>Better health checks & alerting</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>RED Metrics: Duration</h1>
</hgroup>
<ul class="xx-small">
<li>Duration (Response Time)</li>
<ul>
<li>How long each request takes</li>
<li>Measured from the client or service side</li>
</ul>
<div class="h-drawing" style="height: 200px; margin-left: -150px;"
id="1rgjQBi7cWEbNSjNYmnhaFTqcoXNi6JbLaGmNajArRUY"></div>
</ul>
<ul class="xx-small">
<li>High latency may indicate</li>
<ul>
<li>CPU-intensive service or inefficient algorithm</li>
<li>Bad configuration or resource limits</li>
<li>Slow downstream dependencies (DB, APIs)</li>
</ul>
</li>
<li>Mitigation strategies</li>
<ul>
<li>Use asynchronous / background processing</li>
<li>Optimize hot paths, reduce blocking calls</li>
</ul>
</li>
</ul>
</div>
</section>
<div class="slide outline"></div>
<section>
<header>Serving Requests</header>
<div class="slide">
<hgroup>
<h1>Blocking (Synchronous) I/O</h1>
</hgroup>
<div id="1QP7gZSS1WS3YquzLekSgdZfcmi4BYArm-K9tuWrULQs" class="h-drawing" style="height: 220px"></div>
<ul class="x-small">
<li>Inbound connection</li>
<ul>
<li>A server creates a thread for every inbound connection</li>
<li>For example, 1K connections = 1K threads, big overhead</li>
<li>A thread is reserved for the entire duration of the request processing</li>
</ul>
<li>Outbound connection</li>
<ul>
<li>A thread is blocked when outbound connection is made</li>
<li>When outbound connection is slow, the scalability is poor</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Non-Blocking (Asynchrnous) I/O</h1>
</hgroup>
<div id="1kxkFc3Chl4qFXxH_4f2seuNbpBdENMyZWMRUmxd1p28" class="h-drawing" style="height: 220px"></div>
<ul class="x-small">
<li>Inbound connections</li>
<ul>
<li>The connection is maintained by the OS, not the server app</li>
<li>The Web app registers events, OS triggers events when they occur</li>
<li>The app may create working threads and controls their number</li>
</ul>
<li>Outound connections</li>
<ul>
<li>The app registers a callback that is called when the data is available</li>
<li>Event loop</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Components</h1>
</hgroup>
<div class="h-drawing" id="19ZwXAQ2Ui4TzbuCtXDoT-1dW7ZsAqgGWdQwal0ZxPVQ"></div>
<ul class="xx-small">
<li><b>Muxer</b> – component that handles communication via network sockets.</li>
<li><b>Request queue</b> – queue of requests to be processed.</li>
<li><b>Self-tunning thread pool</b> – a pool of threads in various states.</li>
<li><b>Work manager</b> – a configuration of <b>maximum threads</b> and a <b>capacity</b> that
can be used to handle requests for a specific application/service.</b></li>
</ul>
</div>
<!-- <div class="slide">
<hgroup>
<h1>Java Virtual Threads</h1>
</hgroup>
<img src="img/virtual-threads-java.png" style="width: 750px; padding: 20px"></img>
<ul class="xx-small">
<li>Virtual threads mapped to a platform threads (carrier threads)</li>
<li>Blocking operations do not block carrier threads</li>
</ul>
</div> -->
</section>
<div class="slide outline"></div>
<section>
<header>Load Balancers</header>
<div class="slide">
<hgroup>
<h1>Load Balancing</h1>
</hgroup>
<ul class="small">
<li>Distributes a load to multiple app/object instances</li>
<ul>
<li>App instances run on different machines</li>
<li>Load sharing: equal or with preferences</li>
<li>Health checks</li>
</ul>
<li>Types</li>
<ul class="x-small">
<li>DNS-based load balancer</li>
<ul>
<li>DNS Round Robin</li>
</ul>
<li>NAT-based load balancer (Layer-4)</li>
<li><b>Reverse-proxy load balancer</b> (Layer-7)</li>
<ul>
<li>application layer</li>
<li>Sticky sessions</li>
<ul>
<li>JSession, JSession-aware load balancer</li>
</ul>
</ul>
<li>Client-side load balancer</li>
<ul>
<li>LB run by a client
<li>a client uses a replica-aware stub of the object
from the server</li>
</ul>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>DNS-based Load Balancer</h1>
</hgroup>
<ul class="x-small">
<li>DNS Round Robin</li>
<ul>
<li>A DNS record has multiple assigned IP addresses</li>
<li>DNS system delivers different IP addresses from the list</li>
<li>Example DNS A Record:<br />
<code>company.com A 147.32.100.71 147.32.100.72 147.32.100.73</code>
</li>
</ul>
<li>Advantages</li>
<ul>
<li>Very simple, easy to implement</li>
</ul>
<li>Disadvantages</li>
<ul>
<li>IP address in cache, could take hours to re-assign</li>
<li>No information about servers' loads and health</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Forward Proxy</h1>
</hgroup>
<div class="h-drawing" id="1zt7pfPYpd5cdHu92rimaRelwjKHkHeeA7AhHnrerI74" style="height: 270px"></div>
<ul class="xx-small">
<li>Forward Proxy</li>
<ul>
<li>Centralized access control based on content</li>
<li>The client knows about the site it wants to access</li>
<li>Perfoms request on behalf of the client</li>
<ul>
<li>Caches content to increase performance, limits network traffic</li>
<li>Filters requests or controls access based on destinations or origins</li>
</ul>
<li>Widely used in private networks in companies</li>
<li>Most of the proxy servers today are Web proxy servers</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Forward Proxy Sequence Diagram</h1>
</hgroup>
<div class="h-drawing" id="1F9GMscVnuf1Jex-2SMCc0phrtajyGmZtV-zMl9AqBXA" style="height: 270px"></div>
<ul class="xx-small">
<li>Forward Proxy</li>
<ul>
<li>There are 2 TCP sockets for every connection (client-FP, FP-server)</li>
<li>Client is not directly connected to the server</li>
<li>FP tunnels requests to the server</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Reverse Proxy</h1>
</hgroup>
<div class="h-drawing" id="1RpfjNLhFSzu7mDdWVvV3ZldHEhzx9rLB1KpHpdL9bno" style="height: 270px"></div>
<ul class="xx-small">
<li>Reverse Proxy</li>
<ul>
<li>Aggregates multiple request-response interactions with back-end systems</li>
<li>Processes the request on behalf of the client</li>
<li>The client does not know about the back-end systems</li>
<li>May provide additional capabilities</li>
<ul>
<li>Data transformations</li>
<li>Security – authentication, authorization</li>
<li>Orchestration of communication with back-end systems</li>
</ul>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Reverse Proxy Load Balancer</h1>
</hgroup>
<div class="h-drawing" style="margin-top: 40px; height: 450px" id="1QtCAcD0R571rYmeP1hrofveZ3x6F7P61rfUpEswxOl0">
</div>
</div>
<div class="slide">
<hgroup>
<h1>HTTP Sticky Sessions Example</h1>
</hgroup>
<div class="h-drawing" id="1hzFB_41gJmkKQHpcSODvengGnHW98UYv1x1xZHt4XMA" style="height: 320px; margin: 20px">
</div>
<ul class="x-small">
<li>How to identify a server that hosts the session state</li>
<ul>
<li>Passive cookie persistence – LB uses a cookie from the server</li>
<li>Active cookie persistence – LB adds its own cookie</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Types of Load Balancers</h1>
</hgroup>
<ul class="x-small">
<li>Software</li>
<ul>
<li>Apache <code>mod_proxy_balancer</code>, NGINX</li>
<ul>
<li>HTTP Session persistence – sticky sessions</li>
<li>Various configuration options</li>
</ul>
<li>WebLogic proxy plug-in</li>
<pre class="brush: xml">
<Location /soa-infra>
SetHandler weblogic-handler
WebLogicCluster czfmwapp03-vf:8001,czfmwapp04-vf:8001,czfmwapp05-vf:8001
</Location>
</pre>
<ul class="no-bullet">
<li><code>/soa-infra</code> is a first part of an URL path that rules in this <code>Location</code> will
be
applied (this is a standard Apache configuration mechanism)</li>
<li><code>WebLogicCluster</code> specifies the list of backend servers for load balancing</li>
</ul>
</ul>
<li>Hardware</li>
<ul>
<li>Cisco, Avaya, Barracude</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Round-Robin Algorithm</h1>
</hgroup>
<ul class="xx-small">
<li>Uses</li>
<ul class="no-bullet">
<li><code>request</code> – client request with or without a cookie information</li>
<li><code>server_list</code> – a list of backend servers that can process the request</li>
<li><code>rbinx</code> – round robin index</li>
<li><code>sticky_sessions</code> – associative array of pairs <code><session_id,server></code>
</li>
<li><code>unhealthy_treshhold</code> – a number of negative consecutive health checks
before moving the server to the "unhealthy" state.</li>
</ul>
<li>Round Robin Algorithm</li>
<ul>
<li>if <code>session_id</code> exist in the <code>request</code> and in <code>sticky_sessions</code></li>
<ul>
<li>send the <code>request</code> to the server <code>sticky_sessions[session_id]</code></li>
</ul>
<li>otherwise</li>
<ul>
<li>send the <code>request</code> to the <code>rbinx</code> server in the <code>server_list</code></li>
<li>extract <code>session_id</code> from the response from the server</li>
<li>if the <code>session_id</code> exist, add a pair <code><session_id;server_list[rbinx]></code> to
<code>sticky_sessions</code>
</li>
<li>increase <code>rbinx</code> by one or reset it to <code>0</code> if it exceeds the length of
<code>server_list</code>
</li>
</ul>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Health Check</h1>
</hgroup>
<ul class="xx-small">
<li>Health Check</li>
<ul>
<li>For each server in the <code>server_list</code></li>
<ul>
<li>call the server's heatlhcheck endpoint</li>
<li>if a number of failed health checks for the server exceeds the <code>unhealthy_threshold</code></li>
<ul>
<li>remove the server from the <code>server_list</code></li>
</ul>
<li>if the server was unhealthy and a there was a successful healthcheck</li>
<ul>
<li>add the server back to the <code>server_list</code></li>
</ul>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Backend Server Selection Options</h1>
</hgroup>
<ul class="xx-small">
<li>Backend server with a weight and a backup server</li>
<ul>
<li>NGINX example:</li>
<pre class="brush: plain; gutter: false; class-name: 'tight'">
http {
upstream backend {
server backend1.example.com weight=5;
server backend2.example.com;
server 192.0.0.1 backup;
}
server {
location / {
proxy_pass http://backend;
}
}
}
</pre>
</ul>
<li>Least connections</li>
<ul>
<li>A request is sent to a server with the least number of active connections</li>
</ul>
<li>Least time</li>
<ul>
<li>A request is sent to a server with the lowest average response time and the lowest number of active
connections</li>
<li>Time can be:</li>
<ul>
<li>Time to receive the resonse header</li>
<li>Time to receive full response body</li>
</ul>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Backend Server Selection Options (Cont.)</h1>
</hgroup>
<ul class="xx-small">
<li>Limiting the Number of Connections</li>
<ul>
<li>Maximum number of connections per backend server</li>
<li>Number of connections in the queue</li>
<pre class="brush: plain; gutter: false">
upstream backend {
server backend1.example.com max_conns=3;
server backend2.example.com;
queue 100 timeout=70;
}
</pre>
</li>
</ul>
<li>Hash (ip hash, generic hash)</li>
<ul>
<li>A server to which a request is sent is determined from the client IP address or an arbitrary value
(string, request URL, etc.)</li>
</ul>
<li>Server Slow-Start</li>
<ul>
<li>This prevents a recently recovered server from being overwhelmed</li>
<li>During server slow-start, connections may time out</li>
<ul>
<li>This may cause the server to be marked as failed again.</li>
</ul>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Session Persistence</h1>
</hgroup>
<ul class="xx-small">
<li>Session Persistence</li>
<ul>
<li>Sticky cookie</li>
<ul>
<li>A cookie defined by the load balancer for every client</li>
<pre class="brush: plain; gutter: false">
upstream backend {
server backend1.example.com;
server backend2.example.com;
sticky cookie srv_id expires=1h domain=.example.com path=/;
}
</pre>
</ul>
<li>Sticky learn</li>
<ul>
<li>LB finds a cookie by inspecting requests and responses</li>
<li>LB uses the cookie for subsequent redirection</li>
</ul>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Session State Persistence and Replication</h1>
</hgroup>
<ul class="xx-small">
<div class="h-drawing" style="height: 290px" id="1PiI-1CeVkQTYUgOPHyk3wqJufQl9cYQz5vlNziERE74"></div>
<li>Session DB persistence</li>
<ul>
<li>Session information is maintained in the database</li>
<li>Does not require sticky sessions in LB</li>
<li>Implements <code>HttpSession</code> interface that writes data to the DB</li>
</ul>
<li>In-memory replication</li>
<ul>
<li>A <b>primary server</b> holds a session state, the <b>secondary server</b>
holds its replica.</li>
<li>Information about primary and secondary servers are part of JSession</li>
</ul>
</ul>
</div>
<!-- <div class="slide">
<hgroup>
<h1>In-Memory Replication</h1>
</hgroup>
<ul class="x-small">
<li>Session format</li>
<ul>
<li>It's a cookie</li>
<li><code>JSESSIONID=SESSION_ID!PRIM_SERVER_ID!SEC_SERVER_ID!CREATION_TIME</code></li>
<ul class="no-bullet">
<li><code>SESSION_ID</code> – session id, generated by the server to identify memory associated with
the session on the server</li>
<li><code>PRIM_SERVER_ID</code> – ID of the managed server holding the session data</li>
<li><code>SEC_SERVER_ID</code> – ID of the managed server holding the session replica</li>
<li><code>CREATION_TIME</code> – time the session data was created/updated</li>
</ul>
</ul>
<li>How LB uses this information</li>
<ul>
<li>LB has information whether the server is running or not (via healthchecks)</li>
<li>if the primary server is running, it redirects the request there</li>
<li>if the primary server is not running, it redirects the request to the secondary server directly</li>
<li>if primary and secondary servers are not running, it redirect the request to any other server it has in
the list – this may cause side effects!</li>
</ul>
</ul>
</div> -->
<!-- <div class="slide">
<hgroup>
<h1>In-Memory Replication Scenarios</h1>
</hgroup>
<center>
<div class="h-drawing" id="1APKL5IK-WG_8rlF6g__Q5TwxVrwmW9a4KPbK10JiKGU" style="width: 690px"></div>
</center>
</div> -->
</section>
<div class="slide outline"></div>
<section>
<header>HTTP in Kubernetes</header>
<div class="slide">
<hgroup>
<h1>HTTP in Kubernetes</h1>
</hgroup>
<ul class="x-small">
<li>Kubernetes does not provide built-in Layer 7 (HTTP) routing</li>
<li>Services expose Pods at TCP/UDP level</li>
<ul>
<li><code>ClusterIP</code>: internal-only</li>
<li><code>NodePort</code>: accessible via <code>NodeIP:NodePort</code></li>
<li><code>LoadBalancer</code>: cloud-provider load balancer</li>
</ul>
<li>For advanced routing (URLs, hostnames, TLS)</li>
<ul>
<li>Kubernetes uses the Ingress API</li>
</ul>
<li>Ingress works at the HTTP layer (L7) and provides:</li>
<ul>
<li>Path-based routing</li>
<li>Host-based routing</li>
<li>TLS termination</li>
<li>Centralized access point</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Ingress Resource</h1>
</hgroup>
<ul class="x-small">
<li>An Ingress is a set of HTTP routing rules</li>
<li>It defines how external HTTP/S traffic reaches cluster Services</li>
<li>An Ingress needs an Ingress Controller</li>
<ul>
<li>NGINX Ingress Controller</li>
<li>HAProxy Ingress</li>
<li>Traefik</li>
<li>Contour</li>
</ul>
<li>Controller watches Ingress objects and configures</li>
<ul>
<li>reverse proxy</li>
<li>load balancer</li>
<li>dynamic routing tables</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>How Ingress Works</h1>
</hgroup>
<ul class="x-small">
<li>Client sends HTTP request to public IP</li>
<ul>
<li>LoadBalancer or NodePort</li>
</ul>
<li>Ingress Controller receives the request</li>
<ul>
<li>Runs as a Deployment inside the cluster</li>
<li>Listens on ports 80/443</li>
<li>Uses reverse proxy (NGINX/HAProxy/etc.)</li>
</ul>
<li>Ingress rules decide where to send the request</li>
<ul>
<li><code>Host</code> matching → <code>example.com</code></li>
<li><code>Path</code> matching → <code>/api</code>, <code>/app</code></li>
</ul>
<li>The controller forwards the request to the Service</li>
<ul>
<li>The Service then forwards to Pods</li>
</ul>
<li>Ingress Controller handles</li>
<ul>
<li>TLS termination</li>
<li>HTTP routing</li>
<li>Load balancing across Pods</li>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Ingress Example</h1>
</hgroup>
<ul class="xx-small">
<li>Example Ingress routing traffic to the <code>busybox-tcp-service</code></li>
<pre class="brush: bash; class-name: ''">
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: busybox.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: busybox-tcp-service
port:
number: 8080
</pre>
<li>Requests to <code>http://busybox.example.com/</code> are routed to the Service</li>
<li>Ingress Controller performs HTTP reverse proxying and load balancing across Pods</li>
</ul>
</div>
</section>
<div class="slide outline"></div>
<section>
<header>Performance Tuning</header>
<div class="slide">
<hgroup>
<h1>Performance Limiting Factors</h1>
</hgroup>
<div id="1bo3PC-IopJA4SiyHLVag7g1amyT8W89k2edtirQwz1w" style="height: 450px; margin: 30px" class="h-drawing">
</div>
</div>
<div class="slide">
<hgroup>
<h1>Monitoring</h1>
</hgroup>
<ul class="xx-small">
<li>Important to understand performance</li>
<ul>
<li>DevOps monitoring trends</li>
</ul>
<li>What you need</li>
<ul>
<li>Collect → Filter → Store → View → <b>Tune</b></li>
<li>Metrics, dashboards, alerting, log management, reporting, tracing capabilities</li>
<li>It is necessary to organize metrics well in order to understand what is going on</li>
<li>Start from a high-level process, detail to technical components</li>
</ul>
<li>Source</li>
<ul>
<li>Application server</li>
<ul>
<li>usually management beans with JMX interfaces</li>
<li>log files (access logs, server logs, etc.)</li>
</ul>
<li>OS</li>
<ul>
<li>many utilities available out of the box</li>
<li>open sockets, memory, context switches, I/O performance, CPU usage</li>
</ul>
<li>Database</li>
<ul>
<li>applications may write metrics to the DB</li>
<li>SQL scripts to collect metrics</li>
</ul>
</ul>
</ul>
</div>
<div class="slide">
<hgroup>
<h1>Monitoring Tools</h1>
</hgroup>
<ul class="x-small">
<li>Commercial Monitoring Solutions</li>
<ul>
<li>Application server vendor usually offers a monitoring solution</li>
<li>AppDynamics, Oracle Enterprise Manager, Splunk</li>
<li>Google stackdriver, Amazon AWS CloudWatch</li>
</ul>
<li>Open source examples</li>
<ul>
<li>Elasticsearch + LogStash + Kibana</li>
<li>InfluxDB + Telegraph + DataGraph</li>
</ul>
</ul>
</div>
</section>
</body>