Java puzzle (Single threaded client server)

Without creating additional threads, create a ServerSocket on a random unused port, a client Socket connecting to localhost and a server Socket.

Part 1) Send messages from client to server and back again. (This can be useful in unit tests) [Click for sample solution]

Part 2) Do the same with blocking NIO. [Click for sample solution]

Part 3) Benchmark how many GB/s per second you can transfer this way. [Click for sample solution]

Part 4) Measure the typical and 99.99% round trip latency, and estimate how much garbage is produced.

For bonus points try the same with Async NIO2 in Java 7.

I will add a solution Nov 29th (after a week)

Comments

  1. loopback Blocking socket/NIO the same ~65(in or out) Mb/s with payload 1460 bytes
    network Blocking socket/NIO ~1/0.7 Мb/s with payload 1460 bytes

    ReplyDelete
  2. @Unknown, Are you sure that Mb/s and not MB/s? Even so I would expect 65 MB/s or more on a 1 GB ethernet.

    ReplyDelete
  3. Mb - means megabyte not megabit.

    ReplyDelete
  4. It quite common to write network bandwidth as 100 Mb/s per 1 Gb/s (b for bits) where as disk transfer rates are usually in MB/s (B for bytes)

    IEEE-1541 recommends b for bits and B for bytes.

    ReplyDelete

Post a Comment

Popular posts from this blog

Java is Very Fast, If You Don’t Create Many Objects

System wide unique nanosecond timestamps

What does Chronicle Software do?