In recent months, the word “serverless” has been appearing constantly in technology events and blogs. The promise of serverless is that some services or frameworks can dispense with worrying about servers, allowing you to just program without restrictions. Certainly, servers are still around; so what’s new in the current service infrastructure (IaaS) scenario? Lambda architectures are a new and interesting paradigm that divides projects into functions made available on various networks. It is the same concept that work teams present to convince their CTO to migrate to microservices.
Lambda architectures are powerful because they are able to facilitate the design of projects and make them more economical. Like microservices, Lambda architecture poses new challenges: service discovery, team education, resilience, multilingual and multicloud – to highlight some of them. Everything and everyone needs to be coordinated. In addition, Lambda functions fit perfectly into initial designs and trials. This article presents some of the tools that you can use in your next project.
Basically, Lambda-based architectures launch a computational unit for a service that does something. Obviously, if you need to manage hundreds of services by running steps that trigger each other, you can end up with flows similar to the one in Figure 1.
Figure 1. Complex logic flow
I will not dwell on this scenario, but I recommend that you consult experienced architects or read additional articles to learn how to manage technical deficiencies and how microservices can fight back.
For now, let’s focus on a new project – one that is easy, clean and effective. First, you must complete the basic lessons quickly – landing page, user management and payment – and then you can add more features. However, it is still too early to say which features will captivate the user to the point where they will pay for the product.
In short, the goal is to build a product safely by defining the blocks you can think of in isolation and only when you need them. Lambda functions can streamline this process and shorten product development time.
You probably do not need to migrate your entire professional infrastructure to Lambda architecture. You probably need fewer frameworks and more structures that just work. And you certainly need to define how to implement and maintain the hundreds of functions.
Whatever your stack, follow your intuition and start a new Lambda. Shut it down or replace it. You will have secure experimentation and quick iterations.
You may notice that this is similar to microservices, like Docker, but less mentally stressful. You can call it “nano” if you want to distinguish them, but I believe that containers and Lambdas are the detail of the implementations that take advantage of the same benefits of the architecture pattern described above. Lambdas perform a service as a function – and have the benefit of being shut down when they are no longer needed. This forces developers to think about smaller, stateless processing tasks. The code solves a problem with minimal side effects. Think of it as a combination of the good old UNIX philosophy and the latest functional trend. I’m suspicious, but I think it makes the developer happy, with a strong consensus from the community. And what does it take to do that?
Most frameworks and SaaS require you to expose the function with an object that can keep secrets as attributes of HTTP queries. Certainly, nothing will prevent you from having to write 2,000 lines of code between module.exports and the callback (), but that can lead to an anti-pattern.
And the ease of implementation can quickly make maintenance more difficult than dividing your problems into straightforward solutions:
Now you have some code that will take you to HTTP thanks to Fission. This requires that you have a setup at Kubernetes, but in the middle of 2018, who doesn’t have an “open-source system for deployments, scaling and automatic management of containerized applications?”. But seriously: if you don’t have time or don’t like to manage distributed clusters, you’re still in good company. Large hosting platforms offer competitive tools for adding Lambdas. You can be ready in just 30 seconds with Webtask 101 – without spending a single cent:
Once you have the chance to quickly start a project like React or Webpack, say, you realize that it is not something suffered – but it is still full of features:
And the Lambda function is now run periodically, which, as you know, is a very common use case.