How should you host your app in 2024?
All posts

Common Serverless Runtime Limits

When does Coherence get useful instead of purely serverless functions, like those offered on Vercel/Netlify/CloudFlare? There are a few reasons why you might hit limits and want to go beyond their hosting, especially for backend APIs.
March 6, 2023

When does Coherence get useful instead of purely serverless functions, like those offered on Vercel/Netlify/CloudFlare? There are a few reasons why you might hit limits and need to go beyond their hosting, especially for backend APIs.

One set of limits is execution time limit on functions:

  • e.g 10 seconds on free on Vercel, 10 seconds on Netlify
  • You can pay to increase this on some platforms, for example the paid tier on Vercel is 60 seconds. This is still not enough for many real-world use cases, especially if you talk to 3rd party APIs from your code.

Another set of limits is the package, request size, or memory limit:

  • 50 MB total deployment size limit on Vercel serverless
  • 1024 MB memory limit on Vercel or Netlify serverless
  • 4.5 MB max request body size

In addition to serverless functions, some platforms like Vercel also offer edge functions. These have their own limits.

  • Edge functions are even more limited, e.g. 30s max timeout for all plans or 4 MB size limit even for enterprise plans. There are some caveats here such as that streaming responses can consume more time as long as they are actively sending data back to the client.

There are additional limits that apply to some applications, for example:

  • No outbound TCP connections, e.g. to redis. There are workarounds here, such as using a HTTP wrapped API via a provider like Upstash, but these mean that you're locked into a vendor's ecosystem instead of the open standard software itself.
  • No ability to connect to database resources in a VPC, must use public IP and open your database up to the internet. In addition to security risks, this is a performance bottleneck and a cost drawback

Coherence has no limits aside from the underlying limits on Cloud Run (GCP) or Fargate (AWS). With Coherence, you can easily deploy an application to your own AWS or GCP account using a container and remove the limits on slug/package size, memory, and execution time right away. You’ll still get the developer experience of branch previews and an intuitive UI that Vercel provides. These features might be useful for your application, for example if you are doing long-running jobs that process data or talk to external APIs where you don’t control the response speed. You might also want to use:

  • A database instance or redis instance in your VPC on the cloud provider, for example postgres or mysql
  • Separate worker tiers running with different machine types, for example using libraries like celery, sidekiq, or bee-queue
  • CI/CD with database migrations or seeding built in, similar to what Jenkins, Drone, CircleCI, gitlab CI, or GitHub Actions might provide
  • A Cloud IDE based on VSCode to develop your project, similar to what GitPod or GitHub Codespaces might be used for

Feel free to reach out with any questions if we can help you get started!