Skip to content

Commit dbfefc9

Browse files
committed
configure netty event loops
1 parent bbbdd01 commit dbfefc9

File tree

5 files changed

+42
-23
lines changed

5 files changed

+42
-23
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ allprojects {
4949
kotlin : '1.6.10',
5050
java_controlplane : '0.1.35',
5151
spring_boot : '2.3.4.RELEASE',
52-
grpc : '1.21.0',
52+
grpc : '1.48.1',
5353
jaxb : '2.3.1',
5454
javaxactivation : '1.2.0',
5555
micrometer : '1.5.5',

docs/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Property
77
------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------
88
**envoy-control.server.executor-group.type** | Group executor type. DIRECT or PARALLEL | DIRECT
99
**envoy-control.server.executor-group.parallel-pool-size** | Pool size used for executor group in PARALLEL mode | 4
10-
**envoy-control.server.nio-event-loop-thread-count** | The number of threads that will be used by netty's nio event loop | 1
11-
**envoy-control.server.nio-event-loop-pool-size** | Pool size of NIO Event Loop | 0 (Number of CPUs * 2)
10+
**envoy-control.server.nio-event-loop-thread-count** | The number of threads that will be used by netty's nio worker event loop | 1
11+
**envoy-control.server.nio-boss-event-loop-thread-count** | The number of threads that will be used by netty's nio boss event loop | 1
1212
**envoy-control.server.netty.keep-alive-time** | Sets a custom keepalive time for Netty server | 15s
1313
**envoy-control.server.netty.permit-keep-alive-time** | Specify the most aggressive keep-alive time clients are permitted to configure (in seconds) | 10s
1414
**envoy-control.server.netty.permit-keep-alive-without-calls** | Sets whether to allow clients to send keep-alive HTTP/2 PINGs even if there are no outstanding RPCs on the connection | true

envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/ControlPlane.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import io.grpc.netty.NettyServerBuilder
1212
import io.micrometer.core.instrument.MeterRegistry
1313
import io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics
1414
import io.netty.channel.nio.NioEventLoopGroup
15+
import io.netty.channel.socket.nio.NioServerSocketChannel
1516
import pl.allegro.tech.servicemesh.envoycontrol.groups.Group
1617
import pl.allegro.tech.servicemesh.envoycontrol.groups.GroupChangeWatcher
1718
import pl.allegro.tech.servicemesh.envoycontrol.groups.MetadataNodeGroup
@@ -89,6 +90,7 @@ class ControlPlane private constructor(
8990
) {
9091
var grpcServerExecutor: Executor? = null
9192
var nioEventLoopExecutor: Executor? = null
93+
var nioBossEventLoopExecutor: Executor? = null
9294
var executorGroup: ExecutorGroup? = null
9395
var globalSnapshotExecutor: Executor? = null
9496
var globalSnapshotAuditExecutor: Executor? = null
@@ -112,6 +114,12 @@ class ControlPlane private constructor(
112114
nioEventLoopExecutor = newMeteredCachedThreadPool("grpc-worker-event-loop")
113115
}
114116

117+
if (nioBossEventLoopExecutor == null) {
118+
// unbounded executor - netty will only use configured number of threads
119+
// (by nioEventLoopThreadCount property or default netty value: <number of CPUs> * 2)
120+
nioBossEventLoopExecutor = newMeteredCachedThreadPool("grpc-boss-event-loop")
121+
}
122+
115123
if (executorGroup == null) {
116124
executorGroup = buildExecutorGroup()
117125
}
@@ -210,6 +218,11 @@ class ControlPlane private constructor(
210218
nioEventLoopExecutor
211219
)
212220
)
221+
.bossEventLoopGroup(NioEventLoopGroup(
222+
properties.server.nioBossEventLoopThreadCount,
223+
nioBossEventLoopExecutor
224+
))
225+
.channelType(NioServerSocketChannel::class.java)
213226
.executor(grpcServerExecutor)
214227
.keepAliveTime(properties.server.netty.keepAliveTime.toMillis(), TimeUnit.MILLISECONDS)
215228
.permitKeepAliveTime(properties.server.netty.permitKeepAliveTime.toMillis(), TimeUnit.MILLISECONDS)
@@ -300,6 +313,11 @@ class ControlPlane private constructor(
300313
return this
301314
}
302315

316+
fun withNioBossEventLoopExecutor(executor: Executor): ControlPlaneBuilder {
317+
nioBossEventLoopExecutor = executor
318+
return this
319+
}
320+
303321
fun withExecutorGroup(executor: ExecutorGroup): ControlPlaneBuilder {
304322
executorGroup = executor
305323
return this

envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/ServerProperties.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import java.time.Duration
77
class ServerProperties {
88
var port = 50000
99
var nioEventLoopThreadCount = 0 // if set to 0, default Netty value will be used: <number of CPUs> * 2
10+
var nioBossEventLoopThreadCount = 0 // if set to 0, default Netty value will be used: <number of CPUs> * 2
1011
var serverPoolSize = 16
1112
var serverPoolKeepAlive: Duration = Duration.ofMinutes(10)
1213
var executorGroup = ExecutorProperties()

envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/config/LocalReplyConfigFactoryTest.kt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,19 @@ body_format {
448448
value {
449449
struct_value {
450450
fields {
451-
key: "service-tag"
451+
key: "listOfIntegers"
452452
value {
453-
string_value: "test"
453+
list_value {
454+
values {
455+
number_value: 1.0
456+
}
457+
values {
458+
number_value: 2.0
459+
}
460+
values {
461+
number_value: 3.0
462+
}
463+
}
454464
}
455465
}
456466
fields {
@@ -467,30 +477,14 @@ body_format {
467477
}
468478
}
469479
fields {
470-
key: "listOfIntegers"
480+
key: "service-tag"
471481
value {
472-
list_value {
473-
values {
474-
number_value: 1.0
475-
}
476-
values {
477-
number_value: 2.0
478-
}
479-
values {
480-
number_value: 3.0
481-
}
482-
}
482+
string_value: "test"
483483
}
484484
}
485485
}
486486
}
487487
}
488-
fields {
489-
key: "reason"
490-
value {
491-
number_value: 1.0
492-
}
493-
}
494488
fields {
495489
key: "listOfMap"
496490
value {
@@ -518,6 +512,12 @@ body_format {
518512
}
519513
}
520514
}
515+
fields {
516+
key: "reason"
517+
value {
518+
number_value: 1.0
519+
}
520+
}
521521
}
522522
content_type: "application/envoy+json"
523523
}""".trimIndent()

0 commit comments

Comments
 (0)