Skip to content

Commit

Permalink
feat(ray): utilize redis as deployment config cache (#722)
Browse files Browse the repository at this point in the history
Because

- avoid constant disk IO ops

This commit

- utilize redis as deployment config cache
- write config to persistent disk only on program exit
  • Loading branch information
heiruwu authored Dec 16, 2024
1 parent 2bf8ea0 commit da20daf
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 44 deletions.
6 changes: 3 additions & 3 deletions cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ func main() {
publicGrpcS := grpc.NewServer(grpcServerOpts...)
reflection.Register(publicGrpcS)

rayService := ray.NewRay()
defer rayService.Close()

mgmtPublicServiceClient, mgmtPublicServiceClientConn := external.InitMgmtPublicServiceClient(ctx)
defer mgmtPublicServiceClientConn.Close()

Expand All @@ -175,6 +172,9 @@ func main() {
redisClient := redis.NewClient(&config.Config.Cache.Redis.RedisOptions)
defer redisClient.Close()

rayService := ray.NewRay(redisClient)
defer rayService.Close()

temporalTracingInterceptor, err := opentelemetry.NewTracingInterceptor(opentelemetry.TracerOptions{
Tracer: otel.Tracer("temporal-tracer"),
TextMapPropagator: propagator,
Expand Down
6 changes: 3 additions & 3 deletions cmd/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ func main() {
db := database.GetSharedConnection()
defer database.Close(db)

rayService := ray.NewRay()
defer rayService.Close()

redisClient := redis.NewClient(&config.Config.Cache.Redis.RedisOptions)
defer redisClient.Close()

rayService := ray.NewRay(redisClient)
defer rayService.Close()

temporalTracingInterceptor, err := opentelemetry.NewTracingInterceptor(opentelemetry.TracerOptions{
Tracer: otel.Tracer("temporal-tracer"),
TextMapPropagator: b3.New(b3.WithInjectEncoding(b3.B3MultipleHeader)),
Expand Down
119 changes: 107 additions & 12 deletions pkg/mock/ray_mock.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions pkg/ray/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ var SupportedAcceleratorTypeMemory = map[string]int{
}

const (
// Ray redis key
RayDeploymentKey = "model_deployment_config"

// Ray deployment env variables
EnvIsTestModel = "RAY_IS_TEST_MODEL"
EnvMemory = "RAY_MEMORY"
EnvTotalVRAM = "RAY_TOTAL_VRAM"
Expand All @@ -291,8 +295,5 @@ const (
EnvNumOfCPUs = "RAY_NUM_OF_CPUS"
EnvNumOfMinReplicas = "RAY_NUM_OF_MIN_REPLICAS"
EnvNumOfMaxReplicas = "RAY_NUM_OF_MAX_REPLICAS"
)

const (
DummyModelPrefix = "dummy-"
DummyModelPrefix = "dummy-"
)
Loading

0 comments on commit da20daf

Please sign in to comment.