API GATEWAY and Microservices Architecture | How API Gateway act as a Single Entry Point?

Concept && Coding - by Shrayansh
28 Sept 202423:17

Summary

TLDRThe video script discusses the critical role of API Gateways in handling high volumes of requests and their differences from load balancers. It explains how API Gateways route requests to appropriate microservices, perform API composition, authentication, and rate limiting. The script also covers service discovery, request/response transformation, and caching. It further elaborates on how API Gateways scale across multiple regions and availability zones, ensuring no single point of failure, and how DNS-based load balancing helps distribute traffic efficiently.

Takeaways

  • 🚪 **API Gateway as a Single Entry Point**: API Gateway acts as the single entry point for all client API requests, routing them to the correct backend service based on the API endpoint.
  • 🔄 **Difference from Load Balancer**: Unlike load balancers that distribute traffic across instances of the same microservice, API Gateway understands and routes API requests to different microservices based on the endpoint.
  • 🤖 **API Composition**: API Gateway can compose responses by calling multiple microservices and aggregating the data, reducing the complexity on the client side.
  • 🔐 **Authentication**: API Gateway provides authentication services, integrating with authorization servers to validate client tokens before allowing access to microservices.
  • 🚦 **Rate Limiting and Throttling**: API Gateway can enforce rate limits and throttling to manage traffic and prevent abuse, ensuring fair usage and system stability.
  • 🔍 **Service Discovery**: It interacts with service discovery systems to find the correct microservice instances to route requests to, as microservice locations can change due to scaling.
  • 🔄 **Request/Response Transformation**: API Gateway can transform incoming requests and outgoing responses to fit the needs of the system, including caching responses for efficiency.
  • 🌐 **Scalability Across Regions and AZs**: API Gateway scales across multiple regions and availability zones to handle high traffic and provide low latency, ensuring high availability.
  • 🌐 **DNS-Based Load Balancing**: At the highest level, DNS-based load balancers distribute traffic to the appropriate regional API Gateways, considering factors like latency and compliance.
  • 🛡️ **No Single Point of Failure**: The system design ensures that there are no single points of failure, with traffic able to be rerouted in case of outages in availability zones or regions.

Q & A

  • What is an API Gateway and how does it differ from a load balancer?

    -An API Gateway is a single entry point that accepts client API requests and routes them to the correct backend service based on the API endpoint. Unlike a load balancer, which distributes traffic to multiple instances of a microservice, an API Gateway understands the API structure and makes routing decisions accordingly.

  • What is API composition and why is it important?

    -API composition is a feature of API Gateways that simplifies client requests by allowing the Gateway to call multiple microservices and aggregate the results into a single response. This reduces the complexity on the client-side and is frequently used in services like Netflix to tailor API responses based on the device type.

  • How does the authentication feature of an API Gateway work?

    -The API Gateway can authenticate clients by integrating with an authorization server. Clients pass an access token obtained from the authorization server with their requests. The API Gateway validates this token, and if it's valid, the request is allowed to proceed to the microservices.

  • Can you explain rate limiting and API throttling in the context of an API Gateway?

    -Rate limiting is a feature that sets rules to manage the maximum number of concurrent requests an API Gateway can handle before returning a 429 error. API throttling is a more granular level of control that can limit the request rate for individual users or applications, blocking them once they exceed the allowed rate.

  • What is service discovery and how does it interact with an API Gateway?

    -Service discovery is a system that keeps track of the location (IP address and port) of microservices as they scale up or down. The API Gateway uses service discovery to find the current location of a microservice before invoking it, ensuring that the request is routed to the correct instance.

  • How does an API Gateway handle millions of requests per second?

    -An API Gateway can handle high volumes of requests by being deployed in multiple regions and availability zones, with each region having multiple instances of the Gateway. This distributed architecture ensures that there is no single point of failure and allows the Gateway to scale horizontally to meet demand.

  • What is the role of DNS in distributing traffic to different API Gateways?

    -DNS plays a crucial role in load balancing at the domain name level. Services like AWS Route 53 or Azure Traffic Manager act as DNS-based load balancers, distributing traffic to the appropriate API Gateway based on factors like latency, compliance, and geographical location.

  • How does the API Gateway decide which microservice to route a request to?

    -The API Gateway decides which microservice to route a request to based on the API endpoint. It examines the structure of the incoming API request and uses this information to determine the appropriate backend service to handle the request.

  • What are the benefits of using an API Gateway over a traditional load balancer?

    -API Gateways offer intelligent routing based on API structure, support for API composition to aggregate data from multiple services, authentication, rate limiting, and service discovery. These features provide more flexibility and control over API traffic compared to traditional load balancers, which only distribute traffic without understanding the API context.

  • Can you provide an example of how API composition might work in a real-world scenario?

    -In an e-commerce platform, when a user requests their order history, the API Gateway can compose a response by calling the product and invoice microservices to fetch relevant details. If the request comes from a mobile device, it might show only product and invoice details, while a request from a PC might include additional information like ratings, reviews, and recommendations, all aggregated into a single response by the API Gateway.

  • What are some other capabilities of API Gateways mentioned in the script?

    -Besides routing, API composition, authentication, rate limiting, and service discovery, API Gateways can also perform request and response transformation, caching of responses to reduce load, and logging for monitoring and debugging purposes.

