Skip to content

Commit 76e3297

Browse files
EXPEbdodlaBhargav Dodla
andauthored
fix: Add support for Read key batching for Redis. Also default read batch size to 100 for Redis/Valkey (#304)
Co-authored-by: Bhargav Dodla <bdodla@expediagroup.com>
1 parent e574ae5 commit 76e3297

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

go/internal/feast/onlinestore/egvalkeyonlinestore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func NewValkeyOnlineStore(project string, config *registry.RepoConfig, onlineSto
171171
// Parse read batch size
172172
var readBatchSize float64
173173
if readBatchSizeJsonValue, ok := onlineStoreConfig["read_batch_size"]; !ok {
174-
readBatchSize = -1.0 // Default to -1 (no batching)
174+
readBatchSize = 100.0 // Default to 100 Keys Per Batch
175175
} else if readBatchSize, ok = readBatchSizeJsonValue.(float64); !ok {
176176
return nil, fmt.Errorf("failed to convert read_batch_size: %+v", readBatchSizeJsonValue)
177177
}

go/internal/feast/onlinestore/redisonlinestore.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ type RedisOnlineStore struct {
5353
clusterClient *redis.ClusterClient
5454

5555
config *registry.RepoConfig
56+
57+
// Number of keys to read in a batch
58+
ReadBatchSize int
5659
}
5760

5861
func NewRedisOnlineStore(project string, config *registry.RepoConfig, onlineStoreConfig map[string]interface{}) (*RedisOnlineStore, error) {
@@ -111,6 +114,19 @@ func NewRedisOnlineStore(project string, config *registry.RepoConfig, onlineStor
111114
}
112115
}
113116

117+
// Parse read batch size
118+
var readBatchSize float64
119+
if readBatchSizeJsonValue, ok := onlineStoreConfig["read_batch_size"]; !ok {
120+
readBatchSize = 100.0 // Default to 100 Keys Per Batch
121+
} else if readBatchSize, ok = readBatchSizeJsonValue.(float64); !ok {
122+
return nil, fmt.Errorf("failed to convert read_batch_size: %+v", readBatchSizeJsonValue)
123+
}
124+
store.ReadBatchSize = int(readBatchSize)
125+
126+
if store.ReadBatchSize >= 1 {
127+
log.Info().Msgf("Reads will be done in key batches of size: %d", store.ReadBatchSize)
128+
}
129+
114130
// Metrics are not showing up when the service name is set to DD_SERVICE
115131
redisTraceServiceName := os.Getenv("DD_SERVICE") + "-redis"
116132
if redisTraceServiceName == "" {

sdk/python/feast/infra/online_stores/eg_valkey.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class EGValkeyOnlineStoreConfig(FeastConfigBaseModel):
8787
full_scan_for_deletion: Optional[bool] = True
8888
"""(Optional) whether to scan for deletion of features"""
8989

90-
read_batch_size: Optional[int] = -1
91-
"""(Optional) number of keys to read in a single batch for online read requests. Anything <= 1 means no batching."""
90+
read_batch_size: Optional[int] = 100
91+
"""(Optional) number of keys to read in a single batch for online read requests. Anything < 1 means no batching."""
9292

9393

9494
class EGValkeyOnlineStore(OnlineStore):

sdk/python/feast/infra/online_stores/redis.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class RedisOnlineStoreConfig(FeastConfigBaseModel):
7979
full_scan_for_deletion: Optional[bool] = True
8080
"""(Optional) whether to scan for deletion of features"""
8181

82+
read_batch_size: Optional[int] = 100
83+
"""(Optional) number of keys to read in a single batch for online read requests. Anything < 1 means no batching."""
84+
8285

8386
class RedisOnlineStore(OnlineStore):
8487
"""

0 commit comments

Comments
 (0)