TechBy Jerico S. Dela Cruz
Convenience with Serverless
Forty years ago the Internet was rising without anyone knowing on what power it could bring to the world. It connected machines with one another no matter the distance. Ten years after we see documents getting inside this Internet giving birth to the World Wide Web. Around these years, HTML is being formalized as a standard document for the web. Another ten years and we start hearing about cloud computing. Amazon Web Services (AWS) released the first cloud service available to the public six years after.
With technology growing rapidly, we should expect several tools for cloud services for ease of management for that service. AWS, for example, provides several services that users can now interact with. Such services can be function or backend as a service, to name a few. With AWS and its various tools, deployment and scaling of cloud services is doable. But what if we could add a layer of manageability for these services?
What Serverless Is
Serverless has servers somewhere just as wireless network has wires somewhere. Serverless is best described as “Servers but with less management” you’re letting automation do it’s magic. This allows even the developers to deploy their own code without much deep background with cloud services. Serverless is both Function as a Service (FaaS) and Backend as a Service (BaaS).
Getting Technical
To install Serverless, you should already have Node JS and NPM installed on your machine. Once done, you should run the following command:
After installation, you should be able to use Serverless taking only one line of command for installation. You can confirm installation by running either of the commands below.
What is Serverless #1
Serverless is FaaS as it uses services similar to Google Function and AWS Lambda. With AWS Lambda, automatically takes your configuration inside your Yaml files then builds them in AWS API Gateway.
What is Serverless #2
Serverless, as a backend service, enables developers easy integration with third party services. For example, to be able to use AWS’ Simple Email Service (SES), you just have to use AWS SDK framework (available with Serverless on project initialization) and call the SES function putting in the correct parameters.
Say “Hello World” Serverless
To be able to try the power of Serverless, we should do a standard “Hello World” program. With that, we can start with using templates already available in Serverless.
The command should create a directory complete with all the tools and files for you to start with. The most notable are the function handler handler.js and serverless configuration = serverless.yml.
The handler file will contain the hello-world function definition that should simply output a simple message. Take note that it is a requirement that you pass your data in the manner written below (i.e. message should be stringified from JSON with status code and proper headers).
Inside the serverless configuration file are details about the provider (e.g. AWS or Google) and the environment that will be used (e.g. Python or Node JS). Third party service will also be defined in this file.
Once everything is prepared, you should run the following command to start the magic.
Serverless should output the link that will trigger the function above. I have been using the framework for almost a month and I have been introduced to the AWS stack just as I was exploring with the Serverless framework. Truly, Serverless works wonders as you are deploying your code using one command.
What’s important when handling Serverless is when to use what service because that will help you getting through with connecting your third party services to your current architecture.
You are now on your way to deploying your functions at ease. It is important to take note that the functions will autoscale as the team in Serverless promised. This means that monitoring and scaling manually will now be lessened. This gives developers more power to deploy their functions without the usual infrastructure concerns.
“Serverless systems are still in their infancy. There will be many advances in the field over the coming years and it will be fascinating to see how they fit into our architectural toolkit.“ MARTIN FOWLER in Serverless Architectures.
References
- https://martinfowler.com/articles/serverless.html
