redhub

package module
v0.0.0-...-9cc3b7a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

REDHUB

RedHub

GoDoc FOSSA Status

High-performance RESP-Server multi-threaded framework, based on RawEpoll model.

  • Ultra high performance
  • Fully multi-threaded support
  • Low CPU resource consumption
  • Compatible with redis protocol
  • Create a Redis compatible server with RawEpoll model in Go

Installing

go get -u github.com/IceFireDB/redhub

Example

Here is a simple framework usage example,support the following redis commands:

  • SET key value
  • GET key
  • DEL key
  • PING
  • QUIT

You can run this example in terminal:

go run example/memory_kv/server.go

Benchmarks

Machine information
        OS : Debian Buster 10.6 64bit 
       CPU : 8 CPU cores
    Memory : 64.0 GiB

Go Version : go1.16.5 linux/amd64

【Redis-server5.0.3】 Single-threaded, no disk persistence.
$ ./redis-server --port 6380 --appendonly no
$ redis-benchmark -h 127.0.0.1 -p 6380 -n 50000000 -t set,get -c 512 -P 1024 -q
SET: 2306060.50 requests per second
GET: 3096742.25 requests per second
【Redis-server6.2.5】 Single-threaded, no disk persistence.
$ ./redis-server --port 6380 --appendonly no
$ redis-benchmark -h 127.0.0.1 -p 6380 -n 50000000 -t set,get -c 512 -P 1024 -q
SET: 2076325.75 requests per second
GET: 2652801.50 requests per second
【Redis-server6.2.5】 Multi-threaded, no disk persistence.
io-threads-do-reads yes
io-threads 8
$ ./redis-server redis.conf
$ redis-benchmark -h 127.0.0.1 -p 6379 -n 50000000 -t set,get -c 512 -P 1024 -q
SET: 1944692.88 requests per second
GET: 2375184.00 requests per second
【RedCon】 Multi-threaded, no disk persistence
$ go run example/clone.go
$ redis-benchmark -h 127.0.0.1 -p 6380 -n 50000000 -t set,get -c 512 -P 1024 -q
SET: 2332742.25 requests per second
GET: 14654162.00 requests per second
【RedHub】 Multi-threaded, no disk persistence
$ go run example/server.go
$ redis-benchmark -h 127.0.0.1 -p 6380 -n 50000000 -t set,get -c 512 -P 1024 -q
SET: 4087305.00 requests per second
GET: 16490765.00 requests per second

REDHUB Benchmarks

REDHUB Benchmarks

Disclaimers

When you use this software, you have agreed and stated that the author, maintainer and contributor of this software are not responsible for any risks, costs or problems you encounter. If you find a software defect or BUG, ​​please submit a patch to help improve it!

License

FOSSA Status

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(addr string, options Options, rh *redHub) error

func NewRedHub

func NewRedHub(
	onOpened func(c *Conn) (out []byte, action Action),
	onClosed func(c *Conn, err error) (action Action),
	handler func(cmd resp.Command, out []byte) ([]byte, Action),
) *redHub

Types

type Action

type Action int
const (
	None Action = iota
	Close
	Shutdown
)

type Conn

type Conn struct {
	gnet.Conn
	// contains filtered or unexported fields
}

func (*Conn) Flush

func (c *Conn) Flush() error

func (*Conn) ReadCommand

func (c *Conn) ReadCommand() (resp.Command, error)

func (*Conn) WriteArray

func (c *Conn) WriteArray(count int)

func (*Conn) WriteBulkString

func (c *Conn) WriteBulkString(bulk string)

func (*Conn) WriteError

func (c *Conn) WriteError(msg string)

func (*Conn) WriteInt

func (c *Conn) WriteInt(num int)

func (*Conn) WriteNull

func (c *Conn) WriteNull()

func (*Conn) WriteString

func (c *Conn) WriteString(str string)

type Options

type Options struct {
	Multicore        bool
	LockOSThread     bool
	ReadBufferCap    int
	LB               gnet.LoadBalancing
	NumEventLoop     int
	ReusePort        bool
	Ticker           bool
	TCPKeepAlive     int
	TCPNoDelay       gnet.TCPSocketOpt
	SocketRecvBuffer int
	SocketSendBuffer int
	TLSConfig        *tls.Config
}

type PubSub

type PubSub struct {
	// contains filtered or unexported fields
}

func NewPubSub

func NewPubSub() *PubSub

func (*PubSub) Psubscribe

func (ps *PubSub) Psubscribe(conn *Conn, channel string)

func (*PubSub) Publish

func (ps *PubSub) Publish(channel, message string) int

func (*PubSub) Subscribe

func (ps *PubSub) Subscribe(conn *Conn, channel string)

Directories

Path Synopsis
example
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL