Infrastructure & Integrations
Serverless and edge functions: where the work fits, not everywhere
Where each kind of work fits
What to watch for
01
The first-request wait
After a quiet spell
A function that hasn't run for a while takes longer to answer the first time. Fine for a notice, noticeable on a page.
02
Time limits
Long work gets stopped
Functions are stopped after a set time. Anything longer belongs on a worker.
03
Database connections
Many short visitors
Hundreds of functions each opening a connection can overwhelm a database. Pooling has to be planned.
04
Scattered code
A hundred small pieces
Rules split across many functions drift apart. Shared rules stay in the backend; functions call it.
05
Cost at volume
Cheap when quiet, not always when busy
Steady heavy work often costs less on an always-on server.
One payment notice, handled
Payment provider · invoice INV-2301 paid
- done
Notice arrives
the function starts
- done
Checked
really from the payment provider, signature valid
- done
Seen before?
no; recorded once by its notice ID
- done
Invoice marked paid
through the backend, the one place that rule lives
- done
Answered
“received”, so the provider doesn't send it again
Paid in the office app within seconds; a repeated notice would change nothing.
A function for everything, or functions where they fit
A function for everything
- 01Every feature its own function
- 02Long jobs split to fit the time limit
- 03Business rules copied between functions
- 04The database struggling with connections
The system is everywhere and nowhere, and nobody can see how it fits together.
Functions where they fit
- 01One backend for the rules and records
- 02Functions for short, bursty work that calls it
- 03Edge code for tiny decisions near the visitor
- 04Workers for long jobs
Each piece runs where it's cheapest and simplest to run.
What functions sit between
In
Out
Worth using when the work is short, bursty or near the visitor
Good fit
- Other systems send you notices at unpredictable times.
- Visitors need a fast decision before the page loads.
- Traffic is quiet most of the day with occasional spikes.
Not the right fit
- Long-running jobs. They belong on workers.
- A backend that's busy all day. An always-on server is simpler and often cheaper.
Questions about serverless and edge functions
Is serverless cheaper?
For work that's quiet most of the time, usually. For steady, heavy work, an always-on server often costs less. We look at how your work actually arrives before choosing.
Does serverless mean there are no servers?
No. The hosting provider runs the servers and starts your code when it's needed. You don't manage the machines, but they're there.
Will this lock us in to one hosting provider?
Some edge and function features are specific to a provider. We keep business rules in ordinary code in the backend, so the parts that would need rewriting to move are small.
Can our whole app be serverless?
Small apps often can. As an app grows, the busy backend and long jobs usually move to always-on servers and workers, with functions kept for what suits them.