Skip to content

Commit

Permalink
Switch default back-pressure strategy to AUTO_FLUSH from LINEAR. (#5983)
Browse files Browse the repository at this point in the history
Signed-off-by: Santiago Pericasgeertsen <[email protected]>
  • Loading branch information
spericas authored Jan 30, 2023
1 parent 64d5f73 commit 65a962d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022 Oracle and/or its affiliates.
* Copyright (c) 2017, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -543,7 +543,7 @@ public Builder backpressureBufferSize(long size) {
* <li>PREFETCH - After first data chunk arrives, probable number of chunks needed to fill the buffer up to watermark is calculated and requested.</li>
* <li>NONE - No backpressure is applied, Long.MAX_VALUE(unbounded) is requested from upstream.</li>
* </ul>
* @param backpressureStrategy One of NONE, PREFETCH or LINEAR, default is LINEAR
* @param backpressureStrategy One of NONE, PREFETCH, LINEAR or AUTO_FLUSH, default is AUTO_FLUSH
* @return an updated builder
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022 Oracle and/or its affiliates.
* Copyright (c) 2017, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -177,11 +177,12 @@ default long backpressureBufferSize() {

/**
* Strategy for applying backpressure to the reactive stream of response data.
* Switched default to {@link BackpressureStrategy#AUTO_FLUSH} since 3.1.1.
*
* @return strategy identifier for applying backpressure
*/
default BackpressureStrategy backpressureStrategy() {
return BackpressureStrategy.LINEAR;
return BackpressureStrategy.AUTO_FLUSH;
}

/**
Expand Down Expand Up @@ -404,10 +405,10 @@ default B tls(Supplier<WebServerTls> tlsConfig) {
* <li>PREFETCH - After first data chunk arrives, probable number of chunks needed to fill the buffer up to watermark is calculated and requested.</li>
* <li>NONE - No backpressure is applied, Long.MAX_VALUE(unbounded) is requested from upstream.</li>
* </ul>
* @param backpressureStrategy One of NONE, PREFETCH or LINEAR, default is LINEAR
* @param backpressureStrategy One of NONE, PREFETCH, LINEAR or AUTO_FLUSH, default is AUTO_FLUSH
* @return this builder
*/
@ConfiguredOption("LINEAR")
@ConfiguredOption("AUTO_FLUSH")
B backpressureStrategy(BackpressureStrategy backpressureStrategy);

/**
Expand Down Expand Up @@ -500,7 +501,7 @@ final class Builder implements SocketConfigurationBuilder<Builder>, io.helidon.c
private int initialBufferSize = 128;
private boolean enableCompression = false;
private long maxPayloadSize = -1;
private BackpressureStrategy backpressureStrategy = BackpressureStrategy.LINEAR;
private BackpressureStrategy backpressureStrategy = BackpressureStrategy.AUTO_FLUSH;
private int maxUpgradeContentLength = 64 * 1024;
private long maxBufferSize = 5 * 1024 * 1024;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -58,6 +58,19 @@ void tearDown() {
executorService.shutdown();
}

/**
* Verifies default back-pressure strategy is {@link BackpressureStrategy#AUTO_FLUSH}
* on all sockets.
*/
@Test
void defaultStrategy() {
WebServer webServer = WebServer.builder().build();
webServer.configuration()
.sockets()
.values()
.forEach(sc -> assertThat(sc.backpressureStrategy(), is(AUTO_FLUSH)));
}

@Test
void linear() {
AtomicLong receivedSize = new AtomicLong(0);
Expand Down

0 comments on commit 65a962d

Please sign in to comment.