Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global ratelimiter and make async t...; Port [#18549] to branch-2.10 #18552

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/common/src/main/java/alluxio/conf/PropertyKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -5456,6 +5456,14 @@ public String toString() {
.setConsistencyCheckLevel(ConsistencyCheckLevel.ENFORCE)
.setScope(Scope.SERVER)
.build();
public static final PropertyKey PROXY_S3_V2_ASYNC_CONTEXT_TIMEOUT_MS =
longBuilder(Name.PROXY_S3_V2_ASYNC_CONTEXT_TIMEOUT_MS)
.setDefaultValue(30000L)
.setDescription("Timeout(in milliseconds) for async context. "
+ "Set zero or less indicates no timeout.")
.setConsistencyCheckLevel(ConsistencyCheckLevel.ENFORCE)
.setScope(Scope.SERVER)
.build();
public static final PropertyKey PROXY_S3_V2_ASYNC_LIGHT_POOL_CORE_THREAD_NUMBER =
intBuilder(Name.PROXY_S3_V2_ASYNC_LIGHT_POOL_CORE_THREAD_NUMBER)
.setDefaultValue(8)
Expand Down Expand Up @@ -8755,6 +8763,8 @@ public static final class Name {
"alluxio.proxy.s3.v2.version.enabled";
public static final String PROXY_S3_V2_ASYNC_PROCESSING_ENABLED =
"alluxio.proxy.s3.v2.async.processing.enabled";
public static final String PROXY_S3_V2_ASYNC_CONTEXT_TIMEOUT_MS =
"alluxio.proxy.s3.v2.async.context.timeout.ms";
public static final String PROXY_S3_V2_ASYNC_LIGHT_POOL_CORE_THREAD_NUMBER =
"alluxio.proxy.s3.v2.async.light.pool.core.thread.number";
public static final String PROXY_S3_V2_ASYNC_LIGHT_POOL_MAXIMUM_THREAD_NUMBER =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public class S3RequestServlet extends HttpServlet {
* light-weighted metadata-centric requests and heavy io requests */
public static final String PROXY_S3_V2_LIGHT_POOL = "Proxy S3 V2 Light Pool";
public static final String PROXY_S3_V2_HEAVY_POOL = "Proxy S3 V2 Heavy Pool";
public static final boolean PROXY_V2_ASYNC_ENABLED =
Configuration.getBoolean(PropertyKey.PROXY_S3_V2_ASYNC_PROCESSING_ENABLED);
public static final long ASYNC_CONTEXT_TIMEOUT =
Configuration.getLong(PropertyKey.PROXY_S3_V2_ASYNC_CONTEXT_TIMEOUT_MS);

/**
* Implementation to serve the HttpServletRequest and returns HttpServletResponse.
Expand Down Expand Up @@ -76,13 +80,14 @@ public void service(HttpServletRequest request,
}
request.setAttribute(ProxyWebServer.S3_HANDLER_ATTRIBUTE, s3Handler);
// Handle request async
if (Configuration.getBoolean(PropertyKey.PROXY_S3_V2_ASYNC_PROCESSING_ENABLED)) {
if (PROXY_V2_ASYNC_ENABLED) {
S3BaseTask.OpTag opTag = s3Handler.getS3Task().mOPType.getOpTag();
ExecutorService es = (ExecutorService) (opTag == S3BaseTask.OpTag.LIGHT
? getServletContext().getAttribute(PROXY_S3_V2_LIGHT_POOL)
: getServletContext().getAttribute(PROXY_S3_V2_HEAVY_POOL));

final AsyncContext asyncCtx = request.startAsync();
asyncCtx.setTimeout(ASYNC_CONTEXT_TIMEOUT);
final S3Handler s3HandlerAsync = s3Handler;
es.submit(() -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ public void init() throws ServletException {
mAsyncAuditLogWriter);
getServletContext().setAttribute(PROXY_S3_V2_LIGHT_POOL, createLightThreadPool());
getServletContext().setAttribute(PROXY_S3_V2_HEAVY_POOL, createHeavyThreadPool());
if (mGlobalRateLimiter != null) {
getServletContext().setAttribute(GLOBAL_RATE_LIMITER_SERVLET_RESOURCE_KEY,
mGlobalRateLimiter);
}
}
});
mServletContextHandler
Expand Down
Loading