Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NIO disadvantages in ActiveMQ

Tags:

activemq

nio

I've been working on configuring an ActiveMQ broker, and one thing that confuses me is that everything I've read describes NIO being "a good choice if you need to scale" or a "something to look at if you need more speed", so my question is why don't they just say "always use NIO"? All I've read is advantages but presumably there are reasons not to use it (otherwise it would just be the default). What are they?

like image 827
Brendan Long Avatar asked May 19 '11 17:05

Brendan Long


2 Answers

Complexity. It is usually more simple to code for 1 thread per connection.

Also, I think NIO may be slightly slower in the small volume case (1, 2, 3 connections). Generally you wouldn't design a system to perform well in the small volume case.. but if you know you are never going to have > 2 connections for an application... maybe NIO is overkill / actually harmful.

like image 98
bwawok Avatar answered Jan 03 '23 18:01

bwawok


The NIO transport scales better because it is more efficient and does not spawn a thread per connection. Also, the NIO transport extends the TCP transport, so all the options for the underlying socket still apply. To my knowledge, there is no downside to using NIO because overall it should be more efficient than the TCP transport. There's no good reason that I can recall for NIO not being the default transport.

like image 45
bsnyder Avatar answered Jan 03 '23 16:01

bsnyder