Outlines

00:00

🚀 Introduction to API Gateway

The speaker, Shan, introduces the topic of API Gateway in the context of system design. He explains that API Gateway is a critical component that acts as a single entry point for all client API requests. It routes these requests to the appropriate backend service based on the API endpoint. This is different from a load balancer, which simply distributes traffic across instances of a microservice without understanding the API itself. API Gateway is described as intelligent, capable of handling more complex tasks such as API composition, where it can assemble responses from multiple microservices based on the client's device type, thus reducing client-side complexity.

05:01

🔐 API Gateway Features: Authentication and Rate Limiting

Shan discusses additional features of API Gateway, including authentication and rate limiting. Authentication is handled by the API Gateway, which can validate access tokens from an authorization server, ensuring that only authenticated clients can access the microservices. Rate limiting is another feature that prevents abuse by setting limits on the number of requests a client can make within a certain time frame. This can be applied globally or to specific APIs or users, helping to manage traffic and prevent overloading of services.

10:02

🌐 Service Discovery and Handling High Traffic

The paragraph delves into service discovery, which is essential for managing the locations of microservices as they scale up or down. Service discovery can register or deregister microservice instances or perform health checks to ensure only active instances are considered. This helps API Gateway to route requests to the correct microservice instances. Shan also begins to explain how API Gateway can handle high traffic by discussing the distribution of requests across multiple regions and availability zones, ensuring no single point of failure.

15:05

🌆 Regional Distribution and Redundancy

Shan elaborates on the concept of regions and availability zones in cloud infrastructure. He explains that each availability zone within a region has its own data center, and if one goes down, the others can handle the traffic. This setup ensures redundancy and high availability. API Gateway operates at the regional level, routing traffic to the appropriate availability zone based on factors like user location and service requirements. This approach helps distribute the load and avoid a single point of failure.

20:06

🌐 Global Traffic Management and DNS Load Balancing

In the final paragraph, Shan addresses how traffic is distributed globally across different regions and API Gateway instances. He introduces the concept of DNS-based load balancing, which directs traffic to the appropriate API Gateway based on factors like latency and compliance requirements. This ensures that users are served by the closest and most suitable API Gateway, improving performance and reliability. Shan also mentions that DNS is not a single point of failure due to its distributed nature, which will be covered in more detail in a future video.

Mindmap

Keywords

💡API Gateway

API Gateway serves as a single entry point for all client requests in a system, routing them to the appropriate backend service based on the API endpoint. It is a critical component in managing, securing, and monitoring interactions between clients and microservices. In the script, the API Gateway is compared to a load balancer to highlight its unique capabilities, such as understanding API structures and making routing decisions accordingly.

