i need to make low latency server, where raw data throughput is less important than the ability to handle thousands of simultaneous connections. I don't know what language to use. Java is simpler, development will be faster, nice interface for all what i need + good support for networking (JAVA NIO and selector class). But actually i don't have much experience with java beside programming, so even if i read things like java isn't today slower then native C/C++, still have some doubts about the performence, because c/c++ is compiled to binary code, but java .class files are interpreted, so there MUST be overhead in that translating.
EDIT: App will be server for support real-time on web applications (like chat, etc.)
Usually people want a low latency application so I don't know what you mean by low latency.
so even if i read things like java isn't today slower then native C/C++
Its still slightly slower, just not enough to matter most of the time.
For example, network IO is network IO regardless of the language you use. e.g. The language won't make your network faster or slower except in the most extreme low latency cases.
, because c/c++ is compiled to binary code, but java .class files are interpreted,
Java is compiled to native code at runtime so both system run native code in the end.
so there MUST be overhead in that translating.
There is a overhead on startup. But once the application is running, the impact is much less.
Have someone high latency app programmed?
If your network has high latency, your language is less likely to matter.
What you mean is better to use for that type of application?
I suggest you use the language you are most comfortable with.
App will be server for support real-time on web applications
In that case, your network latency is likely to be far higher than that of your application if you have coded it properly.
To give you a broad idea, a typical internet connect has a latency of 5 - 20 ms. A typical user can only react with a latency of 50 ms. A server with a latency of 20 - 50 ms can be written in just about any language. A server with a latency of 200 - 500 micro-seconds can be written in Java or C++. If you want less than 100 micro-seconds, including the latency to the client, you are looking at specialist hardware and some C++ code for your core engine. In that case, the server and the consumer will probably be in the same building, if not the same rack.
Most JVM implementations are using just in time (JIT) compilation techniques, so they can be nearly as efficient as ahead-of-time compiled programs (in C++ or Ocaml).
I am taking a Linux point of view below.
The JVM will usually translate to machine code (incrementally, and once) the hot spots of your .class
bytecode files.
You might consider using other languages like Ocaml (using Ocsigen for the web part) or Opa
Of course, you could always rewrite the very critical part of your application in C (or in C++) and call that from Java (or Ocaml, or other language) code.
You could generate machine code at runtime, tailored to the actual web job. Look into asmjit or GNU lightning. You could generate C code (at runtime, like Bismon -described in this draft report and funded by CHARIOT - does) then compile it as a plugin and dlopen(3) and dlsym(3) it. See also this answer. A simpler example of run-time C code generator is my manydl.c (for Linux).
You could consider using HTTP server libraries, such as libonion or POCO or Wt
You might consider coding your web application in Common Lisp using SBCL. There are many libraries available from https://common-lisp.net/ - including web related libraries.
You could use GNU guile or Python to code your server. You can easily find plugins or extensions accelerating web services.
Of course the observed latency depends upon your hardware. It won't be the same on a cheap RaspberryPi and on a high-end supercomputer listed on top500.Org
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With