Senthilsweb
Search
Blog

DuckDB Data API Enhanced with Serverless Redis Cache for Better Edge Performance

I've noticed that my DuckDB Studio app on Vercel's hobby plan often crashes due to function timeouts. The hobby plan's 10-second function limit and limited memory make it hard to run data-heavy apps.

I’ve noted concerns and personally observed that my duckdb-studio application, hosted on Vercel using the hobby plan, frequently crashes due to function timeouts. Developing on Vercel’s hobby plan poses significant challenges, such as a maximum function invocation time of 10 seconds and limited memory, which impact the performance of data-intensive applications. To mitigate these limitations, I introduced serverless Redis/Upstash cache into our duckdb-data-api, the backend engine powering the duckdb-studio.

Solution: Serverless Redis Caching with Upstash

To tackle these challenges, I integrated Upstash Redis a.k.a. Vercel-kv, to provide a robust caching solution. The caching strategy involves:

::list{type=“success”}

  • Middleware Strategy: Implemented caching logic through FastAPI middleware using the decorator design pattern. This centralizes cache management and enhances efficiency.
  • Cache Key Naming Convention: Our cache keys follow a structured format to ensure clarity and prevent conflicts, incorporating the request type and endpoint. ::

See the enhanced performance in action

::list{type=“success”}

  • My blog www.senthilsweb.com is powered by Motherduck/DuckDB via the duckdb-data-api hosted on Vercel edge, demonstrating rapid content delivery and data processing capabilities.
  • duckdb-studio: https://duckdb-studio.vercel.app This platform, leveraging our enhanced API, showcases the speed and efficiency of operations powered by our caching strategy, offering a real-time example of how data can be managed and presented swiftly. ::

Github projects

https://github.com/senthilsweb/duckdb_data_api

https://github.com/senthilsweb/duckdb-studio


Vercel Hobby Plan Limitations

The hobby plan on Vercel provides a developmental platform but includes restrictions that can hinder data-heavy applications:

::list{type=“success”}

  • Function Timeout: Functions are limited to a runtime of 10 seconds.
  • Memory Limitation: Available RAM is often insufficient for processing large datasets.
  • The KV Storage Cap: The plan offers a maximum of 256 MB for cache storage. ::
TechnologySoftware DevelopmentWeb DesignVue.jsNuxt.jsOpen SourceWeb DevelopmentLow Code Platform