💡Load Balancer

A load balancer is a system that distributes network or application traffic across multiple instances of a service. Unlike an API Gateway, it does not understand the context of API requests but simply distributes traffic to ensure no single instance is overwhelmed. The script contrasts the API Gateway with a load balancer to emphasize the intelligent routing capabilities of the former.

💡API Composition

API Composition is a feature of API Gateways that allows the creation of new APIs by combining data from multiple back-end services. This is useful for creating a unified response that aggregates information from different microservices, reducing the complexity for the client. The script uses the example of a mobile device versus a personal computer to illustrate how API composition can tailor the API response based on the client's capabilities.

💡Authentication

Authentication is the process of verifying the identity of a user or system. In the context of the script, API Gateways can authenticate clients by integrating with authorization servers and validating access tokens. This ensures that only authenticated clients can access the microservices, centralizing the authentication logic and preventing its duplication across services.

💡Rate Limiting

Rate Limiting is a technique used to control the number of requests a user or an IP address can make to an API within a certain time period. It helps prevent abuse and ensures fair usage of resources. The script mentions setting burst limits and API throttling as examples of rate limiting, which can be configured to manage peak loads and prevent service outages.

💡Service Discovery

Service Discovery is the process of locating and registering service instances in a distributed system. It is crucial for dynamic environments where microservices scale up and down, changing their network locations. The script explains how API Gateways use service discovery to find the correct microservice instance to route a request, ensuring high availability and fault tolerance.

💡Request/Response Transformation

Request/Response Transformation refers to the process of altering the format or structure of incoming requests or outgoing responses. API Gateways can perform these transformations to meet specific business needs or to ensure compatibility between clients and services. The script implies that this feature can be used to adapt to different client requirements or to standardize data formats across services.

💡Caching

Caching is a technique used to store copies of frequently accessed data in a faster-access storage system to improve performance. API Gateways can cache responses to reduce the load on backend services and speed up response times for clients. The script suggests that caching can be used to handle repeated requests more efficiently, by serving cached responses instead of processing the same request multiple times.

💡DNS-based Load Balancer

A DNS-based Load Balancer uses the Domain Name System to distribute client requests across multiple servers or regions. This is part of a larger strategy to ensure high availability and reduce latency by directing traffic to the nearest or least busy API Gateway. The script discusses how DNS-based load balancing works in conjunction with API Gateways to manage traffic at a regional level, enhancing the system's scalability and resilience.

💡Regions and Availability Zones

Regions and Availability Zones are terms used in cloud computing to describe different levels of redundancy and fault tolerance. A region is a separate geographic area, while an Availability Zone is an isolated location within a region. The script explains how API Gateways can route traffic to different regions and availability zones based on factors like latency, compliance, and client location, ensuring robustness and high availability.

Highlights

API Gateway is a critical component in system design, serving as a single entry point for client API requests.

API Gateway routes API requests to the correct backend service based on the endpoint.

Load balancers distribute traffic to multiple instances of a microservice, but do not understand API structure.

API Gateway can compose APIs, reducing client-side complexity by handling multiple microservice calls.

API Gateways handle authentication, integrating with authorization servers to validate client tokens.

Rate limiting and API throttling are used to manage traffic and prevent abuse.

Service Discovery is crucial for keeping track of microservice locations in a dynamic environment.

API Gateways can transform requests and responses to meet specific needs.

Caching responses at the API Gateway can improve performance by reducing the need to invoke APIs for repeated requests.

Logging is an important feature of API Gateways for monitoring and debugging purposes.

API Gateways handle millions of requests per second by leveraging regions and availability zones.

Regions and availability zones provide redundancy and prevent single points of failure.

DNS-based load balancing is used to distribute traffic between different regions and API Gateways.

DNS is not a single point of failure due to its distributed nature with local and authoritative servers.

Service Discovery provides the location for microservices to the API Gateway for routing requests.

Load balancers work at the microservice level, distributing traffic among instances.

API Gateways decide which load balancer to invoke based on the API request.

