简体   繁体   English

JAVA 中的 GRPC 服务器以支持巨大的请求负载

[英]GRPC server in JAVA to support huge load of requests

I have a grpc (1.13.x) server on java that isn't performing any computation or I/O intensive task.我在 java 上有一个 grpc (1.13.x) 服务器,它不执行任何计算或 I/O 密集型任务。 The intention is to check the number of requests this server can support per second on 80 core machine.目的是检查该服务器在 80 核机器上每秒可以支持的请求数。

Server:服务器:

  ExecutorService executor = new ThreadPoolExecutor(160, Integer.MAX_VALUE,
                60L, TimeUnit.SECONDS,
                new SynchronousQueue<Runnable>(),
                new ThreadFactoryBuilder()
                        .setDaemon(true)
                        .setNameFormat("Glowroot-IT-Harness-GRPC-Executor-%d")
                        .build());
     Server server =  NettyServerBuilder.forPort(50051)
                .addService(new MyService())
                .executor(executor)
                .build()
                .start();

Service:服务:

@Override
    public void verify(Request request, StreamObserver<Result> responseObserver) {
        Result result = Result.newBuilder()
                    .setMessage("hello")
                    .build();
        responseObserver.onNext(result);
        responseObserver.onCompleted();
    }

I am using ghz client to perform a load test.我正在使用ghz客户端执行负载测试。 Server is able to handle 40k requests per second but RPS count is not able to exceed more than 40k even on increase in number of concurrent clients with incoming requests rate 100k.服务器每秒能够处理 40k 请求,但 RPS 计数不能超过 40k,即使传入请求速率为 100k 的并发客户端数量增加。 GRPC server is able to handle just 40K requests per second and it queues all other requests. GRPC 服务器每秒只能处理 40K 请求,并将所有其他请求排队。 CPU is underutilized (7%). CPU 未充分利用 (7%)。 About 90% of grpc threads (with prefix grpc-default-executor) were in waiting state, despite no I/O operation.尽管没有 I/O 操作,但大约 90% 的 grpc 线程(前缀为 grpc-default-executor)正在等待 state。 More than 25k threads are in waiting state.超过 25k 线程在等待 state。

Stacktrace of threads in waiting:等待中线程的堆栈跟踪:

grpc-default-executor-4605
PRIORITY :5

THREAD ID :0X00007F15A4440D80

NATIVE ID :
stackTrace:
java.lang.Thread.State: TIMED_WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@15.0.1/Native Method)
- parking to wait for <0x00007f1df161ae20> (a java.util.concurrent.SynchronousQueue$TransferStack)
at java.util.concurrent.locks.LockSupport.parkNanos(java.base@15.0.1/LockSupport.java:252)
at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(java.base@15.0.1/SynchronousQueue.java:462)
at java.util.concurrent.SynchronousQueue$TransferStack.transfer(java.base@15.0.1/SynchronousQueue.java:361)
at java.util.concurrent.SynchronousQueue.poll(java.base@15.0.1/SynchronousQueue.java:937)
at java.util.concurrent.ThreadPoolExecutor.getTask(java.base@15.0.1/ThreadPoolExecutor.java:1055)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@15.0.1/ThreadPoolExecutor.java:1116)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@15.0.1/ThreadPoolExecutor.java:630)
at java.lang.Thread.run(java.base@15.0.1/Thread.java:832)
Locked ownable synchronizers:
- None

How can I configure the server to support 100K+ requests?如何配置服务器以支持 100K+ 请求?

Nothing in the gRPC stack seems to cause this limit. gRPC 堆栈中的任何内容似乎都不会导致此限制。 What's the average response time on the server side?服务器端的平均响应时间是多少? It looks like you are limited by the ephemeral ports or TCP connection limit and you may want to tweak your kernel as described at here https://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1 or here https://blog.box.com/ephemeral-port-exhaustion-and-web-services-at-scale看起来您受到临时端口或 TCP 连接限制的限制,您可能想要调整您的 kernel,如下所述Z5E056C500A1C4B6A7110B50D807BADE-a-com//www.metabrew-application-with-a-a-com//www.metabrew-application- mochiweb-part-1或此处https://blog.box.com/ephemeral-port-exhaustion-and-web-services-at-scale

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM