An in-memory, key-value store HTTP API service

This is an in-memory key-value store HTTP API service, with the following endpoints:

  • /get/{key} : GET method. Returns the value of a previously set key.

  • /set : POST method. Sets key/value pair(s) in the key-value store. Body can accept multiple key-value pairs in a single request, for example - {"abc-1":1,"abc-2":2,"xyz-1":"three","xyz-2":4}.

  • /search : GET method. Searches for keys using prefix or suffix filters.

Assume you have the following keys in the store: abc-1, abc-2, xyz-1, xyz-2.
- /search?prefix=abc would return abc-1 and abc-2.
- /search?suffix=-1 would return abc-1 and xyz-1.

  • / : GET method. Returns all the key-value pairs in the in-memory store. Also useful for readiness probes and load testing.

How to run (as binary)

  • Fork and clone this repository.
  • Run go build -o kvstore.
  • Run the ./kvstore binary (the service will run on port 8080).

(Alternatively, you can simply run go build and run the resulting ./kv binary, or give another name to it.)

How to build and use Docker image

  • Fork and clone this repository.
  • Build the Docker image with the command
docker build -t <image-name>:<tag-name> .

For example, you can run docker build -t kv-store:latest .

  • After building the image, run it with the command
docker run -d -p 8080:8080 <image-name>

(The service will run on port 8080 in this case.)

Alternatively, you can simply pull the docker image (the latest image tag is recommended) from the Dockerhub repository.

Running the service on a k3d cluster

  • Fork and clone this repository (or simply copy the deploy.yaml file and save it).
  • Create a new k3d cluster with k3d cluster create kvstore -p "8080:80@loadbalancer".
  • Run kubectl apply -f deploy.yaml. (k3s deploys traefik as the default ingress controller. Coupled with the port mapping, this does not require any further configuration for running the service on k3d. The deployment and configuration have not been tested for other Kubernetes distributions.)

(Please run the service on port 8080, as the deployment file has readiness probe configured for the port.)

Testing for zero downtime

Testing was done via the CLI tool for Fortio. Just before the deployment image was updated from importhuman/kv-store to use a slightly different image (importhuman/kv-store:1.3), the following command was run:

fortio load -a -c 50 -qps 500 -t 180s "localhost:8080"

Status 200 response was obtained for 100% of the requests.

The complete logs can be found in logs.json.

Known issues while running on Kubernetes

  • The deployment creates 3 replicas of the key-value store service. These replicas do not have a shared memory, and so have different key-value pair stores, instead of all replicas utilizing a common store.
  • Key-value pairs are not stored anywhere outside the pod, thus, while requests can be made consistently without downtime, any stored values are lost when a pod restarts or goes down.
Owner
Ujjwal Goyal
Currently working on buildpacks and linkerd | Open source enthusiast | Self taught programmer | Actively looking for opportunities
Ujjwal Goyal
Similar Resources

Proc-peepin - Capture process cpu and memory and send it off to influx

proc-peepin Capture process cpu and memory and send it off to influx Running loc

Feb 13, 2022

Windows Store Installer for VS Code

vscode-winsta11er This repo contains the code for a simple Go-based installer for the new Windows store. Releases To create a release, create and push

Dec 9, 2022

Simple distributed kv-store using ABD algorithm.

Distributed-kv-store Simple distributed kv-store using ABD algorithm. API GET /key Get value by key. 302 = found key. PUT /key Put key with value. 201

Dec 14, 2021

A server for TurboRepo Remote Cache to store cache artefacts in Google Cloud Storage or Amazon S3

Tapico Turborepo Remote Cache This is an implementation of Vercel's Turborepo Remote Cache API endpoints used by the turborepo CLI command. This solut

Dec 13, 2022

Store - Read and write data structures

Store - Read and write data structures Store provides the ability to write the data structures to a file and read from a file in the Go programming la

Jan 3, 2022

[TOOL, CLI] - Filter and examine Go type structures, interfaces and their transitive dependencies and relationships. Export structural types as TypeScript value object or bare type representations.

typex Examine Go types and their transitive dependencies. Export results as TypeScript value objects (or types) declaration. Installation go get -u gi

Dec 6, 2022

An unified key management system to make life easier.

An unified key management system to make life easier.

Safebox An unified key management system to make life easier. The main goal of safebox is to make key backup easier with single main key to derive the

Nov 15, 2022

Mildly performant age public key bruteforcer

vanity-age Mildly performant age vanity public key brute-forcer.

Aug 30, 2021

Reads Sets and Deletes a key from Redis cache

Reads Sets and Deletes a key from Redis cache

Nov 2, 2021
Implement a toy in-memory store information service for a delivery company

Implement a toy in-memory store information service for a delivery company

Nov 22, 2021
In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.
In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.

In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.

May 19, 2022
Export the private key from a Swarm json key file

exportSwarmKey Currently it is a pain in the A** to export bee key in to metamask as they are not compatible. This programe will export the private ke

Oct 2, 2022
HTTP service to generate PDF from Json requests

pdfgen HTTP service to generate PDF from Json requests Install and run The recommended method is to use the docker container by mounting your template

Dec 2, 2022
An HTTP service for customizing import path of your Go packages.

Go Packages A self-host HTTP service that allow customizing your Go package import paths. Features Reports. Badges. I18N. Preview I launch up a free H

Nov 27, 2022
A Simple Bank Web Service implemented in Go, HTTP & GRPC, PostgreSQL, Docker, Kubernetes, GitHub Actions CI

simple-bank Based on this Backend Master Class by TECH SCHOOL: https://youtube.com/playlist?list=PLy_6D98if3ULEtXtNSY_2qN21VCKgoQAE Requirements Insta

Dec 9, 2021
:chart_with_upwards_trend: Monitors Go MemStats + System stats such as Memory, Swap and CPU and sends via UDP anywhere you want for logging etc...

Package stats Package stats allows for gathering of statistics regarding your Go application and system it is running on and sent them via UDP to a se

Nov 10, 2022
Helps exercise your memory by giving you random tokens and poems to memorize.

memory-enhancer Helps exercise your memory by giving you random tokens and poems to memorize. Using Every day when you first open your terminal you wi

Nov 9, 2021
A profiling tool to peek and profile the memory or cpu usage of a process
A profiling tool to peek and profile the memory or cpu usage of a process

Peekprof Get the CPU and Memory usage of a single process, monitor it live, and extract it in CSV and HTML. Get the best out of your optimizations. Us

Jan 9, 2023
Safira - In memory of my dog Safira
Safira - In memory of my dog Safira

In memory of my dog Safira. The tool safira replaces pattern_offset.rb and patte

Jan 11, 2022