Transcripts

play00:00

hey guys Shan the side and welcome to

play00:02

concept and coding and today in system

play00:04

design playlist I'm going to cover a new

play00:07

topic which is very very important which

play00:09

is API Gateway there are so many

play00:11

questions which built on top of it and

play00:14

I'm going to tell you the complete uh

play00:17

overall design where this API Gateway

play00:20

fit and these two are the most

play00:23

frequently interview question get asked

play00:25

if API Gateway is a single entry point

play00:28

how does it handle millions of request

play00:30

per second or sometime also like how API

play00:33

Gateway is different from load balancer

play00:35

does it come before or after the load

play00:37

balancer and trust me so many Engineers

play00:41

has doubt on this

play00:42

one what is API

play00:45

Gateway in simple term it accept the

play00:48

client API request and Route them to

play00:52

correct backend service based on API end

play00:57

point read this line again because this

play01:00

is what makes it different from a load

play01:02

balancer so let's say that this is a

play01:04

client and API Gateway is in mid so it

play01:09

accept your

play01:10

request Now API get will will decide hey

play01:14

if it is this API / API invoice it has

play01:17

to route to this micros service invoice

play01:20

micros service if API structure is like

play01:24

this it has to route to order

play01:26

microservice if API structure is like

play01:28

this it has to route to sales micros

play01:30

service okay so it route the API to

play01:35

correct backend

play01:37

service isn't this what load balancer

play01:39

also do

play01:41

no generally load balancer simply

play01:45

distribute the traffic to multiple

play01:47

instance of a

play01:49

microservices so for example once the

play01:52

request is coming load balancer task is

play01:55

to just equally distribute the traffic

play02:00

between multiple instances of a same

play02:03

microservice so invoice microservice 1

play02:05

invoice microservice 2 invoice

play02:07

microservice three and many

play02:08

more but it do not have the capability

play02:13

to understand an API okay and then take

play02:16

a decision where to Route so load

play02:19

balancer doesn't have capability to

play02:21

understand this API okay it is slash

play02:23

invoice I have to move it to invoice

play02:25

otherwise I have to move it to order no

play02:29

and that's the m major difference

play02:30

between API Gateway and load

play02:33

balancer so apart from routing what API

play02:37

Gateway is doing right based on the end

play02:39

point it decide where to Route which

play02:41

microservice to

play02:43

Route it has so many other capabilities

play02:46

right API Gateway is very intelligent

play02:47

compared to load balancer so fun thing

play02:50

is API composition so here if you see I

play02:53

will tell you the problem with the API

play02:55

composition so now let's say that uh you

play02:57

are opening a e-commerce website and you

play03:00

are going to like view my order view my

play03:04

order click on button now you have to

play03:07

see your past purchase history now let's

play03:10

say if you are uh clicking that option

play03:13

from mobile device so mobile device has

play03:17

very less uh bandwidth you can say that

play03:19

so we show less details so we show let's

play03:22

say only these two details product

play03:24

details and invoice details so mobile

play03:27

device client is using an API just uh

play03:30

take it as an example one from the

play03:32

product microservice and one from the

play03:34

invoice microservice and fetching the

play03:36

detail of product and fetching the

play03:37

detail of invoice and showing the

play03:40

details but now let's say if you are

play03:42

using computer or a personal computer

play03:45

there it has more space and uh bandwidth

play03:49

so you might show more details so maybe

play03:54

the same page for the PC device client

play04:00

apart from product and invoice it is

play04:02

also showing ratings and reviews it is

play04:04

might be also showing recommendations so

play04:08

even though the same page but based on

play04:12

the device also you see the

play04:13

functionality

play04:15

differs okay now on the PC device L you

play04:18

need to query more apis or maybe it is

play04:21

possible that different microservices

play04:23

also to F those

play04:25

dils now here if you see this is an

play04:28

additional headache on the client so

play04:31

with the help of API composition feature

play04:34

of API Gateway this can be simplified so

play04:38

