Skip to content

Commit

Permalink
Remove redis v2 engine due to the performance issue (#224)
Browse files Browse the repository at this point in the history
We allowed to use DB as the secondary storage(Spanner) for increasing
the capacity of Redis, but we don't think it's a good propse after
benchmarking(about 1000 QPS for 2 Spanner instances). So we decided to
remove this experimental feature now.
  • Loading branch information
git-hulk committed Jul 9, 2024
1 parent b1bb578 commit d55c106
Show file tree
Hide file tree
Showing 47 changed files with 18 additions and 4,985 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ teardown:
@bash scripts/teardown.sh

test:
- cd scripts/spanner && docker-compose up --force-recreate -d && cd ../..
@sh scripts/run-test.sh
- cd scripts/spanner && docker-compose down && cd ../..

lint:
@rm -rf lint.log
Expand Down
13 changes: 0 additions & 13 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ type RedisConf struct {
MasterName string
Version string
SentinelPassword string

EnableSecondaryStorage bool

// number of seconds. when job's delay second is greater than pumpStorageThresh,
// it will be written to storage if enabled
SecondaryStorageThresholdSeconds int64
}

func (c *Config) HasSecondaryStorage() bool {
return c.SecondaryStorage != nil
}

func (rc *RedisConf) validate() error {
Expand All @@ -104,9 +94,6 @@ func (rc *RedisConf) validate() error {
if rc.DB < 0 {
return errors.New("the pool db must be greater than 0 or equal to 0")
}
if rc.EnableSecondaryStorage && rc.SecondaryStorageThresholdSeconds < minSecondaryStorageThresholdSeconds {
return errors.New("write to secondary storage threshold required at least 1 hour")
}
return nil
}

Expand Down
6 changes: 0 additions & 6 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,4 @@ func TestRedisConfig_Validate(t *testing.T) {
if err := conf.validate(); err != nil {
t.Fatalf("no error was expected, but got %v", err)
}

conf.EnableSecondaryStorage = true
conf.SecondaryStorageThresholdSeconds = 10
if err := conf.validate(); err == nil {
t.Fatalf("validate addr error was expected, but got nil")
}
}
30 changes: 0 additions & 30 deletions engine/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import (
"encoding/binary"
"encoding/json"
"errors"
"google.golang.org/protobuf/proto"

"github.com/bitleak/lmstfy/engine/model"
"github.com/bitleak/lmstfy/uuid"
)

Expand Down Expand Up @@ -51,26 +49,6 @@ type jobImpl struct {
_elapsedMS int64
}

// NewJobFromReq creates a new job with its body and attributes being marshalled
func NewJobFromReq(req *CreateJobReq) Job {
if req.ID == "" {
req.ID = uuid.GenUniqueJobIDWithDelay(req.Delay)
}
jobData, err := marshalJobBody(req.Body, req.Attributes)
if err != nil {
return &jobImpl{}
}
return &jobImpl{
namespace: req.Namespace,
queue: req.Queue,
id: req.ID,
body: jobData,
ttl: req.TTL,
delay: req.Delay,
tries: req.Tries,
}
}

// NOTE: there is a trick in this factory, the delay is embedded in the jobID.
// By doing this we can delete the job that's located in hourly AOF, by placing
// a tombstone record in that AOF.
Expand Down Expand Up @@ -229,11 +207,3 @@ func (j *jobImpl) MarshalText() (text []byte, err error) {
func (j *jobImpl) GetDelayHour() uint16 {
return 0
}

func marshalJobBody(body []byte, attrs map[string]string) ([]byte, error) {
job := &model.JobData{
Data: body,
Attributes: attrs,
}
return proto.Marshal(job)
}
162 changes: 0 additions & 162 deletions engine/model/job.pb.go

This file was deleted.

10 changes: 0 additions & 10 deletions engine/redis_v2/constant.go

This file was deleted.

Loading

0 comments on commit d55c106

Please sign in to comment.