Product docs and API reference are now on Akamai TechDocs.
Search product docs.
Search for “” in product docs.
Search API reference.
Search for “” in API reference.
Search Results
 results matching 
 results
No Results
Filters
How to Architect a Serverless Application
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Code, a set of instructions to a computer packaged as an application, only serves a purpose when there is a computer (server) to interact with. A serverless application is not an application that seemingly runs without any hardware. It’s an architecture based on functions that work similarly to microservices. It utilizes modern programming strategies that employ a group of functions triggered in response to events, rather than a monolithic application, to optimize server performance. In this case, developers can disregard hardware and focus exclusively on creating the necessary functions to create an application. This guide explains how all of this works. In many cases, serverless applications require less work and produce better results, at a lower cost than other solutions.
What Is Serverless?
Applications cannot operate independently without proper support. Typically, developers work with a team consisting of a DBA, devops, or a system administrator to manage an application. However, with serverless architecture, developers focus only on the code for their application and do not worry about the server or hardware. Serverless applications provide functionality like automatic scaling, provisioning, built-in service integration, automated configuration, and high-availability without any additional effort from the developer. The developer’s only concern is the code used to create the application. This kind of application significantly reduces costs by automatically scaling both up and down to handle the current load with minimal human interaction.
A serverless application can support traditional desktop applications, back-end services, and serverless web applications. In comparison to microservices, serverless applications represent a method of running an application, while microservices represent a method of designing an application. Unlike microservices, serverless applications don’t run continuously, require an event to begin execution, and individual functions perform only one task. Microservice can run continuously and support multiple tasks or functions. The primary advantage a serverless application over a microservice is that it activates when an event occurs and stops once the task is complete. The costs of running a serverless application are therefore less than a microservice in situations where an application is expected to receive frequent usage spikes.
A robust application environment can be created by combining serverless applications and microservices. Each technology has its own particular use, and relying on each when appropriate can result in a flexible and cost-effective solution.
What Are Serverless Applications Used For?
Due to the low startup costs and ability to handle lightweight applications, serverless applications are ideal for startups creating mobile and web application. Here are some other common use cases:
- Situations where traffic tends to be unpredictable.
- Internet of Things (IoT) applications, because both IoT and serverless applications are event based.
- Application that see frequent and significant changes, as serverless applications combine well with Continuous Integration and Continuous Delivery (CI/CD).
- Applications that can be broken down into individual functions, and then combined to create a Packaged Business Capability (PBC).
How Is Building a Serverless App Different Than a Typical App?
Developing serverless applications requires a slightly different process than a monolithic application or microservice, partly because you’re dependent on the hosting service. Developer’s need to understand the hosting service’s Application Programming Interface (API) to create the application and configure each event and function accordingly. Because serverless applications are so dependent on a particular hosting service, they come with some risk of vendor lock-in.
Testing and debugging serverless applications require special attention. Ironically, the problem comes from the very technology that saves time, effort, and money in other ways. Because functions only execute when triggered by an event, intermittent errors can be difficult to find without a thorough testing and debugging strategy. Additionally, connectivity issues between serverless applications, configuration problems, or other factors can make it difficult to track down the root cause of a problem.
Performance is also a crucial consideration when designing a serverless application. Depending on the hosting service, the application can be cached for a specific period of time after it stops running. This enables a quick startup if another event triggers the function before the cache is cleared. However, if the cache is cleared, there could be a delay while the server reloads the application. Even with the best planning, performance can be uneven.
A serverless application requires an event to trigger it in the form of a message. In this case, the problem is that the message may contain special legal or other handling requirements, which makes sending the information problematic. These messaging issues can extend into transactional requirements because built-in latency often makes transactions hard to track. Proper logging is essential to ensure that a transaction has actually occurred, however, this can also slow down the application.
Considering the Serverless Application Process
There’s a process to follow when architecting a serverless application, whether the resulting software represents back-end services, front-end services, or both. This process differs from working with monolithic applications, microservices, Packaged Business Capabilities (PBCs) , or other software development patterns. The idea is to break a software requirement down into smaller pieces until it’s possible to describe a each individual piece very simply.
Define individual services that perform specific tasks.
Define individual functions that perform one and only one task, to make up the services. Build a collection of functions that define each element of a service in detail, and in the most basic way possible. It should not be possible to break a task down any further than the function level. While lambda functions are most common, any language works if the service provider supports it.
Define events that trigger the functions. Remember that serverless applications work on the premise that a function starts, performs a task, and then stops.
Create configuration files that describe each function, including function name, script name, function environment, resources required for execution, at least on event that causes the function to run. Optionally, include the packaging used to bundle the function and resources together in a single, easily installed file.
Create a configuration provider file that describes how the function interacts with the framework supporting the serverless application. This file should describe the framework environment and indicate the stage of the application, such as “development” or “production”.
Create a service configuration file that details the provider file, function files, and any plugins required for the service. Plugins are specialized software that extend the functionality provided by the framework environment, scripting solution, or other elements that make up the service. The service configuration file can also contain details about authentication, authorization, and environmental concerns that affect the service as a whole.
Using Serverless Applications Versus Microservices
When architecting a solution that includes serverless applications, it’s important to have an understanding of different approaches to working with code. It’s essential to know the strengths and weaknesses of various solution models and determine if a combination of models results in the best implementation.
What Are Microservices?
Keep the differences between microservices and serverless applications in mind as you consider architecting a solution based on one, or the other, or both. As previously mentioned, microservices are essentially a method of designing an application, rather than a method of deciding how to run the application. Microservices are often employed in these use cases:
- Applications that require scalability.
- Big applications that manage large amounts of data in various ways.
- Migration of legacy applications from a monolithic architecture to a microservice architecture.
- Situations in which an organization supports multiple applications and needs to use components from one application in another.
When considering a microservice architecture, there are certain advantages to consider, such as:
- Scalability, as each microservice is independent and can be scaled separately using techniques such as data partitioning and multiple instances to solve performance problems.
- Reliability, because if one microservice goes down, it’s easy to use another instead.
- Platform independence, as microservices can connect to different platforms.
- Ease of experimentation, since different scenarios can be tried without bringing the entire application down.
- Team autonomy, because each microservice is its own codebase and has its own data store that doesn’t rely on other microservices.
However, microservices do present some drawbacks in comparison to serverless applications, including:
- High startup costs due to the need to carefully architect connectivity between microservices.
- Difficulty in testing the entire solution, although testing individual microservices is easier.
- Complex debugging processes because the source of a problem can’t be determined until all logs are examined.
- Security issues because microservices are prone to misconfiguration.
What Are Back-End Services?
Back-end services are responsible for making an application function. Back-end services typically include load balancers, database managers, business logic services, and services that perform Create, Read, Update, and Delete (CRUD) operations on data. Back-end services also include message queues for storing requests and event managers. The latter are especially important for serverless applications because events trigger the functions.
It’s essential to understand a back-end service since it lacks a user interface and it doesn’t interact directly with the user. Depending on the service provided, a serverless application can provide perfect support for back-end services, as a front-end service (e.g. user interface element) can make a request to the back end, which performs the task, then stops until another event occurs.
What Are Front-End Services?
Front-end services handle the user interface, date presentation and validation, and other aspects that focus on the user experience. A front-end service may also provide a query API, such as a REST API . This allows third-party applications to interact with back-end services without a user interface. Additionally, a front-end service manages various facets of an application, such as obtaining credentials to be authenticated by the back-end services. The back end also tells the front end what a particular actor is authorized to do. Serverless applications are well-suited for certain elements of front-end services because they typically spend significant time waiting for user input. Using a serverless application reduces costs significantly because there are no expenses for inactivity. When the user is ready to interact with the application, clicking a button creates an event that triggers a function in the serverless application. Here, payment for processing time is measured in milliseconds rather than minutes.
Conclusion
Serverless applications offer developers a cost-effective solution for quick application development without worrying about hardware. Serverless applications and microservices are not mutually exclusive. In fact, it often pays to combine them in large applications to leverage the best of both technologies. It’s essential to remember that serverless applications start, run, and stop, so performance often suffers as a result. Microservices, on the other hand, are designed to run for long periods of time, sacrificing low cost for higher performance.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on