Java Multithreaded Network API (discussion)

Hi, I just wanted your opinion on an api that I’m designing for work.

What we’re working on is a networking lib that we can use internally that we know inside out. I know there are exisiting librarys out there however company wants to have their own library.

The goal is to have an api that is scalable and multithreaded. Multithreading seems to be a heavy topic for us atm and we don’t want to keep things single threaded (although there will be support for this)

Some snippets from a report that somebody did:

Networky is a Java networking library based of NIO.2. It is a solution to creating multithreaded networks. Everything is handled asynchronously, we try to reduce waiting time for operations to complete as much as possible. Networky does its best to remove the need for queuing (or at least lessen it) by running tasks in parallel.
A traditional system would only have one thread to listen connections. This is fine however introduces a long queuing system. Imagine waiting in line to buy tickets for the cinema to watch a new movie that has come out. The line is long and there is only 1 person serving at the checkouts. What Networky is trying to achieve is to reduce the wait time for clients so that they can quickly be processed and handled.

Now the Handlers, if you think of all the people in the cinema watching a movie, they all (logically, not scientifically) receive data at the same time. As Networky is still in very early development, feel free to contribute your thoughts to this. Creating a new Handler for every Channel seems very resourceful. The HandlerWorker in the above image purpose is to show a ConnectionHandler. This ConnectionHandler would deal with channelOpen, channelClose, channelRead, channelWrite and so forth. Small applications may find it hard to deal with a massive number of Handlers. Just like the Listeners, the Handlers will try to process as many people as it can at once and reduce the queue time by as much as possible.

Yes it’s garbage.

They want to have multiple worker threads that handle listening and handling.

The Moparscape community (while still under mitb :p) are pro vets and I’m sure you guys can give me all your opinions on this.
What do you think about the concept? Any possible design ideas? Help me!

Use Netty because they do everything better that you could (probably) create

I cannot. Somebody else wrote a very strong report at work on why Netty is not sutible for what we need and “the stupid pipeline” and addressed many reasons on why its shit. I do not agree at all however they are better programmers then me. I should also mention we have a guy from red hat who’s interested in the project. Does not sound all that though.

Fyi I’m not coding this alone, I’m just doing pre design with the team.

I’d be interested in what you find

Are you guys going to make this library public?

[quote=“penguinimp, post:4, topic:555343”]I’d be interested in what you find

Are you guys going to make this library public?[/quote]
Who knows, I don’t see why not though. A guy made a POC and it’s flipping user friendly as fudge!
The worry is how scalable it will actually be. My attempt (for fun) did not go so well lol

Seems very complicated.

what problem are they actually trying to solve with this? is it just a learning exercise?

i hate it when people write their own shit libraries at work because they think they can do better than everyone else, then they leave and we’re all stuck using some unmaintainable piece of wank for the next eternity. just because they’ve been in the game longer doesn’t mean they know what they’re doing - they’re just better at bullshitting

[quote=“Justin Bieber, post:6, topic:555343”]what problem are they actually trying to solve with this? is it just a learning exercise?

i hate it when people write their own shit libraries at work because they think they can do better than everyone else, then they leave and we’re all stuck using some unmaintainable piece of wank for the next eternity. just because they’ve been in the game longer doesn’t mean they know what they’re doing - they’re just better at bullshitting[/quote]

[quote=“Justin Bieber, post:6, topic:555343”]what problem are they actually trying to solve with this? is it just a learning exercise?

i hate it when people write their own shit libraries at work because they think they can do better than everyone else, then they leave and we’re all stuck using some unmaintainable piece of wank for the next eternity. just because they’ve been in the game longer doesn’t mean they know what they’re doing - they’re just better at bullshitting[/quote]
The idea is that parallelism and multithreading the the way forward.
I’m not sure what environment you’re based around but mostly everybody here are very competent programmers.

Competent doesn’t mean intelligent

parallelism isn’t a problem it’s a solution to a problem

Well they’re not programmers that have a degree from moparscape

That’s what I said lol

sorry mate, I thought you were replying to my question about what problem they’re trying to solve

dunno what the salty comment about moparscape is all about, a lot of people here have solid cs degrees and good jobs

[quote=“Justin Bieber, post:12, topic:555343”]sorry mate, I thought you were replying to my question about what problem they’re trying to solve

dunno what the salty comment about moparscape is all about, a lot of people here have solid cs degrees and good jobs[/quote]
Hopefully they will then comment!

[quote=“my-swagger, post:13, topic:555343”][quote author=Justin Bieber link=topic=674535.msg4508179#msg4508179 date=1462729398]
sorry mate, I thought you were replying to my question about what problem they’re trying to solve

dunno what the salty comment about moparscape is all about, a lot of people here have solid cs degrees and good jobs
[/quote]
Hopefully they will then comment![/quote]nice

theyd all say the same thing

Id appreciate an open mind set.

then go to another forum and watch them tell you the same thing
and the next
and the next

the reasons you have aren’t convincing at all and aren’t backed by evidence or fact.

In what way is Netty not multi-threaded / concurrent / parallelised? You specify one thread group (i.e., a pool with one or more threads) specifically for accepting connections, and one thread group for all work that occurs after initial connection acceptance.
There’s no logical limit on the thread count in these thread groups (although you’ll want to discover the ideal through profiling).

Honestly, the only bad thing about Netty that I’ve heard of is the undue memory pressure it places on the garbage collector. This makes it potentially unsuitable for real-time networking applications (such as FIX servers) and anything else that demands low-latency/real-time responsiveness due to producing a non-zero amount of garbage (therefore resulting in intermittent execution of the garbage collector).

If you or your colleagues can’t make heads or tails of what I’ve just said, or you’re not working on something that demands real-time/low-latency response within hard SLAs, then you’re making a bad decision from a business perspective by choosing to build rather than ‘buy’ (Netty is free, I know) on this occasion.

Just remember that IT as a value stream has no value until whatever you’re making is in production. And not a moment sooner.

EDIT: As an addendum, if you truly need that low-latency networking capability within Java software then consider the CoralBlocks CoralReactor software. Here’s a link comparing it to Netty: http://www.coralblocks.com/index.php/2014/04/coralreactor-vs-netty-performance-comparison/

Yeah buying a library that can handle real time networking is probably a lot cheaper from a business perspective unless you have VERY efficient engineers. I mean 10-30 years experience of software engineering, indian, engineers.

Lothy,

Netty has bad scaling when it comes to multi-threading. Here’s an example; when multi-threading to multiple channels. It’s also not multi-threaded in the aspect that I want. Multi-threading to one channel? I except to be able to perform io to multiple connections in parallel. Netty does this in a linear fashion afaik on the default implementation. The throughput does not scale (from a client’s perspective). Look at their effective performance.

Regards to speed, in some situtations a reponse is needed as quick as possible. Netty will not supply this. In fact we desperately need this.

There are about 100ish sites in the UK that we need a fast strong connection with (disregarding connection speed, this is a different topic). Heres an actual thing we can all agree on; a payment terminal.

Also there is a lot of inspiration from Erlangs OTP (not in multi-threading or parallel).

Next time I go to work, I’ll get all the information you’ll need.

Just a note; Netty is brilliant, in no way am I saying it’s a piple of crap. We actually used http://vertx.io/ - based off netty before.

I’m just a junior developer. These guys are very old; not indian though :stuck_out_tongue: