DEV Community

Scofield Idehen
Scofield Idehen

Posted on • Originally published at blog.learnhub.africa

Serverless Function For Website

Maintaining servers took a lot of work for web developers. Still, the invention of the Serverless function has made it easy to host and maintain our site and allows developers to focus more on their code development.

Serverless Function

Serverless programming allows programmers to focus more on their coding skills and release software products faster, thereby benefiting from reducing infrastructure costs.

It is a single-purpose, programmatic feature of serverless computing that primarily manages servers or infrastructure.

There is this misconception that serverless programming is serverless. Meanwhile, they are still servers working somewhere, but the server's location is irrelevant to the developer.

Scalability is the main benefit of serverless computing; for instance, when your site scales up or down, it becomes less stressful for the developer to think about how to maintain their server, enabling the developer to focus more on its development. 

At the same time, the serverless function deals with a smooth experience when the product or application suddenly becomes popular.

In serverless functions, cloud providers set limits for maximum concurrency (the amount of time the system receives requests at a time) to reduce the run-time cost. 

Still, sometimes these limits can be changed and revoked based on developer/user requests.

Developers are only charged for the resources and processing power they use. There isn't any expense if the system is not being utilized. 

Along with other services, AWS (Amazon Web Services) offers a large free tier of 1M Lambda function requests per month.

AWS Lambda(Amazon Web Services) 

This event-driven serverless computing architecture, released in 2014, enables customers to run their applications without worrying about server administration. 

It enables code execution on practically any application or backend service without administration.

Serverless functions can be used in different cases like batch processing, streaming processing, web application, mobile application, and IoT(internet of things and ETL(extract-transform-load).

 Now more serverless functions are coming to light; some require a zero-configuration database and API-centric services. For the web, some are AWS Lambda, a serverless computing platform, Lambda Serverless, Google Cloud Functions, Microsoft Azure Functions, IBM Cloud Functions, and Alibaba Cloud Function Compute.

Website Serverless Function.

When working with the traditional architecture, this connection will be specified within the web application code such as PHP, Java, javascript, and Go.

Appling changes to your code, for instance, Form submission, involves changing the entire application. 

Only certain events can trigger serverless functions. For instance, placing an order online, Booking a ticket for a music concert, and signing up for a newsletter could activate a serverless function. 

The backend functionality is created with a single-purpose code module that is executed independently. They can be written in Java, Python, PowerShell, Ruby, and other commonly used programming languages. 

On the other hand, the serverless function allows you to develop the functionality, adding more purpose to every single code.

 It's deployed whereby providing 100% scalable environment management for your website code. 

The website doesn't have to know about it. The frontend code calls it endpoint directly whenever a user submits the form. 

The serverless function breaks down the entire operation into standalone units, using different tools and services to ensure that the codes are reachable. Eg of serverless AWS(Amazon Web Services) Lambda.

How It Execute An Event

Write a function: The programmer write a function that, when triggered, can perform a specific purpose. E.g. Form submission.

Defining an event: The developer will call an event whenever triggered. It gets it from a cloud-native service that will execute the function.

Trigger an Event: The user will Trigger the event with the click of a button then the action specified to that button will be executed.

Deploying and executing a function: If a function/event is not running, the cloud provider starts a new instance of the event being called.

Passing the result to the client: The result will be provided to the user that called the event.

Some interesting factors about this serverless function are-

It provides a good and fair pricing model, where the cost is execution-based, unlike traditional architecture that works on 24/7 server maintenance.
It is a business value; It lets developers focus more on what they do best, writing codes and improving their efficiency daily.
Its cost is low when compared with traditional architecture.
It helps in the management whenever your work is scaling up. Likewise, when your project scales down, It also manages your project. Its billing is based mainly on the amount of usage.

Some limitations are-

They have a cold start - it takes time to start up whenever a function is being called/invoked.
It does not maintain data.
One of its major drawbacks is how this app plays multiple ads.
Implementing serverless structures is very labour-intensive.
Site To Learn Serverless Function

Serverless functions can be learned from various platforms like Udemy, Coursera, Youtube, Pluralsight, edX, FrontendMaster(), Quiklabs, and other platforms around the globe.

Conclusion 

Going serverless will soon become the norm in web development, relieving developers of the stress of managing their sites and allowing them to focus more on auto-scaling and self-improvement.

Top comments (6)

Collapse
 
rickdelpo1 profile image
Rick Delpo

Well written, thanks!

these are the servers I recently got rid of by using AWS
1 AWS EC2 Windows Server - no need to host servers when Lambda will do
2 MySQL db Server - now using noSQL JSON uploaded to AWS S3
3 Java JVM - stopped using java entirely in favor of plain javascript
4 Tomcat Servlet Server - not doing java servlets anymore, replaced by AWS Lambda
5 Apache httpd Server - outsourced to an on line service

I replaced all above servers with AWS S3 and AWS Lambda - only 5 cents per mo now
plus 25 cents per mo to host my html on remote Apache Server.

check out my profile and articles for much more on how i accomplished Serverless
Thanks again !!

Collapse
 
scofieldidehen profile image
Scofield Idehen

wow, thats something, i will look into, thanks a lot.

Collapse
 
briannbates profile image
Brian Bates

Great article!

Collapse
 
scofieldidehen profile image
Scofield Idehen • Edited

Thanks for the feedback!!

Collapse
 
leonardpuettmann profile image
Leonard Püttmann

Cool article! Even though I think the name "serverless" is a bit missleading, I do love the concept behind it and I would agree when you say it is the future

Collapse
 
scofieldidehen profile image
Scofield Idehen

Oh i think it drives home the point, but i am excited you find the article exciting.