You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add request-aware connection routing and enhanced node selection
Introduces flexible connection routing system that allows intelligent node
selection based on request characteristics and node roles. This enables
performance optimizations by routing operations to the most appropriate nodes.
Features:
- RequestAwareSelector interface for operation-based node selection
- Role-based selector with options pattern: WithRequiredRoles(),
WithExcludedRoles(), WithStrictMode(), WithFallback()
- SmartSelector with automatic operation detection for bulk and search requests
- Automatic routing of bulk operations to ingest nodes and search to data nodes
- Extend connection pool with RequestAwareConnectionPool interface
- Add documentation and guides for node discovery and role management
This new routing system is backward compatible and optional - existing
clients continue to use round-robin selection unless explicitly configured.
Fixes: opensearch-project#770
Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,11 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
7
7
### Added
8
8
- Enhanced cluster readiness checking for improved test reliability: `ostest.NewClient()` now includes readiness validation (health + cluster state + nodes info)
- Request-aware connection routing for improved performance and service availability ([#770](https://github.com/opensearch-project/opensearch-go/pull/770))
11
+
-`RequestAwareSelector` interface for operation-based node selection
12
+
- Role-based selector with flexible options pattern: `NewRoleBasedSelector()` with `WithRequiredRoles()`, `WithExcludedRoles()`, `WithStrictMode()`, `WithFallback()` options
13
+
-`SmartSelector` with automatic operation detection for bulk and search requests
14
+
- Automatic routing of bulk operations to ingest nodes and search operations to data nodes
10
15
11
16
### Changed
12
17
- Refactor Client struct to use embedded mutex pattern for improved thread safety ([#775](https://github.com/opensearch-project/opensearch-go/pull/775))
// Enable node discovery to find all cluster nodes
52
+
DiscoverNodesOnStart: true,
53
+
DiscoverNodesInterval: 5 * time.Minute,
54
+
55
+
// Configure smart routing: bulk operations go to ingest nodes, searches go to data nodes
56
+
Transport: &opensearchtransport.Config{
57
+
Selector: opensearchtransport.NewSmartSelector(
58
+
opensearchtransport.NewRoundRobinSelector(),
59
+
),
60
+
},
61
+
})
62
+
if err != nil {
63
+
return err
64
+
}
65
+
66
+
// This client will automatically route operations to appropriate nodes:
67
+
// - Bulk operations -> ingest nodes
68
+
// - Search operations -> data nodes
69
+
// - Other operations -> round-robin
70
+
_ = advancedClient
71
+
```
72
+
38
73
Next, create an index named `movies` and another named `books` with the default settings:
39
74
40
75
```go
@@ -217,6 +252,86 @@ The following code shows an example on how to look for errors in the response:
217
252
}
218
253
```
219
254
255
+
## Performance Optimization for Bulk Operations
256
+
257
+
### Automatic Ingest Node Routing
258
+
259
+
For production environments with dedicated ingest nodes, you can optimize bulk operation performance by routing requests to the most appropriate nodes:
0 commit comments