now here if you see that in the API

play04:40

Gateway we can configure the endpoint

play04:43

let's say/ API SL my order if the client

play04:47

calls this Now API Gateway has a

play04:51

intelligent that okay if it is a mobile

play04:55

device I will call this two API this two

play04:59

Microsoft services and F the product

play05:01

detail and invoice

play05:03

detail API Gateway has the intelligent

play05:05

okay if it is a personal uh computer

play05:07

device then I have to call additional

play05:12

apis okay gather the result and return

play05:15

the single response so now here if you

play05:18

see that the client work is and the

play05:21

complexity is reduced a lot so this is

play05:24

this feature is known as API composition

play05:26

and it is very very important and it is

play05:28

very frequently used used

play05:31

in Netflix so

play05:34

Netflix the API Gateway which uses it is

play05:37

highly used this API composition okay

play05:41

then we have another feature

play05:43

of API gateways authentication so what

play05:46

happen is so let's say you have a client

play05:49

they are calling an API Gateway okay Now

play05:53

API Gateway also has capability to

play05:56

authenticate the client so now let's say

play05:58

that if it is using o 2.0 flow so in the

play06:02

first step the client get an access

play06:06

token from the authorization server if

play06:09

you if you don't know about the O 2.low

play06:12

check out this hld playlist I have

play06:13

covered in depth of this or 2.low so it

play06:16

would becomes uh clear to you so in the

play06:19

first step the client get an access

play06:21

token from the authorization server now

play06:24

any subsequent request the client pass

play06:26

this token to the API Gateway

play06:29

API Gateway integrates with

play06:32

authorization server and validate this

play06:35

token hey the client it is trying to

play06:38

access an API and it gives me this token

play06:41

is it a valid token or not now

play06:44

authorization server validated yes yes

play06:46

or no if it is yes valid then only API

play06:51

Gateway allow it to pass to a

play06:54

microservices instead of you are putting

play06:56

an authentication logic here here here

play07:00

you are duplicating the things so we are

play07:03

putting the authentication at the front

play07:06

itself only after authenticated it will

play07:09

go

play07:11

further the third important feature of

play07:13

API Gateway is rate limiting so we can

play07:16

set various rules like managing the

play07:18

burst Ram burst limit so burst limit is

play07:21

something like it's handling the

play07:24

peak means maximum number of concurrent

play07:27

requests that API Gateway can handle

play07:29

before it returned 429 too many requests

play07:33

so if you're using aw as aure API

play07:37

Gateway you will have a option to set a

play07:40

burst Limit you can put the value okay

play07:42

500 something like this so what burst

play07:46

Limit says that at a peak what is a

play07:49

maximum concurrent request API Gateway

play07:51

can

play07:52

handle then we have API throttling API

play07:55

throttling I would say that it's a more

play07:57

granual level like

play08:00

we can limit a particular individual or

play08:04

an application right by blocking them

play08:09

once they cross an allowed request rate

play08:11

for example I say that okay this API /

play08:16

API SL

play08:18

invoice this API should not get invoke

play08:23

uh more than 10

play08:26

times in a minute

play08:29

okay so with API throttling we can do

play08:33

that so 10 times in a minute as soon as

play08:35

the 11th call

play08:37

come in a minute it will fail it this

play08:39

will block it even you can go more

play08:42

granual that okay but 10 times in a

play08:45

minute by a particular

play08:47

user by a particular user

play08:51

also okay so this

play08:53

all rules comes under API

play08:56

throttling you can also set a rules to

play08:59

IP based blocking that a particular IP

play09:01

will get blocked and also API qes which

play09:05

is uh you can say that a part of rate

play09:07

limiting hold request to an API which

play09:10

cannot be processed immediately it helps

play09:13

to handle the uh thundering her issue so

play09:17

as soon as subsequent traffic comes now

play09:20

let's say that th000 request comes in

play09:23

the B limit I have only said 500 so 500

play09:25

request are will not be able to process

play09:28

so we can put in into apiq they will

play09:30

