Jamstack and Serverless Architecture
Table of Contents
- How it Works
- Examples of Serverless Functions Used in Jamstack
In an era of internet buzzwords, it can be difficult to keep track of the latest technology trends and how they compare. In recent years, two of the most popular new technologies to emerge have been the Jamstack, and Serverless architecture.
Serverless architecture is closely related to the Jamstack, but is a separate and more expansive ecosystem unto itself. As the name implies, 'serverless' architecture essentially replaces the need for developers to manage a complicated backend by themselves. In reality, servers are of course still being used behind the scenes, but the backend cloud services they provide allow developers to skip having to setup or maintain their own servers.
How it Works
Typically, when a front-end application is built, developers will need to connect it to a backend system (usually built in Ruby-on-Rails, PHP, Node.js, or other backend languages). This backend will serve up functions needed to power the frontend, particularly when fetching data and for authorizing/authenticating requests.
In serverless architecture, these functions are handled automatically by the cloud service provider. The system resources are already set up and available, and can auto-scale with demand from the frontend. One of the main appeals of using serverless functions in this way, is that sudden spikes in traffic to your website will automatically be provision for by the serverless infrastructure. Moreover, you will only pay for the number of functions that are called, without having to pay for constant server uptime.
This functionality is key for running effective Jamstack projects. Frontend developers can focus on building out their application's UI, and the backend functionality is taken care of for them by the serverless systems.
One issue to be aware of is that on some cloud platforms unused serverless functions may be set to ‘idle’ and require a ‘cold start’ when used again, which can result in slightly slower reaction speeds. This issue does not occur if the application and its functions are being used regularly.
Examples of Serverless Functions Used in Jamstack
- Making API calls to fetch data server-side, before serving the static HTML files to the browser. While Jamstack is often associated with serving static sites from a CDN, it is possible to add dynamic functionality using serverless functions.
- Handling authorization. While it is possible to store JSON web tokens (JWTs) in the browser, it is still necessary to generate the bearer tokens server-side (they cannot be stored in the browser due to obvious security vulnerabilities). Rather than building out your own backend server for this, it can be handled by the host using serverless functions.
A great resource to check out for real examples of serverless functions used in the Jamstack can be found here.
Is Jamstack/Serverless Right for My Business?
Both of these technologies are well-established, and used by the largest enterprises in the world. However, whether or not they are suitable will depend on the requirements of a given project.
Serverless architecture is widely used, with platforms like AWS (Lambda functions) powering much of the Internet today. Companies that already have large amounts of internal server resources provisioned may not need to use such services; but the ease of use and low cost of using serverless functions makes it an attractive option, particularly for new projects or when building out a proof-of-concept.
Jamstack has more limited use cases, but has similar trade-offs. When building out complex applications with a lot of dynamic functionality, it may be better to lean more heavily on server-side functionality. Static pages rely more on the browser run-time environment, which is not always ideal. For fast, highly performant websites serving static content, Jamstack is an excellent choice.
Combining Serverless/Jamstack Projects with a Headless CMS
A good headless CMS will come with a lot of backend functionality built in, including access to serverless functions, and static hosting for Jamstack sites. While this also be achieved without a CMS, it usually makes sense to have an interface for content creators, marketers, and other non-technical stakeholders to make use of.
Kuroco, the enterprise headless CMS, was built with serverless architecture in mind, and can easily host Jamstack websites on our CDN. If you're looking for an enterprise grade solution to host your serverless and/or Jamstack projects, we hope you will give Kuroco a try!
You can get started today and test it out for free, or feel free to reach out to our customer support team if you have any questions!