0
votes

When using Java sockets, is msg always send with buffer size lenght? (When i send only 300bytes, is it anyway send in package with for example 1024 bytes size?) And what size buffer is the best option? What is a diffrence betweend 512 bytes, and 8k bytes size?

I don't want to create few threads, so I will ask here. Is java standard tcp serversocket performance enought for handling 100 connestions with 10-20 msg/s smooth?

1

1 Answers

1
votes

Most machines have an MTU of 1500 bytes. This means if you send some multiple of this, it will break it into packets. If you have less than this, it may hold the data for a short period of time to see if more data will be sent to reduce the overhead of sending small packets. see Nagle's algorithim for more.

There is not much difference between sending 16 lots of 512 bytes or 8 KB all at once as the OS and network adapter will do some coalescing by default.

What really matters is the bandwidth of your connection between you and the other end. if you have up to 2000 messages per second and they are 512 bytes, you need a 10 Mbit/s line (2000*512*8 = ~8 Mbit)

In terms of numbers, you shouldn't have a problem up to about 10,000 connections, or around 500,000 msg per second. If you have a 1 Gbit/sec line you should be able to get 100 MB/s easily. If you have a 10 Gbit/s line you should be able to get more but you might have trouble using all the bandwidth unless you are careful.