Hot Database Connections for Serverless Functions

Preamble — Problems to Solve

Firing up new Serverless containers — a.k.a. cold starts — takes from one to several seconds (time varies per platform). To eliminate such cost/latency, Serverless frameworks keep already started containers warm for a period of time (duration varies per provider).

Serverless functions might make database access. Although less costly than starting new Serverless container, database connection creation and tear down may cost tens or even hundreds of milliseconds depending on your DBMS environment. This problem is exacerbated with Serverless functions that are are short-lived and cannot afford such cost on every call.