Demystifying serverless deployments with Zeit Now
Chris Kipp
Work for Visma connect making qualified information exchange tooling primarily in Scala and JS
Studied international relations, but decided to learn programming and switched careers
A function is a unit of code that is often defined by its role within a greater code structure. Specifically, a function contains a unit of code that works on various inputs, many of which are variables, and produces concrete results involving changes to variable values or actual operations based on the inputs.
f(x) = x + 2
f(3) = 5
f(4) = 6
Technopedia
{ name here }-as-a-Service
PAAS SAAS IPAAS FAASÂ
Cloud infrastructure providers typically give us access to several layers of abstraction that map to the traditional counterparts:
Set of computers
Zeit
Cluster
Computer
VM Instance
Process
Container
Thread
Function
'use strict'
module.exports = (req, res) => {
if (req.headers.authorization !== process.env.WAKA_FETCH_AUTH) {
res.writeHead(401, { 'Content-Type': 'text/plain' })
res.end('Authentication required.')
} else {
makeRequest()
.then(response => {
console.info(response)
res.writeHead(300, { 'Content-Type': 'text/plain' })
res.end(response)
})
.catch(err => {
console.error(err)
res.writeHead(400, { 'Content-Type': 'text/plain' })
res.end('Sorry something went wrong with your request.')
})
}
}
Zeit
Typically, when you spawn a server, worker, container, or process, the requests end up all combined into one process, spawned across several cores and computers
Zeit
Serverless functions handle an incoming request, run some computation, and responds. If another request comes to the same path, the system will automatically spawn a new isolated function, thus scaling automatically.
At times you may have multiple different parts of your ecosystem that each do independent things and could even potentially be written in different languages, frameworks, etc
┌ thing3.go Ready [33s]
└── λ thing3.go (4.69MB) [bru1]
┌ thing2.js Ready [17s]
└── λ thing2.js (2.62KB) [bru1]
┌ thing1.js Ready [17s]
└── λ thing1.js (2.62KB) [bru1]
┌ thing4.php Ready [17s]
└── λ thing4.php (2.42MB) [bru1]
> Success! Deployment ready [41s]