Reputation: 597
I created simple Webflux (kotlin) app with reactive mongo. Controller has one GET method which is return Flow (2 objects from one collection). I used Apache Benchmark and I noticed one thing: I have i7 10700 (8+8 cores). If I set System.setProperty("reactor.netty.ioWorkerCount", "8"), performance increases. With 16 netty-nio threads AB shows ~4800 requests per second and one request time takes about 7-9 ms. With 8 netty-nio threads AB shows ~5500 requests per second and 3-5 ms per request.
Is it worth in future in real project use only physical cores? Does hyper-threading have advantages in other situations?
Upvotes: 2
Views: 336
Reputation: 72254
Hyperthreading and thread count is a delicate thing, and often very difficult to reason about in a given setting. So rather than taking a blanket rule to turn it on or off, it's always worth benchmarking your specific setup to see what works best IMHO.
That being said, I'm not overly surprised that it hampered, rather than helped performance in this case. Hyperthreading won't give your processor any more real processing power, it just enables unused parts of the core to be used simultaneously on another thread. If your event loop is just chugging away doing the same work constantly, it's therefore likely to not make a great deal of difference (as the same parts of the cores are being used for each thread) - and as you note, has a chance to hamper performance because of the increased context switching overhead happening with more worker threads.
If you had an application that could feasibly do meaningfully different work with each request that came in however - that could be a different story, hence the sense in always benchmarking your specific case to make sure.
Upvotes: 2