wait in the waiting area till your API

play09:34

Gateway get the bandwidth to process

play09:37

them so this rate limiting is also very

play09:40

important feature another very important

play09:43

feature is service Discovery very

play09:45

important okay so now understand that

play09:48

you have multiple components let's say

play09:51

you have microservices you have load

play09:54

balancer right there are multiple

play09:57

instances of everyone

play09:59

and today in the distributed World some

play10:02

go scale up scale down so their IP

play10:05

address and port number keep on changing

play10:07

so you need somebody to keep track of

play10:09

their location who does that service

play10:13

Discovery a microservices can scale up

play10:15

and scale down it's necessary to know

play10:18

the

play10:19

location IP address and Port service

play10:22

Discovery keep track of those so there

play10:25

are two different approaches approach

play10:27

one whenever each micros Services uh

play10:30

scales up or scal down it has to

play10:32

register or deregister themselves so

play10:35

they have to uh register to the service

play10:38

Discovery and then only service

play10:40

Discovery would be able to know about

play10:41

their location another approach is that

play10:44

service Discovery keep the heal check of

play10:46

all the registered microservice and keep

play10:49

only active microservices location so

play10:52

earlier it has multiple microservices

play10:54

which is registered in the service

play10:56

Discovery so service Discovery keep

play10:58

frequently Health checkup now let's say

play11:01

if it is not able to see the heartbeat

play11:03

of this one it will remove this one from

play11:05

its location and only whatever the uh

play11:08

somebody asks that hey this is uh

play11:11

invoice microservice one invoice

play11:13

microservice instance 2 invoice

play11:15

microservice St 3 anybody ask for hey

play11:18

give me a location for invoice

play11:20

microservice service Discovery will

play11:22

provide one of

play11:24

them

play11:26

okay so here you have a client

play11:30

it is calling an API it goes to an API

play11:33

Gateway Now API Gateway has the logic

play11:36

that okay it's slash order means it has

play11:38

to invo order micros

play11:42

service now it has to know the location

play11:45

before invoking that right so how API G

play11:49

will know it will call service Discovery

play11:52

there are various software like zul and

play11:55

urea so they provide they serve as a

play11:59

Serv service Discovery uh software so

play12:02

API Gateway check with them hey I need a

play12:05

location for order microservice service

play12:08

Discovery will give it a location and it

play12:11

will pass it to the proper micros

play12:16

service okay so sometimes there is a

play12:19

separate service for service Discovery

play12:22

and sometimes this the complete

play12:24

functionality itself is inbuilt there in

play12:27

the API Gateway

play12:29

so these four are the major capabilities

play12:32

of API Gateway but there are other

play12:34

capabilities like request response

play12:37

transformation the request which is

play12:40

coming and the response which goes out

play12:43

you can transform this according to your

play12:45

company needs you can even cash the

play12:48

response which is going out you can cash

play12:50

it so that the next time same request

play12:52

comes uh you don't have to invoke an API

play12:55

itself you can directly response from

play12:56

here itself and even you can put

play13:01

logging now if API Gateway is a single

play13:04

entry point how does it handle million

play13:06

of request per second so before I goes

play13:09

to this diagram let me do some rough

play13:11

here and then I will tell you so till

play13:15

now what we have seen is we have

play13:18

microservices let's say invoice

play13:21

microservice and it has multiple

play13:25

instances okay then you have

play13:29

order

play13:31

microservice and it will have its own

play13:34

multiple instances now you know that who

play13:37

will take care of uh Distributing the

play13:40

traffic to a

play13:41

single uh microservices to a multiple

play13:44

instance it's load balancer so you have

play13:47

one load balancer which takes care of

play13:51

Distributing the traffic between

play13:53

multiple instances of this invoice

play13:56

microservices this is invoice microser

play13:59

Services similarly you will have one

play14:01

load balancer which takes care of

play14:03

responsibility to distribute the traffic

play14:06

to a multiple instances of order

play14:10

microservices

play14:13

now who will route the traffic to a load

