I would start with eliminating the byte array, String and the new PostToKafka instance.
But I seriously doubt you will come close to your performance goal. Can you show the Jetty
and Nett versions which are faster, and if yes how much?
I am not sure what the characteristic of your Kafka client is, but it is likely that it
should run on a worker thread.
Gruss
Bernd
--
http://bernd.eckenfels.net
_____________________________
From: SenthilKumar K <senthilec566@gmail.com<mailto:senthilec566@gmail.com>>
Sent: Donnerstag, Juni 22, 2017 9:21 PM
Subject: [undertow-dev] Undertow Http Server - Handling 2 Millions Requests Per Second Per
Instance
To: <undertow-dev@lists.jboss.org<mailto:undertow-dev@lists.jboss.org>>,
Senthil kumar <senthilec566@gmail.com<mailto:senthilec566@gmail.com>>
Hello Undertow Dev Team ,
I have been working on the use case where i should create simple http server to
serve 1.5 Million Requests per Second per Instance ..
Here is the benchmark result of Undertow :
Running 1m test @
http://127.0.0.1:8009/
20 threads and 40 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 2.51ms 10.75ms 282.22ms 99.28%
Req/Sec 1.12k 316.65 1.96k 54.50%
Latency Distribution
50% 1.43ms
75% 2.38ms
90% 2.90ms
99% 10.45ms
1328133 requests in 1.00m, 167.19MB read
Requests/sec: 22127.92
Transfer/sec: 2.79MB
This is less compared to other frameworks like Jetty and Netty .. But originally Undertow
is high performant http server ..
Hardware details:
Xeon CPU E3-1270 v5 machine with 4 cores ( Clock 100 MHz, Capacity 4 GHz) , Memory : 32 G
, Available memory 31 G.
I would need Undertow experts to review the server code below and advice me on tuning to
achieve my goal( ~1.5 Million requests/sec ).
Server :
Undertow server = Undertow.builder()
.addHttpListener(8009, "localhost")
.setHandler(new Handler()).build();
server.start();
Handler.Java
final Pooled<ByteBuffer> pooledByteBuffer =
exchange.getConnection().getBufferPool().allocate();
final ByteBuffer byteBuffer = pooledByteBuffer.getResource();
byteBuffer.clear();
exchange.getRequestChannel().read(byteBuffer);
int pos = byteBuffer.position();
byteBuffer.rewind();
byte[] bytes = new byte[pos];
byteBuffer.get(bytes);
String requestBody = new String(bytes, Charset.forName("UTF-8") );
byteBuffer.clear();
pooledByteBuffer.free();
final PostToKafka post2Kafka = new PostToKafka();
try {
post2Kafka.write2Kafka(requestBody); { This API can handle ~2 Millions events per sec }
} catch (Exception e) {
e.printStackTrace();
}
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("SUCCESS");
--Senthil