1

I have written a Netty HTTP Server.

I am figuring out right way to handle Http requests
Options: (1. Netty Handlers 2. LMAX Disruptor).

I have read it somewhere that LMAX Disruptor are good for async event handling.
But after the load testing, server with LMAX Disruptor for event handling provided 70% less throughput than Netty Handler. And latency also increased by 200%.
I was getting 30k qps on an 8 core 16gb box. After using Lmax Disruptor, I am getting 10k qps.
Currently my service is just reading Json request and returning static response. I am just trying to compare raw performance as of now.

I am reading HttpRequest from SimpleChannelInboundHandler and sending to LMAX Disruptor event handler and freeing the netty worker handler whose configuration is mentioned below:

Netty IO threads: 24 and worker threads: 48

Disruptor disruptor = new Disruptor<>(new EventFactory(), 65536, DaemonThreadFactory.INSTANCE);

Is it because Disruptor creates new Daemon thread for each event?

Nandish Kotadia
  • 441
  • 1
  • 6
  • 21
  • If you want a good answer, you will need to explain what you're your service is doing. In any case, pushing the work to another thread doesn't make it go away, and in most cases only increases latency due to context switches. Also as far as I can recall Disruptor doesn't perform well with multi-producer setups. – Eran Harel Apr 08 '20 at 09:54
  • I am having Single Producer Setup. My Service is just reading Json request and returning static response. I am trying to benchmark it. – Nandish Kotadia Apr 08 '20 at 10:05
  • So a distruptor can't add any value to this service basically. – Eran Harel Apr 08 '20 at 10:44
  • So going forward I want to add stages of processing to it. Pass request from 1 event disruptor to different and return the response. Will it help there? Also it creates new daemon thread for each message. Can't we have pool of threads and it uses that to improve latency and avoid garbage collection. – Nandish Kotadia Apr 08 '20 at 10:47
  • @NandishKotadia What EventExecutorGroup are your handlers using? The advantage is disruptor is that because its essentially a replacement for BlockingQueue you can write blocking code but you can't with certain "ExecutorGroups".TLDR are you netty handlers able to do blocking? – Adam Gent Dec 20 '20 at 19:18

1 Answers1

0

To get performance from disruptor, you need to hav mechanical sympathy on mind at first... Than make sure:

  1. you have pre-allocated events (please start with lower number. For example 512). Ideally they should fit into cache
  2. make sure that you do not do any allocation when setting data to event
  3. attach as many handlers as you want to events. They will run one-by-one on each event. So your first handler can pass its result to event instance and second one can read it from there and there is no need to any locking.

To more precise answer, please provide some basic info about how you create disruptor and what is your processing handler look like.

user3698328
  • 71
  • 1
  • 7