play14:16

balancer you

play14:18

have API Gateway so whenever the request

play14:22

comes to an API

play14:24

Gateway API Gateway check with service

play14:28

discovery

play14:29

hey this is the API / API SL invoice

play14:33

let's

play14:34

say now with service Discovery it will

play14:37

give me an address of this load balancer

play14:39

here you have to interact

play14:40

with this in this scenario and if it is

play14:45

uh SL API SL order then API Gateway will

play14:49

check with service Discovery service

play14:51

Discovery will give an address of this

play14:53

load

play14:54

balancer and this load balancer will

play14:56

take care of Distributing whatever the

play14:58

traffic it is coming com among multiple

play15:00

instances of that that so now I am just

play15:04

extended this to a Next Level now here

play15:08

if you see I bring couple of new points

play15:11

region and availability zone so you need

play15:14

to First understand what is region and

play15:16

what is availability zone now let's

play15:20

say when we have to answer that how it

play15:22

handle millions of requests per second

play15:24

and when it say that it's a single entry

play15:26

point does it really a single entry

play15:28

point

play15:30

right then what things comes into mind

play15:33

is we have to understand first region

play15:34

and

play15:36

AZ consider this region as I'm saying

play15:39

let's

play15:40

say uh

play15:43

Mumbai Mumbai is one region and AZ is

play15:46

particular area area one let's say area

play15:49

2 uh let's say

play15:52

bandra and uh now XY Z area inside this

play15:56

region so now in this each a there they

play16:00

have a dedicated data

play16:03

center dedicated

play16:05

data

play16:07

center notice that this AZ so this is

play16:11

let's say AZ 1 this is az2 in this

play16:14

region this region Mumbai has 2 a

play16:17

availability zone right uh maybe bandra

play16:21

and some other area and each area has a

play16:24

dedicated Data Center and they do not

play16:27

share any resource

play16:30

if anyone goes down it's not like the

play16:33

complete region is down this region its

play16:35

traffic will now move to this

play16:38

one when this also both goes down then

play16:41

only we say that hey region is down

play16:43

region one is down then companies do

play16:46

have different region also region two

play16:49

let's say maybe Chennai in Chennai

play16:54

multiple az1

play16:57

az2 Okay so so let's say one a area is

play17:01

Shing another is some other area so even

play17:06

though one a got down doesn't matter

play17:09

this region has another a if all the A's

play17:12

availability Zone get down then then

play17:15

also there will not be any single point

play17:17

of failure because this region is also

play17:20

we have multiple

play17:21

regions so the same thing here so you

play17:25

already know that I have already showed

play17:27

you microservices

play17:29

now slowly understand this now I'm going

play17:31

to extend it further you have a

play17:34

microservices one it has multiple

play17:40

instances who control the traffic to a

play17:42

multiple instance of a single

play17:44

microservice is your load

play17:48

balancer similarly you have multiple

play17:51

different uh microservice itself let's

play17:53

say this is order micros service 2 it is

play17:56

also has its own instances

play18:00

load balancer will take care of

play18:02

Distributing the traffic to this

play18:04

multiple

play18:05

instances so this would be all under one

play18:08

availability

play18:09

Zone this is your one availability

play18:13

Zone similarly you have

play18:16

a

play18:18

same structure in az2 different

play18:23

availability Zone okay same

play18:25

microservices one it's multiple

play18:27

instances microservices to it multiple

play18:29

instances and load

play18:32

balancer Now API Gateway is one region

play18:35

level let's say that any request which

play18:37

comes to an API Gateway API Gateway

play18:40

check with service Discovery service

play18:42

Discovery has many criteria and rules it

play18:46

uh checks let's say that user belongs to

play18:49

area one and the nearest availability

play18:52

zone is this so the location with

play18:55

service Discovery will give to an API

play18:57

Gateway so API Gateway will route the

play19:00

traffic to this availability zone now

play19:03

based on the API uh either this load

play19:06

balancer get invoked or this load

play19:08

balancer right if it let's say an

