Git Product home page Git Product logo

rpc's Introduction

rpc database

Go Doc Go Report Card

About

The in-memory database with caching, written in Golang.

Install

go get github.com/dpasiukevich/rpc

To run in the container, clone this repo and run:

docker-compose up

go run client.go -addr=127.0.0.1:3050

Features

  • data types: string, list, hash
  • data clustering using consistent hashing
  • LRU caching
  • persistence to disk
  • tls protocol

Usage

Running the server and client:

  • cd server/
  • go run server.go
  • cd client/
  • go run client.go

Package consist of 3 entities:

  • proxy server
  • data server
  • client

Proxy server distributes the keys between data servers. So if client is working through the proxy server, all the requests will be distributes across the cluster.

Proxy server get the list of data servers from file (by default: cluster/servers.json). It dynamically disables routing to the data server, if it's removed from servers.json file. Proxy server uses connection pool to serve the requsts faster.

Also client can connect to the data server directly.

Data server options:

  -addr string
    	Address to listen. (default "127.0.0.1:9443")
  -backup string
    	Path to file with backup in gob format. Used to restore previous state of server.
  -cert string
    	Server certificate filepath. (default "server.crt")
  -key string
    	Server key filepath. (default "server.key")

Proxy server options:

  -addr string
    	Address to listen. (default "127.0.0.1:9443")
  -cert string
    	Server certificate filepath. (default "server.crt")
  -conns int
      Number of connections to keep for each data server (default 10)
  -key string
    	Server key filepath. (default "server.key")
  -servers string
      Path to file with the list of data servers (default "servers.json")

Client options:

  -addr string
    	Address to listen/connect. (default "127.0.0.1:9443")

Available commands:

  • set key value
  • get key
  • lpush my_list value
  • lset my_list 0 value
  • lget my_list 0
  • hset my_hash key value
  • hget my_hash key
  • size
  • keys
  • remove key
  • ttl key 30

Benchmarks

BenchmarkGet-4     	20000000	        76.2 ns/op
BenchmarkSet-4     	 2000000	       565 ns/op
BenchmarkLPush-4   	 5000000	       305 ns/op
BenchmarkLGet-4    	20000000	        93.5 ns/op
BenchmarkHSet-4    	20000000	       105 ns/op
BenchmarkHGet-4    	20000000	        83.6 ns/op

rpc's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.