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

=vertx deploy vertical target instances to match the CPU cores. #361

Merged
merged 1 commit into from
Jun 27, 2023
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
2 changes: 1 addition & 1 deletion java_vertx_grpc_bench/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def protobufVersion = '3.21.6'
def protocVersion = protobufVersion

dependencies {
implementation 'io.vertx:vertx-grpc-server:4.4.3'
implementation 'io.vertx:vertx-grpc-server:4.4.4'
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
implementation "io.grpc:grpc-stub:${grpcVersion}"
implementation "com.google.protobuf:protobuf-java-util:${protobufVersion}"
Expand Down
13 changes: 10 additions & 3 deletions java_vertx_grpc_bench/src/main/java/vertx/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.grpc.examples.helloworld.HelloReply;
import io.grpc.examples.helloworld.HelloRequest;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
Expand All @@ -14,9 +15,15 @@
public class Main {
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
vertx.nettyEventLoopGroup().forEach(u -> {
vertx.deployVerticle(new ServerVerticle());
});
DeploymentOptions deploymentOptions = new DeploymentOptions();
int cores = Runtime.getRuntime().availableProcessors();
He-Pin marked this conversation as resolved.
Show resolved Hide resolved
String GRPC_SERVER_CPUS = System.getenv("GRPC_SERVER_CPUS");
if (GRPC_SERVER_CPUS != null && GRPC_SERVER_CPUS.length() > 0) {
cores = Integer.parseInt(GRPC_SERVER_CPUS);
}
deploymentOptions.setInstances(cores);
vertx.deployVerticle(ServerVerticle::new, deploymentOptions);
System.out.println("Deploy vertical instances:"+cores);
}

static class ServerVerticle extends AbstractVerticle {
Expand Down