Skip to content

Using Cloudflare Worker + Queues + R2 Storage + Cache to implement a small scale to zero search system that is reasonably fast and cheap.

License

Notifications You must be signed in to change notification settings

TM9657/serverless-cloudflare-search

Repository files navigation

🔍🌩️ Serverless Search on Cloudflare

Using Cloudflare Worker + Queues + R2 Storage + Cache to implement a small scale to zero search system that is reasonably fast and cheap. Benchmark welcome for performance measure :)

Endpoints:

  • search - public
  • index - access restricted (see config)

Cached Index saved in R2. Cache read on search request. Queue -> Writing Index (Batch size and concurrency 0)

Features

  • Generic Index support
  • Multiple Parallel indices per endpoint (infinite)
  • Good performance for smaller Datasets (up to 50k documents (I guess? Feel free to create a better benchmark!))

Setup

create a .env file in your root with the following parameter:

CLOUDFLARE_AUTH_KEY=
CLOUDFLARE_AUTH_EMAIL=
  • pnpm install ➡️ populates your config with a strong secret
  • pnpm run initialize ➡️ creates the bucket and queue
  • npx turbo build ➡️ publishes your workers to cloudflare

"Benchmark"

This project is meant for smaller datasets (cheap serverless search). For a movie dataset with 17920 documents a search takes 800ms first time (downloading the index from R2), after that we get a worker performance of 50-60ms per search.

Todo

  • Alternative Flexsearch implementation (Problems with export / import and types)
  • Investigate Durable Object for faster initial response
  • Add serverless setup for AWS deployment
  • Add CLI tool

Provided by TM9657 GmbH with ❤️

Check out some of our products:

  • Kwirk.io (Text Editor with AI integration, privacy focus and offline support)

About

Using Cloudflare Worker + Queues + R2 Storage + Cache to implement a small scale to zero search system that is reasonably fast and cheap.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published