00:00 - 00:04
previously I made a video on the Journey
00:02 - 00:05
of a request where we traced how a
00:04 - 00:07
client request travels from the front
00:05 - 00:10
end to the back end covering key
00:07 - 00:13
components like load balancers gateways
00:10 - 00:15
and apis some of you raised excellent
00:13 - 00:18
questions about the placement and roles
00:15 - 00:21
of load balancers and API gateways when
00:18 - 00:23
to use one both or neither so in this
00:21 - 00:25
video we'll break down some of the most
00:23 - 00:26
common patterns in Cloud native
00:25 - 00:28
architectures I'll cover the
00:26 - 00:30
similarities and differences between
00:28 - 00:32
load balancers and gateways their key
00:30 - 00:34
features and how to combine them
00:32 - 00:38
effectively depending on your business
00:34 - 00:38
and Technical needs so let's
00:39 - 00:45
start both load balancers and API
00:42 - 00:46
gateways functions as reverse proxies a
00:45 - 00:49
concept I have covered in detail in one
00:46 - 00:51
of my previous videos but let's break
00:49 - 00:53
down their roles and features at a high
00:51 - 00:56
level load balances ensure system
00:53 - 00:58
reliability and scalability by
00:56 - 01:00
Distributing incoming traffic across
00:58 - 01:03
multiple servers the prevent any single
01:00 - 01:05
server from being overwhelmed making the
01:03 - 01:07
system more resilient they also run
01:05 - 01:09
health checks to detect server failures
01:07 - 01:12
and automatically redirect traffic to
01:09 - 01:14
healthy instances as traffic grows they
01:12 - 01:17
allow more backend servers to be added
01:14 - 01:19
dynamically ensuring
01:17 - 01:22
scalability and there are two main types
01:19 - 01:24
Network load balancers work at layer 4
01:22 - 01:27
or at the transport layer for ultra low
01:24 - 01:29
latency and high throughput it's ideal
01:27 - 01:31
for real-time applications like gaming
01:29 - 01:34
or financial Trading ing application
01:31 - 01:37
load balancer or elb operates at ler 7
01:34 - 01:39
or at the application ler and supports
01:37 - 01:43
Advance request routing based on content
01:39 - 01:46
like URL paths or HTTP headers it is
01:43 - 01:49
perfect for web and microservices based
01:46 - 01:51
architectures now NLB and ALB might seem
01:49 - 01:54
Advanced for now but I'll cover them in
01:51 - 01:56
detail in a future video for now just
01:54 - 01:59
remember nlv is best for low latency
01:56 - 02:01
high throughput workloads and alv is
01:59 - 02:03
best for smart request routing like URL
02:01 - 02:05
based traffic some of the popular
02:03 - 02:07
examples of load balancers are Amazon
02:05 - 02:10
elastic load balancer Google Cloud load
02:07 - 02:12
balancer engine X and ha proxy API
02:10 - 02:14
gateways on the other hand serve as
02:12 - 02:17
centralized entry point for managing
02:14 - 02:19
apis they handle incoming client request
02:17 - 02:21
route them to the appropriate backend
02:19 - 02:23
services and even perform tasks like
02:21 - 02:26
authentication authorization and rate
02:23 - 02:29
limiting to control request volumes they
02:26 - 02:31
can also transform data adjust headers
02:29 - 02:33
paths or payload formats to ensure
02:31 - 02:36
compatibility some of the popular
02:33 - 02:38
examples here are AWS API Gateway Kong
02:36 - 02:41
API Gateway and APG by
02:38 - 02:43
Google both API gateways and load
02:41 - 02:45
balancers distribute incoming traffic to
02:43 - 02:47
prevent servers from getting overbed
02:45 - 02:49
they most support request routing for
02:47 - 02:52
example load balancers uses IP address
02:49 - 02:55
or ports while API gateways rely on API
02:52 - 02:57
endpoints and request headers both of
02:55 - 02:59
them enable fall tolerance by detecting
02:57 - 03:02
unhealthy services and rerouting traffic
02:59 - 03:04
to to healthy ones now while both
03:02 - 03:07
components share some similarities like
03:04 - 03:09
load balancing and request routing their
03:07 - 03:11
roles differs significantly in modern
03:09 - 03:14
Cloud architectures load balancers focus
03:11 - 03:16
on Distributing Network traffic across
03:14 - 03:18
multiple backend servers ensuring High
03:16 - 03:22
availability scalability and fall
03:18 - 03:24
tolerance whereas API gateways route API
03:22 - 03:26
request to the right back and service
03:24 - 03:28
while adding features like
03:26 - 03:30
authentication rate limiting and data
03:28 - 03:32
transformation there are more API
03:30 - 03:35
specific managing entire request life
03:32 - 03:38
cycle and enabling integration across
03:35 - 03:40
microservices in short load balancers
03:38 - 03:42
manage raw traffic distribution while
03:40 - 03:44
API gateways provide a feature Rich API
03:42 - 03:46
management layer on top when deciding
03:44 - 03:48
how to arrange load balancer and API
03:46 - 03:51
gateways you should consider your system
03:48 - 03:53
needs if scaling and high availability
03:51 - 03:55
of the API Gateway itself are critical
03:53 - 03:57
placing a load balancer in front makes
03:55 - 04:00
sense it evenly distributes traffic
03:57 - 04:02
across multiple API Gateway instances
04:00 - 04:05
ensuring fall tolerance and reducing
04:02 - 04:06
downtime the setup also adds Extra
04:05 - 04:09
Protection with features like DDS
04:06 - 04:11
prevention and web application firewalls
04:09 - 04:13
on the other hand if your system needs
04:11 - 04:16
Advanced features like authentication
04:13 - 04:17
reest transformation or API level rate
04:16 - 04:19
limiting before reaching backend
04:17 - 04:22
Services the API Gateway should come
04:19 - 04:23
first this is common in microservices
04:22 - 04:26
architecture where the Gateway routes
04:23 - 04:29
request to specific backend clusters
04:26 - 04:31
based on defined rules in practice many
04:29 - 04:33
are architectures combine both setups
04:31 - 04:35
for maximum flexibility performance and
04:33 - 04:37
security so let's break down some of the
04:35 - 04:41
common setups when to use them and why
04:37 - 04:43
they work so well so here in this setup
04:41 - 04:46
the client request first hits a load
04:43 - 04:49
balancer like AWS ALB it manages initial
04:46 - 04:51
tasks like SSL termination by decrypting
04:49 - 04:53
incoming encrypted traffic it also does
04:51 - 04:55
traffic distribution such as sending
04:53 - 04:58
request to available API Gateway
04:55 - 05:01
instances and once the request reaches
04:58 - 05:03
the API Gateway it performs API specific
05:01 - 05:06
tasks like authentication and
05:03 - 05:07
authorization to ensure secure access
05:06 - 05:10
thus rate limiting to prevent system
05:07 - 05:12
overload and also does the routing logic
05:10 - 05:14
by forwarding request to the currect
05:12 - 05:16
backend service the structure simplifies
05:14 - 05:19
the client's entry point with a single
05:16 - 05:21
public domain and offloads early request
05:19 - 05:23
handling task like SSL termination from
05:21 - 05:26
the API Gateway in this configuration
05:23 - 05:28
the API Gateway act as the front line
05:26 - 05:31
ensuring only secure authorized and
05:28 - 05:33
validated request proceed further after
05:31 - 05:35
passing the API Gateway it goes to the
05:33 - 05:37
internal load balances which distribute
05:35 - 05:39
traffic across different backend
05:37 - 05:41
clusters such as microservices running
05:39 - 05:43
in kubernetes ECS or even private
05:41 - 05:45
vpcs this is ideal when different
05:43 - 05:47
backend Services need custom load
05:45 - 05:50
balancing configurations or run in
05:47 - 05:52
isolated networks the API Gateway
05:50 - 05:53
handles all client facing concerns
05:52 - 05:56
leaving load balancing task to back and
05:53 - 05:58
focus services and if performance is
05:56 - 06:00
your top priority adding a Content
05:58 - 06:03
delivery Network or CD like Cloud fair
06:00 - 06:06
or AWS Cloud F at the edge can reduce
06:03 - 06:09
latency and offload significant amount
06:06 - 06:11
of traffic here the CDN caches static
06:09 - 06:14
assets like images CSS files or even
06:11 - 06:16
Dynamic Pages request for non-cash
06:14 - 06:17
resources go to a load balancer which
06:16 - 06:19
then forwards them to the API Gateway
06:17 - 06:22
for request handling and traffic
06:19 - 06:23
management the structure boost Global
06:22 - 06:26
performance while still maintaining
06:23 - 06:28
control of API specific business logic
06:26 - 06:30
now some API gateways such as Kong
06:28 - 06:33
engine X and APG come with Native load
06:30 - 06:36
balancing features this means you might
06:33 - 06:38
skip external load balancer and request
06:36 - 06:40
are directly routed to backend services
06:38 - 06:42
with internal load balancing logic and
06:40 - 06:43
this is perfect for smaller setups or
06:42 - 06:45
simpler architectures where reducing
06:43 - 06:48
infrastructure complexity
06:45 - 06:50
matters for high performance setups you
06:48 - 06:52
should consider a multi-tier
06:50 - 06:55
architecture for instance you can have a
06:52 - 06:57
network load balancer or NLB which comes
06:55 - 07:00
first and handles ultr low latency high
06:57 - 07:03
throughput traffic it operates at layer
07:00 - 07:05
4 making it fast but it is limited to
07:03 - 07:08
transport level routing and then we have
07:05 - 07:10
API Gateway it comes next to apply
07:08 - 07:11
security policies request transformation
07:10 - 07:14
and API specific
07:11 - 07:17
Logic the final routing layer is the
07:14 - 07:19
application load balancer at ler 7 it
07:17 - 07:21
distribute request to specific backend
07:19 - 07:23
Services based on paths headers or
07:21 - 07:24
content types this pattern separates
07:23 - 07:26
responsibility into different layers
07:24 - 07:28
optimizing performance and simplifying
07:26 - 07:31
service management so when to choose
07:28 - 07:33
which setup you go API Gateway first if
07:31 - 07:35
API level tasks like authentication
07:33 - 07:38
authorization and rate limiting need to
07:35 - 07:40
happen early you go load balancer first
07:38 - 07:43
if Global traffic management SSL
07:40 - 07:46
termination or DDOS protection is
07:43 - 07:48
essential before any API processing you
07:46 - 07:51
can also go for multiple tiers of load
07:48 - 07:53
balancers if you are in multi- region or
07:51 - 07:55
multicluster deployments where traffic
07:53 - 07:58
distribution requires highly specialized
07:55 - 08:00
rules and finally in microservices heavy
07:58 - 08:03
environments us a service mesh like is
08:00 - 08:04
or Linker enables Advanced traffic
08:03 - 08:07
management dest retries and
08:04 - 08:08
observability inside the network if
08:07 - 08:10
you're interested in learning more check
08:08 - 08:12
out my previous videos where I explained
08:10 - 08:15
service mesh and how companies like
08:12 - 08:16
Netflix leverage it to scale globally
08:15 - 08:18
understanding these combinations will
08:16 - 08:20
help you design more scalable secure and
08:18 - 08:22
resilient Cloud native applications and
08:20 - 08:24
if you found this video helpful hit the
08:22 - 08:25
like subscribe and ring the bell so you
08:24 - 08:29
don't miss the next Deep dive where
08:25 - 08:32
we'll explore nlbs and alvs in detail
08:29 - 08:35
see you unit day