šŸ“™ Understanding Neuronal Networks presale is now open - 20% off discount!

Introduction to Javascript Serverless – functions as a service

The serverless term is quite misleading. There is still a server involved. However, when using a serverless service, such as Cloudflare, you don’t have to worry about managing that server.

A serverless function runs only when needed. You pay just for the memory, storage CPUs, and data bandwidth used.

With serverless a new machine is spawned up when needed and shut down after. The service provider will also handle all the required infrastructure scaling when your app has a traffic spike.

This comes as an alternative to a traditional server provider, where you rent a given virtual or real machine. That machine is always up and running and you pay a fixed price for it.

Javascript serverless functions are stateless. For example:

let user = 'JS Craft'

const updateUser = newUser => user = newUser

const getUser = () => user

The getUser() function will ALWAYS return 'JS Craft', no matter how many times the updateUser() function was called.

Given that the serverless machines are shut down after the function runs, any session data is lost, therefore the value of user is reset.

Even if the serverless functions are stateless, you can still use databases to persist data. All serverless providers will give you access to a persistence layer.

Next let’s see how to make your first call to a Javascript serverless function with with Cloudflare and vanilla Javascript.

šŸ“– Neural Networks from Scratch - Presale

I'm writing a book about the timeless foundational concepts of neural networks for JavaScript developers. Go from if-else to weights and biases by building tiny AI models from scratch!

šŸ“– Neural Networks from Scratch - Presale

I'm writing a book about the timeless foundational concepts of neural networks for JavaScript developers. Go from if-else to weights and biases by building tiny AI models from scratch!


Leave a Reply

Your email address will not be published. Required fields are marked *