{"action":"created","issue":{"url":"https://api.github.com/repos/netty/netty/issues/5152","repository_url":"https://api.github.com/repos/netty/netty","labels_url":"https://api.github.com/repos/netty/netty/issues/5152/labels{/name}","comments_url":"https://api.github.com/repos/netty/netty/issues/5152/comments","events_url":"https://api.github.com/repos/netty/netty/issues/5152/events","html_url":"https://github.com/netty/netty/issues/5152","id":148763248,"number":5152,"title":"Throughput is low even with batching","user":{"login":"maseev","id":3434800,"avatar_url":"https://avatars.githubusercontent.com/u/3434800?v=3","gravatar_id":"","url":"https://api.github.com/users/maseev","html_url":"https://github.com/maseev","followers_url":"https://api.github.com/users/maseev/followers","following_url":"https://api.github.com/users/maseev/following{/other_user}","gists_url":"https://api.github.com/users/maseev/gists{/gist_id}","starred_url":"https://api.github.com/users/maseev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maseev/subscriptions","organizations_url":"https://api.github.com/users/maseev/orgs","repos_url":"https://api.github.com/users/maseev/repos","events_url":"https://api.github.com/users/maseev/events{/privacy}","received_events_url":"https://api.github.com/users/maseev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-04-15T20:38:10Z","updated_at":"2016-04-20T18:37:57Z","closed_at":null,"body":"Hi, guys.\r\n\r\nI created a simple client-server [app](https://github.com/maseev/clientserver) that sole purpose is to transfer 200 bytes messages as fast as possible between the client and the server.\r\n\r\nDuring the tests, it turned out that the throughput isn't that high as I expected (about 20-30 Mb/sec on read/write), even though I call ```flush``` method on every 100th message:\r\n\r\n![selection_001](https://cloud.githubusercontent.com/assets/3434800/14573847/63c80114-0379-11e6-9ba5-57f52e0ca8a1.png)\r\n\r\nThe [server](https://github.com/maseev/clientserver/blob/master/src/main/java/io/github/maseev/server/nio/Server.java) logic is pretty straightforward and doesn't do a lot (just batching messages and flush them when the counter hits the batch threshold).\r\n\r\nI didn't see much difference by changing ```WRITE_BUFFER_HIGH_WATER_MARK``` and ``WRITE_BUFFER_LOW_WATER_MARK``` values either.\r\nI could implement batching on the client side (that would definitely improve the overall throughput dramatically), but the thing is I can't really do this because the real client will be a third-party closed-source application.\r\n\r\nAccording to this [ticket](https://github.com/netty/netty/issues/1759), I'm not the only one who's trying to implement a smart batching algorithm.\r\nAm I missing something? Maybe there's some general approach how you can increase throughput in a Netty application which is supposed to transfer a gigantic amount of small messages (less than 300 bytes each)?\r\n\r\nI couldn't find any answers in the Netty in Action book, as well as on StackOverflow. Netty's documentation (user guide, to be precise, which by the way only describes basic topics without going into details) doesn't say much about this particular use case."},"comment":{"url":"https://api.github.com/repos/netty/netty/issues/comments/212551390","html_url":"https://github.com/netty/netty/issues/5152#issuecomment-212551390","issue_url":"https://api.github.com/repos/netty/netty/issues/5152","id":212551390,"user":{"login":"maseev","id":3434800,"avatar_url":"https://avatars.githubusercontent.com/u/3434800?v=3","gravatar_id":"","url":"https://api.github.com/users/maseev","html_url":"https://github.com/maseev","followers_url":"https://api.github.com/users/maseev/followers","following_url":"https://api.github.com/users/maseev/following{/other_user}","gists_url":"https://api.github.com/users/maseev/gists{/gist_id}","starred_url":"https://api.github.com/users/maseev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maseev/subscriptions","organizations_url":"https://api.github.com/users/maseev/orgs","repos_url":"https://api.github.com/users/maseev/repos","events_url":"https://api.github.com/users/maseev/events{/privacy}","received_events_url":"https://api.github.com/users/maseev/received_events","type":"User","site_admin":false},"created_at":"2016-04-20T18:37:57Z","updated_at":"2016-04-20T18:37:57Z","body":"@Scottmitch - I played with RecvByteBufAllocator a little bit. Used the [adaptive](https://github.com/netty/netty/blob/83c349ffa94d3992c4ee511d3625afc0c97c12bb/transport/src/main/java/io/netty/channel/AdaptiveRecvByteBufAllocator.java) one with the following parameters:\r\n\r\n```\r\n.childOption(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator(200, 128 * 1024, 512 * 1024))\r\n```\r\n\r\nAlso, I removed all batching logic and now I simply call ```ctx.flush()``` in ```channelReadComplete``` method. It doesn't seem to be performing any better. I still see that 20-30 Mb sec on read/write. \r\n\r\nMy network activity diagram with all these spikes looks like the city buildings. Is there anything else I can do about this issue? It seems that Netty makes its own mind about how and when do the reading, flushing and stuff like that. "}}