Technical document

Architecture of a Low-Cost Vector Search & Data Analysis Platform Built with DuckDB, LanceDB, Cloud Run, and GCS

This article explains the architectural design, application boundaries, and implementation considerations for building a low-cost and practical vector search and data analysis platform. This is achieved by using GCS as the sole persistence layer for Parquet and Lance formats, and executing DuckDB and LanceDB on-demand on Cloud Run, thereby eliminating fixed costs during idle times.
AI Development34 minPublication Date November 21, 2026Update date November 21, 2026
Thumbnail for Architecture of a Low-Cost Vector Search & Data Analysis Platform Built with DuckDB, LanceDB, Cloud Run, and GCS

Summary

Key points of this document

  • Background and Challenges: Why Traditional Always-On Databases Are Expensive
  • Technology Stack and Selection Rationale: Separation of Storage and Compute
  • Overall Architecture and Query Execution Flow

Overview

Architecture of a Low-Cost Vector Search & Data Analysis Platform Built with DuckDB, LanceDB, Cloud Run, and GCS

When building large-scale search or analysis platforms, choosing managed vector databases or always-on data warehouses (DWH) can incur fixed costs of tens of thousands of yen per month, even during off-peak hours. This article explains the design principles of a low-cost and practical architecture that completely separates storage and compute, using Google Cloud Storage (GCS) as the sole persistence layer, and executing DuckDB and LanceDB on-demand on Cloud Run.


Background and Challenges: Why Traditional Always-On Databases Are Expensive

Traditional always-on databases and managed vector databases employ mechanisms to continuously allocate memory and SSDs to achieve low-latency responses. However, for business systems, internal tools, or services in the validation phase with fluctuating usage, this "always-on" operation significantly degrades cost efficiency.

Structure of Always-On Memory/Disk Billing

In vector search, it is common to keep Approximate Nearest Neighbor (ANN) indexes (e.g., HNSW) resident in memory. Consequently, as data volume and vector dimensionality increase, the required memory capacity grows, and**instance billing for 24 hours, 365 days, even if the number of queries per day is only a few hundred.**occurs. Similarly, for always-on RDBs and DWHs, CPU and storage allocation costs during idle times accumulate as fixed costs.

Mismatch in Small to Medium-Scale, Intermittent Access Environments

For applications such as internal knowledge search (RAG), ad-hoc aggregation of daily reports, and cross-sectional search of regional information or business documents, there are many periods, such as nights and holidays, when access is zero. In such**maintaining an always-on cluster for intermittent workloads is over-investment,**and a pay-as-you-go architecture commensurate with the scale of usage is required.


Technology Stack and Selection Rationale: Separation of Storage and Compute

In this configuration, the data persistence layer is consolidated into object storage, and the compute layer responsible for search and aggregation is separated into request-driven serverless containers.

Technology ElementRoleSelection Reason and Cost Characteristics
GCS (Google Cloud Storage)Sole Source of Truth (SSOT)Can store Parquet / Lance files at a cost of a few yen per GB per month. Ensures redundancy and durability at low cost.
Cloud RunServerless Compute NodeContainers are launched only upon request, and during idle times, instances scale to 0, eliminating billing.
DuckDBIn-process SQL Analytics EngineCan partially retrieve only necessary columns/row groups from Parquet on GCS via HTTP Range Request, enabling high-speed aggregation and joining.
LanceDBServerless Vector SearchUsing the Lance format, vector indexes (e.g., IVF-PQ) and metadata can be directly placed on GCS, enabling ANN search without a dedicated server.

Significance of Using GCS as the Sole Source of Truth (SSOT)

By not having local disks on database servers or managed storage, and by treating only files on GCS as the Single Source of Truth,**compute nodes can be made completely stateless.**Backup and environment replication are also completed with bucket-level copies, minimizing infrastructure operational load.

Division of Roles Between DuckDB and LanceDB

Aggregation, filtering, and joining of structured data are handled by DuckDB, while similarity search for embedding vectors generated from unstructured text and images is handled by LanceDB. Both operate within the application process (in-process) without resident server processes and can natively handle Apache Arrow, a common columnar memory format, Apache Arrow, allowing them to collaborate without inter-process communication overhead.


Overall Architecture and Query Execution Flow

This section illustrates a configuration with a clear separation between the write path for data generation/updates and the read path for processing search/analysis requests.

Overall System Diagram (Separation of Batch Writes and On-Demand Reads)

Loading diagram...

