Skip to content

nirdosh17/go-service-with-duckdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go DuckDB API

A simple containerized Go API backed by DuckDB.

About

The service exposes GET http://localhost:8000/users/:id endpoint which returns user details from DuckDB running in persistent mode.

API response:

{
  "id": 1,
  "name": "Ken Adams",
  "email": "[email protected]",
  "joined_date": "2021-09-12T05:13:37Z"
}

The service uses go-duckdb pkg to interact with DuckDB C++ shared lib.

Running the API

1. Generate Test Data

# populates 100K records in duckdb
make seed

# with custom seed size
SEED_COUNT=200000 make seed

The seed command generates testdata/test.duckdb duckdb file necessary to run the service. It contains users table which has following columns:

id INTEGER
name VARCHAR
email VARCHAR
joined_date TIMESTAMP

2. Run Go Service

Normally:

make build
make run

As a docker container:

make docker.build
make docker.run

Load testing

wrk -t12 -c100 -d10s --latency http://127.0.0.1:8000/users/100

More about the load testing tool wrk.