Take out theif (exchange.isInIoThread()) {exchange.dispatch(this);return;}How are you testing it? Are you sure you are sending enough requests a second? Also try commenting out the kafka part just to see the speed. If it does increase then we knows in on the undertow side.It also doesn't look like you used the method receiveFullBytes I suggested from the link.On Thu, Jun 22, 2017 at 3:13 PM, SenthilKumar K <senthilec566@gmail.com> wrote:At last i modified the code as below and still i see ~50K requests/sec ..public class HelloWorldServer {public static void main(final String[] args) {Undertow server = Undertow.builder().addHttpListener(8009, "localhost").setHandler(new HttpHandler() { @Overridepublic void handleRequest(final HttpServerExchange exchange) throws Exception {if (exchange.isInIoThread()) {exchange.dispatch(this);return;}if (exchange.getRequestMethod().equals(Methods.POST)) { BufferedReader reader = null;StringBuilder builder = new StringBuilder();try {exchange.startBlocking();reader = new BufferedReader(new InputStreamReader(exchange.getInputStream())); String line;while ((line = reader.readLine()) != null) {builder.append(line);}} catch (IOException e) {e.printStackTrace();} finally {if (reader != null) {try {reader.close();} catch (IOException e) {e.printStackTrace();}}}String body = builder.toString();System.out.println("Req Body ==> " + body);exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain"); exchange.getResponseSender().send("SUCCESS"); } else {exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain"); exchange.getResponseSender().send("FAILURE"); }}}).build();server.start();}}On Thu, Jun 22, 2017 at 11:57 PM, SenthilKumar K <senthilec566@gmail.com> wrote:Seems to Reading Request body is wrong , So what is the efficient way of reading request body in undertow ?--SenthilOn Thu, Jun 22, 2017 at 11:30 PM, SenthilKumar K <senthilec566@gmail.com> wrote: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 connectionsThread Stats Avg Stdev Max +/- StdevLatency 2.51ms 10.75ms 282.22ms 99.28%Req/Sec 1.12k 316.65 1.96k 54.50%Latency Distribution50% 1.43ms75% 2.38ms90% 2.90ms99% 10.45ms1328133 requests in 1.00m, 167.19MB readRequests/sec: 22127.92Transfer/sec: 2.79MBThis 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.Javafinal 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
_______________________________________________
undertow-dev mailing list
undertow-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/undertow-dev