Writes are limited to a single writer, such as a batch job, and atomically placed on GCS, while Cloud Run services behave as read-only. This eliminates the need for distributed locks or complex transaction management.

Query Execution Sequence (Cache and Partial Retrieval Flow)

Loading diagram...

Instead of downloading the entire file, data is retrieved in Lance format partition units and Parquet row group units. Partial retrieval via HTTP Range RequestThis allows for small transfer amounts and memory consumption per query, even if several GBs of data are stored in GCS.


Cost Comparison and Application Boundaries

We will outline the differences in cost structure between traditional resident configurations and this configuration, as well as the application boundaries based on system requirements.

Comparison of Cost Structure and Features

Comparison PointTraditional Configuration (Resident Vector DB + DWH)This Configuration (Cloud Run + GCS + DuckDB/LanceDB)Selection Criteria
Idle CostConstant instance billing occurs (tens of thousands of yen/month~)0 yen when minimum instances are set to 0This configuration is overwhelmingly advantageous if access patterns are spiky
Storage Unit PriceManaged SSD / Dedicated storage unit priceGCS Standard Storage (several yen per GB)Long-term storage costs for large volumes of data can be minimized
Latency CharacteristicsStable at several milliseconds to tens of millisecondsTens to hundreds of milliseconds when warm, several seconds when coldSufficiently practical with this configuration if strict sub-10ms response is not required
Concurrent WritesSupports high-frequency parallel UPSERTsAssumes batch bulk updates/appendsDifferentiate based on the presence of real-time high-frequency updates
Operability and MaintainabilityRequires version upgrades, capacity monitoring, and scaling adjustmentsEasy to manage with only stateless containers and GCSThis configuration is advantageous for long-term operation with a small team

Application Boundaries (Suitable Cases / Unsuitable Cases)

Evaluation AxisConditions where this configuration is suitableConditions where this configuration is unsuitable (consider resident type)
Data ScaleTens of thousands to tens of millions of records (several GBs to several hundreds of GBs)Large-scale datasets exceeding billions of records
Query Frequency (QPS)Intermittent access ~ internal/business use of several QPSHigh-load services handling tens to hundreds of QPS constantly
Update PatternDaily, hourly, or event-driven batch updatesReal-time UPSERTs hundreds of times per second are required
Tolerable Latency200ms to several seconds (initial cold start acceptable)Strict SLA of always less than 10ms to 50ms is required

Implementation Policy and Design Considerations

To achieve both stable performance and low cost in actual operation, the design of write/read separation, cache utilization, and Arrow integration is crucial.

1. Separation of Write and Read Responsibilities (Conflict Avoidance)

Object storage does not provide fine-grained row locks or distributed transactions like traditional RDBs. Simultaneous writes to Lance or Parquet on GCS from multiple Cloud Run instances can cause metadata conflicts and file corruption.

