Engineering

Engineering Deep Dive: Building Sub-100ms Search on Edge-Replicated SQLite

A technical look under the hood at how Bookmark It combines Next.js 15, Drizzle ORM, and Cloudflare D1 SQLite to achieve sub-100ms global query response times.

M
Melad Hani
Founder & Lead Architect
5 min read
Share:

Speed is not just a cosmetic feature for a bookmark manager—it is the foundation of user retention. If saving or searching a link takes more than 500 milliseconds, users will default to leaving dozens of tabs open instead.

The Central Database Bottleneck

Most traditional web apps deploy a single centralized PostgreSQL or MySQL instance in us-east-1. For a user in Tokyo or London, every query pays an unavoidable 150-250ms round-trip speed-of-light tax over WAN.

For Bookmark It, we designed an architecture where your data queries execute in the exact geographic region where your HTTP request lands.

Why SQLite at the Edge?

SQLite is the most battle-tested, lightweight SQL engine in history. When paired with distributed edge compute like Cloudflare D1 and Workers, queries execute in-process or over ultra-low latency local fibers.

Here is an example of how we index tags and timestamps in Drizzle schema for instant multi-tag intersections:

Code Referencetypescript
// schema/bookmarks.ts
export const bookmarks = sqliteTable(
  'bookmarks',
  {
    id: text('id').primaryKey(),
    userId: text('user_id').notNull(),
    url: text('url').notNull(),
    title: text('title').notNull(),
    isFavorite: integer('is_favorite', { mode: 'boolean' }).default(false),
    createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
  },
  (table) => ({
    userIdx: index('user_idx').on(table.userId),
    userCreatedIdx: index('user_created_idx').on(table.userId, table.createdAt),
  })
);

Zero Cold-Start Worker Execution

Because Cloudflare Workers execute on V8 isolates rather than traditional Docker containers or Node.js VM runtimes, cold starts are virtually non-existent (sub-5ms).

The result is a snappy, desktop-class web experience that feels instantaneous across all desktop and mobile browsers.

Tags:#Engineering#Cloudflare D1#SQLite#Next.js#Performance

Did you find this insightful?

Share this article with your developer or research circle.

Share:
M

Written by Melad Hani

Founder & Lead Architect

Building Bookmark It to give everyone a distraction-free, privacy-first personal web archive powered by modern edge architecture.

Continue Reading & Exploring

Ready for Fast, Private Bookmarking?

Start organizing your web bookmarks with sub-100ms edge speed today. 100% free and portable.