play19:10

invoice API this load balancer which is

play19:13

has an invoice micros service if this is

play19:16

an order API this load balancer get

play19:18

invoke which is an order microservice

play19:20

let's

play19:20

say similarly uh if the user is nearest

play19:25

to this availability Zone API Gateway

play19:28

get the location from service Discovery

play19:30

for this a and then based on the API uh

play19:35

appropriate load balancer will get

play19:38

invo now here if you see that this is

play19:41

region one similarly you can have

play19:44

multiple regions like this region two

play19:46

there could be possible Region Three and

play19:48

inside each region you have the same

play19:50

thing so one thing is very clear that

play19:52

it's not a single point of failure if

play19:54

both the load balancer will fail mean

play19:56

this a got down this az2 will take care

play19:59

of it now if this also got failed this

play20:03

also got failed means your complete

play20:06

region is failed

play20:08

then region two comes into the picture

play20:11

let's say region two will take care of

play20:14

it okay so it's not a single point of

play20:16

failure first thing now the question

play20:19

which might to be coming that hey

play20:22

how we thought that API Gateway is a

play20:25

single entry

play20:26

point but now we have a different

play20:29

regions different API

play20:32

Gateway how the request is divided

play20:34

between different regions also who who

play20:38

like here load balancing is Distributing

play20:41

the traffic between single uh

play20:43

microservice instance right similarly

play20:45

API Gateway is kind of another micros

play20:47

service you can say or a software and it

play20:50

has its multiple instances here in

play20:52

different different regions now who is

play20:54

going to distribute the traffic is it

play20:56

the load balancer who is going to

play20:57

distribute the traffic

play20:59

you can say kind of so here if you see

play21:02

that the DNS comes into the

play21:05

picture so if you're using AWS there is

play21:08

something called AWS 53 route you can

play21:11

say that it is considered as a DNS based

play21:13

load balancer similarly if you are using

play21:15

Azure there is something called Azure

play21:17

traffic manager it's again a DNS B load

play21:21

balancer so whenever the client makes a

play21:24

call okay so a specific DNS based load

play21:29

balancer distribute the traffic between

play21:32

an appropriate API Gateway and again it

play21:35

has the same uh intelligence like a

play21:39

service Discovery okay which traffic

play21:41

should goes to which region depending

play21:44

upon the latency compliance maybe there

play21:46

is certain countries let's say XY Z

play21:49

country its traffic should not goes to

play21:51

this region it can only be goes to this

play21:54

region so no matter even though it's far

play21:57

the because of liance the traffic has to

play22:00

be moved to this region so it's a very

play22:03

intelligent uh DNS based load balancer

play22:07

and it can help to Route the traffic

play22:09

between multiple regions and appropriate

play22:12

API Gateway get the request from this

play22:15

now if you are curious another question

play22:18

might comes to you that hey isn't that

play22:20

DNS is a single point of failure then

play22:23

what if this DNS goes down who will take

play22:25

care of uh moving the traffic to the API

play22:28

gate

play22:29

ways no this is again a very big topic

play22:33

but DNS is not a single point of failure

play22:36

it's not a single point of failure so

play22:39

whenever you type let's say that hey uh

play22:42

example XY

play22:46

z.com so this has to be converted to an

play22:49

IP address who helps it DNS helps it but

play22:54

there is no single instance of this

play22:56

there are multiple like local DNS this

play22:58

is a hierarchy local DNS root DNS top

play23:01

level DNS then it goes to authorative

play23:03

DNS but maybe in future video of system

play23:07

design I will explain the DNS in depth

play23:10

if you have any doubt and question we

play23:11

can discuss further and DNS I will cover

play23:13

in the second part all right thank you

play23:16

bye

Rate This

5.0 / 5 (0 votes)

Связанные теги
API GatewaySystem DesignLoad BalancerMicroservicesService DiscoveryAPI CompositionAuthenticationRate LimitingDNS Load BalancingHigh Availability
Вам нужно краткое изложение на английском?