Therefore,**data updates are centralized to a single writer (e.g., Cloud Run Jobs)**and designed to atomically switch using versioned prefixes (e.g., gs://bucket/datasets/v20261121/) or Lance's transaction features. The Cloud Run service on the read side focuses solely on referencing the latest committed version, thereby structurally eliminating read/write conflicts.

2. Strategies to mitigate cold starts and network latency

In a serverless environment, cold starts immediately after instance launch and network round-trip time (RTT) to GCS significantly impact response speed. Combining the following measures can ensure practical response times.

  • Leveraging the /tmp in-memory file system: Cloud Run's /tmp is expanded in memory, so caching lightweight metadata or hot index fragments to /tmp will speed up subsequent searches. However, it is essential to set an upper limit for the cache size to avoid exceeding the memory allocation limit.
  • File size and partition design: Parquet files should be around 100MB to 500MB each, with row groups appropriately partitioned and stored. If tens of thousands of excessively small files are generated, the number of LIST and GET API calls to GCS will increase, leading to disadvantages in both latency and API billing.
  • Memory allocation and concurrency adjustment: Since DuckDB and LanceDB perform parallel operations in-process, allocating at least 2GiB to 4GiB of memory and 2 vCPUs or more to Cloud Run ensures stability. Additionally, setting the concurrency per instance too high can easily lead to OOM (Out of Memory) errors during parallel queries, so it's effective to limit it to around 4 to 16 depending on the workload.
  • Trade-off between minimum instances 0 and 1: If you want to completely eliminate idle costs, set the minimum number of instances to 0. On the other hand, if you only want to avoid cold starts during business hours, set the minimum number of instances to 1, or it is practical to send lightweight warm-up requests via Cloud Scheduler before business hours.

3. Arrow Zero-Copy Integration between DuckDB and LanceDB

In many cases, for the top candidates found by vector search, there is a need to perform subsequent operations such as access permission checks, filtering by business attributes, or aggregation of amounts and counts. LanceDB search results can be passed directly to DuckDB as a PyArrow / Arrow Table without memory copying, allowing for concise description of hybrid processing like the following.

import duckdb
import lancedb

# 1. Connect to a Lance dataset on GCS and perform vector search
db = lancedb.connect("gs://example-analytics-bucket/lance-store")
table = db.open_table("documents")

# Get the approximate nearest neighbor search results as an Arrow Table (top 50)
vector_hits_arrow = (
    table.search(query_embedding)
    .limit(50)
    .to_arrow()
)

# 2. Join with Parquet on GCS using DuckDB, then filter permissions and aggregate
con = duckdb.connect()
con.execute("INSTALL httpfs; LOAD httpfs;")

# An Arrow Table can be directly referenced from DuckDB SQL without copying
result = con.execute("""
    SELECT
        v.doc_id,
        v._distance AS similarity_score,
        m.category,
        m.updated_at
    FROM vector_hits_arrow AS v
    JOIN read_parquet('gs://example-analytics-bucket/parquet/metadata/*.parquet') AS m
      ON v.doc_id = m.doc_id
    WHERE m.department_code = $dept
      AND m.is_archived = false
    ORDER BY v._distance ASC
    LIMIT 10
""", {"dept": "sales"}).fetchall()

In this way, advanced filtering and aggregation can be completed within the same process, without setting up a separate SQL engine on a different server outside the vector search engine.


Limitations, caveats, and verification points

This architecture is not a panacea, and it is necessary to understand its limitations and points to verify before adoption.

Applicable limitations and caveats

  • Unsuitable for high-frequency real-time updates: It is not suitable for requirements where records are added/updated (UPSERT) at a rate of tens to hundreds per second, and immediate reflection in search results is desired. This is because a large number of small files would be generated, and compaction (file merging) processes would not be able to keep up.
  • Incompatible with strict low-latency SLAs: If scale-to-zero is enabled, cold starts will incur a delay of approximately 2 to 5 seconds due to instance startup and initial metadata loading from GCS. This is unsuitable for real-time APIs requiring responses within 10ms at all times.
  • GCS API call billing and egress: Accessing a large number of fragmented objects per query may result in Class A / Class B operation charges (API request charges) becoming more prominent than storage capacity charges. It is essential to always place Cloud Run and the GCS bucket in the same region to avoid inter-region egress charges.

Verification points to be performed before introduction

Verification PointMetrics/Criteria to CheckVerification Method
Cold start timeTime from first request to response completion (within acceptable range)Actual measurement after leaving with minimum instances 0 for a certain period
Memory usage and OOM resiliencePeak memory usage during concurrent request load (target: 70% of limit or less)Load testing with expected concurrency and Cloud Monitoring observation
GCS API calls and transfer volumeNumber of GCS requests and bytes retrieved per queryProfiling in a cache-free state and checking billing breakdown
Zero downtime during batch updatesNo read errors during new index version deploymentConnectivity testing with continuous queries parallel to batch execution

Summary: Criteria for Deciding on Adoption

The design combining DuckDB and LanceDB with Cloud Run + GCS“minimizing fixed costs through complete separation of storage and compute”is an architecture based on a clear objective. If you are unsure whether to apply it to your project, please use the following criteria to decide.

  1. Do you want to reduce idle costs?: If you don't have 24/7 constant access and want to bring fixed costs for nights and holidays close to zero, this is a strong option.
  2. Can updates be batch-centric and acceptable?: If daily/hourly data reflection or asynchronous jobs during document registration are sufficient, it can be safely operated with a single-writer configuration.
  3. Can an initial delay of hundreds of milliseconds to several seconds be tolerated?: For uses where humans operate and check results, such as internal business tools, analytical dashboards, or RAG searches, there are no practical impediments.

If these three conditions are met, you can build a foundation combining SQL analysis and vector search at a much lower running cost than contracting and maintaining a constantly running database. Conversely, in areas requiring hundreds of concurrent updates per second or constant sub-10ms responses, choosing a dedicated, constantly running database from the outset will ultimately lead to more stable operations.

Technical documents

We will continue to increase technical documentation.

We will continue to organize our thoughts on AI, cloud, business app development, requirements definition, and operational design into documents.

Go to technical documentation list