Hello, In this article I will discuss about the serverless computing and microservices. This article will only contain about the introduction of aws lambda and its benefits from server computing perspective. In my next article I will create a serverless function using .NET Core and C#.
What is serverless ?
Since years we have been writing code which we deploy on the server to be invoked by the client. It is a very rare scenario where we do not have a server code to be called. This puts an extra effort of maintaining the server.This is going to change in near future.
The benefit of going server less is that there is no need for us to maintain a virtual machine. All the operations like computing, storing, and networking are taken care by the serverless platform. The serverless platform gives us the flexibility to focus only on the coding side of the project without taking care of the nitty gritty of managing and scaling the servers.
The servers in this architecture are highly available and scalable. Going forward you will see a .NET core code written in C# being deployed to the AWS lambda and invoked by the API code events. AWS provides the computing infrastructure and a runtime environment for javascript, java, phython and .NET Core(C#). A serverless application can consist of multiple functions executed on the need basis.
These serverless functions are developed for event driven architectures. A function can be triggered by event source and it acts as a glue when orchestrating multiple serverless functions forming a system. Apart from triggering the serverless lambda code using events we can manually execute the code.
Dividing the application into smaller functions is necessary when following a serverless approach. This is based on the microservice architecture.
One important point which we need to keep in mind is that serverless functions are also stateless. It is generally not possible to persist data between two executions of the same functions, neither in memory nor on disk. We need to find alternative ways to store data on Amazon like DynamoDB, a no sql DB, Amazon S3 or object store.
Following is the generic list of event triggers by which we can in invoke a lambda functions
- incoming HTTP request.
- Changing data stored in a DB or object storage.
- Incoming message.
- Publishing a task to a topic or real-time data stream.
- Scheduled event.
For more specific events you can navigate to this link.
The lambda functions can be invoked in two ways.
- Synchronous Model – In this model the client will keep waiting for the response to come back. The best example of this model is invoking a function using HTTP request.
- Asynchronous Model – The caller will not wait until the function returns.
Recently with the release of the .NET core platform, aws lambda has also started supporting .NET core(C#) along with other languages.
Why .NET core
- Platform independent
- Better performance due to modularized design and low memory usage
- Open source. Build and validated for Amazon linux.
To start with you need to download the AWS SDK for .NET if you conveniently want to program in visual studio. We can also develop the aws lamda with commands.
Stay tuned as in my next article I will create an “Hello World” lambda function in .NET Core(C#) from scratch and deploy it. Later we will call the function from client.
Conclusion
In this article I have discussed about the serverless architecture with aws lambda. And how we can utilize the compute power of aws serverless architecture, no administration , pay as you use and just upload code to use it.
References:
aws documentation – https://aws.amazon.com/documentation/lambda/
Leave a Reply