25

Serverless architecture: When to use this approach and what benefits it gives

 5 years ago
source link: https://www.tuicool.com/articles/hit/fqEV3ir
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Serverless has been one of the hot topics of software development in recent years. It appeared in the late 2014 and is growing in popularity. This technology has been in the market for around 5 years, which means it’s mature enough and has a big potential for the future.

iUnE3mr.png!web

Let's find out what serverless architecture is, benefits of serverless for your business, and where it should or should not be used.

What serverless architecture is

Serverless architecture covers two different but overlapping areas: backend as a service and functions as a service.

Backend as a service

Serverless was first used to describe applications that significantly or fully incorporate third-party cloud-hosted applications and services, to manage server-side logic and state.

These are typically “rich client” applications—think single-page web apps, or mobile apps—that use the vast ecosystem of cloud-accessible databases (e.g., Parse, Firebase), authentication services (e.g., Auth0, AWS Cognito), and so on. These types of services have been previously described as “(Mobile) Backend as a Service" (BaaS).

2IZZzqZ.jpg!web

Functions as a service

Serverless can also mean applications where server-side logic is still written by the application developer, but, unlike traditional architectures, it’s run in stateless compute containers that are event-triggered and fully managed by a third party.

One way to think of this is “Functions as a Service”(FaaS). AWS Lambda is one of the most popular implementations of a Functions-as-a-Service platforms at present, but there are many others, too.

In comparison with BaaS, FaaS can look like this:

b2AZBnJ.jpg!web

In this post, we will focus more on FaaS implementation of serverless.

Market share and popularity of serverless architecture

The global serverless architecture market size was valued at 3.14 billion USD in 2017 according to the Grand View Research .

The things don't stop at this point and the market size of serverless is expected to grow.

aMru63M.png!web

Serverless architecture allows organizations to focus more on their services, spark their processes with agility and reduce the costs for development, testing, and deployment time.

Let's dive deeper into the main concept of serverless architecture and its benefits for your business.

The main idea behind serverless architecture

While it is called ServerLESS, it, of course, still requires computing power which resides on some hardware.

The “less” part actually refers to a reduced amount of effort required by developers to publish, maintain and scale application servers.

The main idea behind the serverless is to reduce time, complexity and, ultimately, cost of running a reliable and scalable server for a modern application.

The main concept of FaaS is that application logic (or part of it) can be expressed as a set of functions run independently only when the need arises.

Advantages of serverless architecture

Benefits for developers

  • No need to run a server 24/7

Serverless recognizes the fact the ordinary servers usually are using only 5-15% of their computing power and allows to use just as much power as necessary. So there is no need to have a server running 24/7 non-stop when we can only run some code when we need it in particular. This allows FaaS providers to charge only for the time the function was running . Moreover, scaling is super easy and is done automatically - if you have a lot of requests - you just have to run more functions.

  • No need to figure out all the infrastructure pitfalls

As the building blocks of your serveress application are simple functions there is no need to figure out all the infrastructure pitfalls - just write code and ship it. That is, of course, to some extent only - you still need to figure out a lot of stuff about how to communicate between functions and clients, keep state and work with the database.

  • Focus on a core product

The modularity allows to have more product-like approach to developing new features - certain developers or team can more easily take charge of a particular feature and launch it without being restricted by the need to deploy entire server. But with greater power comes greater responsibility so there should be strong communication between teams to prevent conflict situations.

To wrap it up, here are the main benefits of Serverless FaaS approach for developers:

yMreEry.jpg!web

Benefits for business owners

The utilization of Serverless FaaS approach also provides a lot of economic perks for both startups and enterprises. So let’s find out how businesses can benefit from serverless architecture.

  • Lower costs on running a server

Common practices include deploying redundant active services or providing hot standby services that can take over if the primary service fails. Each such service would historically increase hosting costs, requiring careful capacity and disaster recovery planning.

With AWS Lambda, where application developers are no longer in control of the server process, usage is billed only when an application actively processes events, not when it is waiting. This, in effect, means that application idle time is free, which reduces the costs for running a server.

  • Utilizing specialized services for different tasks

Another benefit is that writing pieces of the application as separate independent pieces of logic allows utilizing specialized services for performing different tasks. It results in the overall economic effect. For example, using AWS Cognito to authorize client requests directly could shift the authorization cost from paying once per session to once for each monthly active user.

  • Сlient access to backend resources

It is perfectly acceptable, even expected, to allow client applications to directly access resources traditionally considered ‘back-end’.

For example, end-user devices can be allowed to directly connect to separate database endpoint for posting analytics. The FaaS platform’s requirement for distributed request-level authorization causes developers to remove components from their design, which would traditionally be required to perform the role of a gatekeeper. However, here they would only make our system more complex and costly to operate.

Let’s wrap up the main benefits of serverless for your business.

y2uM3ii.jpg!web

When to use serverless architecture

Considering the benefits of serverless approach here are some types of applications it suits the best:

  • High latency background tasks like multimedia or data processing

  • Client-heavy applications where most of the logic can be moved to the client

  • Applications with an unpredictable amount of server load

  • Fast-growing and rapidly changing applications that should scale at once and be able to change features rapidly

When serverless architecture is not the right choice

Each technology has its drawbacks and serverless is not an exception. Here are the main cases when it’s better not to go serverless.

  • Entirely Serverless application is not suitable for real-time applications that use WebSockets because FaaS functions have limited lifetime

  • After some time of being idle, function will require to go through a cold start which can take up to a few seconds. So if you need a quick response from your server you'll have to either invoke your functions manually to keep them warm or avoid using Serverless only approach

  • Different FaaS providers may differ in some particularities of using their services which will make the switch to another provider troublesome. There are solutions like serverless framework that are provider agnostic but they inevitably cut corners on facilitation of all the strength of a particular Provider in favor of greater generality.

Some of the serverless architecture drawbacks can be mitigated by a hybrid approach - using a relatively small server that will take care of the non-stop activity, while outsourcing time and process consuming tasks to serverless.

Wrapping Up

Serverless approach gives perks for both developers and product owners. The first can free their mind off infrastructure concerns and focus on the core product. Product owners, in their turn, spend less on running a server, have better service scalability, faster time to market, and potential to scale . In the next article, we will reveal how we use serverless approach atApiko and provide real-life examples. Stay tuned!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK