Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to understand ExampleUdpServer.java? #7

Closed
bglmmz opened this issue Aug 13, 2018 · 5 comments
Closed

How to understand ExampleUdpServer.java? #7

bglmmz opened this issue Aug 13, 2018 · 5 comments

Comments

@bglmmz
Copy link

bglmmz commented Aug 13, 2018

Your code works great! I have the same case: UDP and private Channel for each client.
But, I'm not sure about somethings:

  1. The parameter 'ioThreads'.
  2. ServerBootstrap.group(new DefaultEventLoopGroup()), but not the ServerBootstrap.group(new NioEventLoopGroup(), new NioEventLoopGroup()).

So, could you please say more details?
Thanks.

@Shevchik
Copy link
Owner

Shevchik commented Aug 13, 2018

  1. It's the number of threads used for native socket data reading/writing.

The UdpServerSocketChannel itself is split to 2 parts.
Io threads - threads the read/write bytes from/to system sockets.
Worker threads that do user udp channel processing.

So the number of iothreads is the number of system sockets and threads that are used.
But be careful, the iothreads parameter only works on epoll capable platforms that support resuing udp port (i.e. Linux with kernel >= 3.9), and just defaults to 1 if not.

  1. The reason why a signle argument event loop group method is used is because UdpServerSocketChannel uses it's own NioEventLoopGroup or EpollEventLoopGroup based on ioThreads number, so you can't provide a custom boss event loop group.
    The reason why DefaultEventLoopGroup is used is because user worker threads don't do any native scoket/reading writing, they only process user tasks and pipeline operations.

@bglmmz
Copy link
Author

bglmmz commented Aug 14, 2018

Thanks!

@bglmmz bglmmz closed this as completed Aug 14, 2018
@bglmmz bglmmz reopened this Aug 14, 2018
@bglmmz
Copy link
Author

bglmmz commented Aug 14, 2018

Sorry, I would like to ask more .
My worker threads will read/write a redis-cluster and a MySQL server,in this case, the worker threads group should use NioEventLoopGroup?

@Shevchik
Copy link
Owner

The UdpChannel itself is compatible with any event loop group. But if you are using the event loop group only for UdpServerSocketChannel then you better stick to DefaultEventLoopGroup (because it only needs to execute tasks).

@bglmmz
Copy link
Author

bglmmz commented Aug 15, 2018

Oh, I'm still puzzled.
But just let it be.
The code is working well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants