Skip to main content
  1. Posts/

Zeit - Functions as a Service

·528 words·3 mins·

Update 2020: Zeit has rebranded to Vercel. The now command and zeit.co URLs referenced below correspond to the platform’s state in 2019.

Let me introduce you to this amazing service called zeit.co AKA ZEIT NOW.

I currently use it with another free online service called MicroBadger, a service I use to trigger custom Docker builds after a base image such as alpine has been updated. This allows all my personal projects to be on the latest base image, potentially improving performance and security.

The Microservice sends a POST request to a function hosted on ZEIT NOW, and that function runs a bunch of tasks: invoking new builds of personal projects that depend on that image, grabbing changelists, and sending all that information to Slack.

I won’t show you how to do that, but I’ll show you how to get started with a full CI/CD pipeline.


ZEIT NOW is self-described as a All-in-one: Static and JAMstack deployment, Serverless Functions, and Global CDN.

In this post, I will be focusing on the serverless functions aspect as it is the most unique offering I know of. Serverless functions are not new. AWS Lambda has been doing it for a few years now, but the utility of Zeit NOW for me is derived from the fact that I did not have to enter any credit card information to get started.

Let’s go over the main limits of the (Hobby) free-tier:

2020-01-01HobbyProEnterprise
Deployments (per day)1002000Custom
Serverless Functions per Deployment1224Custom
Serverless Functions per Month160640Custom
Serverless Function Duration (Seconds)1060900
Deployments created from CLI per week20002000Custom
Team members per Team-10Custom

But let’s also remember the fair-use policy:

Examples of Fair UseNever Fair Use
Jamstack sites and appsProxies and VPNs
FrontendsMedia hosting for hot-linking
SPAsScrapers
Functions that query DBs or APIsCrypto Mining
Blogs, e-commerce, marketingCPU-intensive APIs (e.g.: Machine Learning)

  1. Let’s get started, install the zeit/now-cli.

  2. Clone/Fork my repository containing the example codebase sgama/demo-zeit-now.

  3. Import this project through the ZEIT web portal.

  4. Login to the now cli:

now login
  1. Run and deploy with the CLI:
/demo-zeit-now$ now
Now CLI 18.0.0
? Set up and deploy “/mnt/c/Vcs/demo-zeit-now”? [Y/n] y
? Which scope do you want to deploy to? MyUser
? Link to existing project? [y/N] n
? What’s your project’s name? demo-zeit-now
? In which directory is your code located? ./
�🔗  Linked to myuser/demo-zeit-now (created .no
�🔍  Inspect: https://zeit.co/myuser/demo-zeit-now/abc12cdef [1s]
✅  Production: https://demo-zeit-now.now.sh [19s]
�📝  Deployed to production. Run `now --prod` to overwrite later (https://zeit.ink/1A).
�💡  To change the domain or build command, go to https://zeit.co/myuser/demo-zeit-now/settings
Dashboard
Dashboard
  • Add the following to your repository’s secrets for CI/CD here: https://github.com/$YOUR_USER/$YOUR_REPO/settings/secrets
ORG_IDjq -r '.orgId' .now/project.json
PROJECT_IDjq -r '.projectId' .now/project.json
ZEIT_TOKENGet one from https://zeit.co/account/tokens
  • Uncomment the contents of .github/workflows/main.yml

  • Push your code and view the CI/CD pipeline run: https://github.com/$YOUR_USER/$YOUR_REPO/actions


Now you can visit the following URLs:

  • https:/$YOUR_REPO.now.sh/src/nodejs
  • https:/$YOUR_REPO.now.sh/src/python

I’ll let you figure the rest out, but with this repo, you will have a fully integrated continuous integration and continuous delivery system deploying functions for free.

Related