Overview of Serverless Architecture
Serverless does not mean that there is no server. It means you don’t have that server in which you are going to be managing and putting your entire application.Earlier, not very long ago, companies and the individuals used to buy and manage their hardware and software from networking infrastructure to data stores and servers to high-level responsibilities hiring specialized teams and the individuals for each trust. After that company starting outsourcing, some duties, and then the cloud came, which in combination.
With virtualization, it laid the ground for infrastructure as a service, platform as a service and similar services, which made companies and the individuals happy. These technologies and trends allowed for more outsourcing, and as a result of more focus on the business logic so, lead time has shortened, and the creation of software from requirements gathering to production radius software has become relatively more comfortable cheaper and quicker.
Then came the containerization wave, and we started to hear about deploying single instances and the units that use enough resources from the host, and the same thing happened. New services emerged as gas or container as a service.This article gives an overview about Building Serverless Applications on AWS
It is all for building software and deploying it more comfortable, cheaper, and quicker, all of that with reducing risks and increased efficiency. Serverless is nothing but a step forward in this movement or evolution. If you see each of these advancements i.e., cloud, infrastructure as a service, platform as a service, container as a service for each one of these a lot of burdens have been shifted from manual to outsourcing the management and maintenance of the infrastructure, the platform or even higher level of the staff. But still there are some things that have to be dealt like servers- the logic they acquire and everything from building server-side code that perform a lot of functionalities that are not associated to the market like routing, security, authentication and authorization and support and debugging the server-side of the application are still done by the developers, well Serverless came to solve one more problem that is building and maintaining the server-side of the application.
Serverless is building software by focusing more on business logic without thinking how you are going to serve your software like there is no server, just business logic. This doesn’t mean that there is no server-side work by developers at all. There could be some configuration and integration work, but all those problems like bugging service technologies as well as scaling and handling failovers. All of these problems that back-end developers used to go through are gone with Serverless.So, Serverless is building software without worrying about servers.
Serverless helps the user to build higher and modern level applications with the increase in speed, agility, and lowering the owner’s cost. Building a Serverless application means the developer doesn’t need to have to worry about operating or managing servers; instead, he can focus entirely on developing the core product i.e., the project he has been assigned. This reduces his effort, energy, and time. These all can later be utilized in building and developing the best quality products.
Benefits of Building Serverless Applications
- No Server Management – Since there is no physical server, therefore, the user doesn’t have to manage any.
- Flexible Scaling – Scaling of application is adjustable as per the capacity and has already been automated.
- Pay for Value – Users have to pay for what we use.
- Automated High Availability – Serverless offers automated fault tolerance and built-inn availability. User doesn’t have to worry about these capabilities because the applications have in-built services that take care of all these.
Some important Constrains for Building Serverless Applications
- The Serverless way requires a new way of thinking.
- New architectural patterns and styles are used in building the software as traditional patterns may not be suitable.
- Event-driven and distributed patterns work well in this model.
- The architectural design chosen might have to be refined.
How to Building Serverless Applications?
Suppose an Enterprise has a client on the right side and the developers on the left side, and in between these, the main thing happens.So basically, we write business logic and deploy it to the provider say, Amazon which encapsulates code units in the form of functions which is where the fast acronym came from or role as a service and so whenever a client request comes to your application , a notification gets to a service that is listening for clients requests after that the server try to locate the code that is responsible for answering the request. When it finds it, it loads it into a container, and then the code gets executed. The answer gets constructed and sent to the client.
The other aspect of Building Serverless Applications is that you get to have all the responsibilities done for you through back-end as service like authentication and routing etc. You may have heard of Amazon API gateway before these technologies belong to Serverless computing. They are considered as back- end services, and you can use them as per your advantages, this is Serverless in a nutshell.
Benefits of Enabling Serverless Architecture
- Reduces managing and maintain server-side work
- Reduces cost
- Reduce risk and increased efficiency
- No need to worry about security and updates
- Auto-scaling of resources
- Prototyping cycle and lead time has been significantly shorter
Overview of AWS Serverless Solutions
AWS Service comes down to offer different vital things.First, you should not have to think about any managing of servers i.e., no physical, no virtual, no containers, or anything that involves you thinking about an operating system or thinking about individual compute resources is something that you have to not think about when it comes to AWS Serverless.
AWS service should not scale with usage, so as requests come in, A.W.S. is going to take those requests and process them using a service product and respond as necessary.
User doesn’t have to pay for idle, there are number of stats that, out there in industry to talk about, how in most enterprises most of their I.T. resources are vacant 80% of the time, that is quite a lot of money being spent on funds that may or maybe never being used or being used very lightly and in the World of Serverless you don’t have to think about the capacity planning in the traditional way.
Overview of AWS Lambda
AWS lambda processes trillions of requests across hundreds of thousands of active customers every month. Lambda is currently available in all 18 A.W.S. regions and as a foundational service lambda launch in every new region that A.W.S. launches. A.W.S. has a number of customers that are using lambda to build highly available, scalable and secure services Thomson routers which processes 4000 requests per second for its product insights analytics platform i.e. finra , which performs half a trillion validation of stock trades daily for fraud and anomaly detection , who uses lambda and Amazon Kinesis to track a matrix of mobile matrix in real-time.
Customers are adopting lambda because running highly available large-scale systems is a lot of work. First, you need to ensure that your order has load balancing at every layer of your architecture.You do this, so you have redundancy in your architecture, but you also so that you can handle more traffic than a single set server able to serve.
When Enterprises plan to build new service, they need to prepare for, and provision for these load balancing layers between primarily architecture components, you also have to make sure you have these systems configured with appropriate routing rules, such that your load is distributed evenly.
Second on the point that a single server can serve, you need to support scaling up, so if you have more traffic than your current service layer can handle, you can continue to serve that traffic bit you also need to be able to scale down after the traffic peaks, so that you are not indefinitely over provisioned which of course is wasteful. When you plan to build a new service, you also need to prepare for and provision these auto-scaling layers to sit in front of your fleet, evaluate the capacity of your fleet, and scale up the traffic volume and stress on your server pool and then back down as peak traffic decreases.
Third continuing on the point of system failure. You need to consider both when a host fails but what about a complete breakdown of an entire data center or availability zone to this you need to instrument each of your services with health check based on fundamental service matrices and if the service shows is unhealthy, stop routing traffic to that host then you need to repeat to ensure you do this for every single system and service component that you build.
Lambda takes care of all your system administration and more helping developers to focus on business logic and writing code and not administering systems.
AWS Lambda Features
- Load Balancing
- Auto Scaling
- Handling Failures
- Preserving Security Isolation
- Managing Utilization
Overview of Lambda Architecture
Lambda Architecture is split into a control plane and the data plane.The control plane is where engineers and developers typically end up with interacting the lambda service. On that part of the system, we have a set of developers’ tools such as the lambda console, the CM, CLI, ID, and toolchains. Underneath those tools, there is a set of control plane APIs, and these are for configuration and resource management. When you create or uploads a function, you interoperate with these API’s and the resource management does the packaging up for code and ends up putting that up into the lambda service, and at this point, the data plane picks up.
Data Plane picks up – First Asynchronous it invokes and also systems like dynamo dB, Kinesis and S.Q.S., and a group of systems that work together, i.e., Polar’s state managers and Leasing Service and they work together to process those events. Those events that are processed through that system are then sent to synchronous invoke. In the synchronous invoke area of the system, there is a front-end, the counting service, the worker manager, the worker, and the placement service.
Front-end invoke – Responsible for orchestrating both synchronous and asynchronous invokes. Also, the first thing it does is authenticate the callers i.e., and it makes sure that only valid callers make it the function and call invoke.
Counting service – It is responsible for providing a region-wide view of customer concurrency to help enforce those set concurrency limits. It also keeps tracking the current concurrency of the function executing on the service. If it’s below the granted execution, it will automatically be given a performance, and if it hits the concurrency limit, it may or may not be throttled. A.W.S. has some intelligence that helps to make sure the user gets the full concurrency.It uses a quorum based protocol which is designed for high throughput and low latency of fewer than 1.5 milliseconds.
Worker Manager – The worker manager is responsible for tracking container idle and busy state and scheduling incoming and V.O.C. requests to the available containers. It handles the workflow steps around function invocation, including environment variable setup and computes metering it. One major key thing it does is it will optimize for the running of code on a warm sandbox.
Worker – It is an essential component of the system architecture.It is responsible for provisioning a secure environment for code execution. It creates and manages a collection of sandboxes. It sets limits on sandboxes such as the memory and CPU, which is available for function execution. It downloads customer code and mounts it for performance, and it also manages multiple language runtimes.It is also responsible for notifying the worker manager hen a sandbox invoke completes.
Placement Service – It is responsible for placing sandboxes on workers to maximize packing density without impacting the customer experience or code pack latency. It is the intelligence to help determine where we want to put a sandbox when we have function ready for execution. It also monitors worker health and decides as to win to mark a worker as unhealthy.
Building Serverless Applications on AWS
- Step 1 – Search for API gateway and open it.
- Step 2 – Click on Get Started, then select new API.
- Step 3 – Enter the details i.e., API name and description, and then click on create API.
Then the new window appears. Now you have to create the resource. For this, click on Actions and create the resource. Here, then fill the resource name and resource path as per your choice. (There is one thing in the window, i.e., ‘enable API gateway CORS. Enable that if you want to connect it through different domain). Then click on Create Resource
Step 4 – The resource has been created. Now the next thing is Create Method. Choose the method as per your choice.
Step 5 – The next thing is choosing the integration point of your method. For this mock. Now you can see the execution path (Method Request >Integration Request > Integration Response > Method Response).
Step 6 – Now select Integration Response. Expand the section. Then expand body mapping template. Then select any generate template. Then save this all.
Step 7 – Now, to test that API, you will need an API URL. To get this API URL, you have to deploy the API. For this, click on the action and then choose Deploy API.Fill the details and deploy them.
Step 8 – Now, you will find a URL on the screen. The URL is the root URL. You can directly not access the root URL. You have to get the HTTP method along with the URL. SO, put the method detail also with the URL.
Step 9 – NEXT search for lambda. There you will find different templates.
Step 10 – For now, use S.R.A.T.C.H. When you click on it, you will get a new window. Fill the details and click on create a function (you have to assign a role. You can create your role. For this, Go to I.A.M. and create role and give assign the access to your role).
Step 11 – Click on create function. This will create a new function. Just put the same JSON that you have created and configured before and click on save and test.
Step 12 – Now, the next thing you have to do is connect your lambda function with dynamo D.B. The first thing to do this includes the AWS SDK. Then create a document client to connect to dynamo D.B. Later create table name and specify the parameter. After making changes save and run your code.
Step 13 – Check all your parameters are correct.
Step 14 – Configure the test event and create the event.
Step 15 – Click on the test. You will see your data is successfully updated.
Step 16 – Now, go to Dynamo D.B. You will see that your data has been updated. It means that the lambda function that you have created is working fine.
Step 17 – The next step is to integrate this lambda function with API Gateway.
Step 18 – Go to API gateway console and change the integration type to Lambda Function.
Step 19 – Select the lambda region. Choose the place you have hosted the language function. Click on save. You will see specific messages, click ok.
Step 20 – Now, you need to deploy this API.
Step 21 – Click on the action and deploy API.
Step 22 – Now you can check this updated data from postman.
This means we are ready with two components i.e., API gateway and lambda function, and the integration of both.Now for processing further with HTML front end, and we need text boxes and host that HTML to S3 bucket. Then we will host the front end in a browser. And then we will test that from that front end. We will enter the details in those test boxes. Once we have updated, we should be able to see that data in Dynamo DB.
Approach Towards Serverless Solutions
With the growth of technology, Enterprises are moving towards Serverless Architecture to execute their functioning without worrying about data loss. To move towards Serverless, we recommend taking the following steps –