History of Cloud
As we know that computer hardware is very heavy, and from decades, number of layers of abstraction have been built in code.
Data Centre: Let’s first talk about computer hardware in the Data centre. In this case, someone is needed to check whether it is turned on or not and connected to the network. Provisioning of resources is not very easy as we need to talk to people, we have to call to data centre providers to allow access to the machine. It takes a minimum of 10 days to provide the resources. Suppose you want to place an order for a Database server or web server, this service will be provided after 10 days.
IAAS (Infrastructure As A Service): In 2006, Amazon launched an EC2 instance. You can provision the machine with API calls using a command line or web browser. IAAS service was born, and developers around the world were happy as they do not have to provides the physical services anymore. You can provide the virtual machine anywhere in the world and do whatever you want. IAAS is running in a virtual machine as well as in a physical machine. You have to manage Windows, Linux, or maybe some corruption occurs in a disk due to which your operating system is lost then you need to reinstall the operating system.
PAAS (Platform As A Service): Amazon came out with a new service known as PAAS. You need to upload your code and Amazon will provide the underline resources. You still managing Window, Linux. Amazon would not do for you.
Containers: Containers are isolated and lightweight still they need to be deployed in a server, and you have to keep your container running. All these things that you need to manage.
Lambda: Amazon released Lambda in 2015. You do not have to take care of managing Data centre, managing infrastructure as a service, managing platform as a service or container. You need to upload the code and Amazon will do everything for you.
What is Lambda?
- Lambda is used to encapsulate Data centres, Hardware, Assembly code/Protocols, high-level languages, operating systems, AWS APIs.
- Lambda is a compute service where you can upload your code and create the Lambda function.
- Lambda takes care of provisioning and managing the servers used to run the code.
- While using Lambda, you don’t have to worry about scaling, patching, operating systems, etc.
Lambda can be used in the following ways:
- It can be used as an event-driven compute service where AWS Lambda runs your code in response to events. These events could be changes to data in an Amazon S3 bucket or an Amazon DynamoDB table.
- It can be used as a compute service to run your code in response to HTTP requests using Amazon API calls made using AWS SDKs.
How does Lambda work
- User uploads an image to S3.
- S3 triggers an event, and this event is a Lambda function.
- Lambda function takes this image, and then encode the image. When an image is encoded, it gets stored in S3.
- The Lambda function might trigger other Lambda event which is returning image location back to the user.
- The Lambda might trigger another Lambda event that takes the image from the S3 bucket and stores it in another S3 bucket located anywhere in the world.
- From the above example, we conclude that Lambda event can trigger another Lambda event and they can communicate with other AWS resources.
An important feature of Lambda is that it scales automatically. While using Lambda, you do not have to maintain Elastic Load Balancer. It either scales up or scales out based on the condition. Scaling up means increasing the resources in terms of RAM such as 8 GB to 12 GB. Scaling out means adding more and more instances. For example, Load Balancer. If load increases, you scale out rather than scaling up the instances. Lambda function scales out automatically. For example, if we have a two-line function, and millions of users hit the same function, millions of functions created to serve the millions of users.