Suppose we develop an application where a user can edit his pictures.
App Name- PhotoEditor
The user can upload the picture -> editor will edit the photo -> user can download the edited photo.
We can just sign up/sign in to the app using our Google/Twitter/Facebook account even if the app is not owned by Google.
Gmail has its database of user information and it won't give its code to anyone. The user should be a member of Gmail and should have his/her authentic account. It will be either valid or invalid.
Gmail can have a function(user id, password)
{
code
}
The result will be either True/False. Thus you just have to invoke the code by passing the parameters. This is called an API.
So, we have two options
Instances
Lambda Function
Sign Up -L1
Sign In -L2
Receive mail -L3
Delete mail -L4
Change password -L5
Update password -L6
Lambda function will be invoked and only the invoked function will be costed. Gmail will not specify which lambda function they've created. They will create one dummy function e.g. sign in ( ) and this will invoke L2. This will be done internally and the dummy function is called API. The mapping is done through API Gateway.
Advantages
Aws Lambda + API gateway: No infrastructure to manage
Supports WebSocket protocol: used for streaming IPL/Gaming
Handles versioning
Canary Testing
Handles different environments (dev, test, prod...)
Handles Security ( Authentication & Authorization)
Creates API Keys, and handles request throttling ( If a hacker tries to send fishy requests it'll take care of it.
Import API
Cache API responses
API GATEWAY INTEGRATION
Lambda Function- Rest API backend by Lambda
HTTP- On-Prem, Load Balancer
AWS service- SQS
API GATEWAY ENDPOINT TYPES
Private: can be only accessed from your v.p.c and not from outside the AWS environment.
Regional: us-east2 users only no others.
Edge-Optimized: globally, by anyone. It is the default.
Mock integration type-
For the trial, To check if I'm able to call the function, it will not send an actual request to the backend. It will just return the response which is predefined.
Caching API responses
Caching reduces the number of calls made to the backend.
The default TTL is 300 seconds.
Caches are defined per stage.
The cache is expensive. it makes sense in production not in dev and test.
API Gateway Throttling
If I want to block requests after 100 requests.
Throttle- To give service unavailable and reject them.
Define your throttle limits for different stages.