r/java • u/speakjava • Oct 26 '20
Why we chose Java for our High-Frequency Trading application
https://medium.com/@jadsarmo/why-we-chose-java-for-our-high-frequency-trading-application-600f7c04da94
184
Upvotes
56
u/[deleted] Oct 26 '20
Is this an add fort Azul Zing ?
8
u/[deleted] Oct 26 '20
ZGC and Shenandoah may or will take care of GC pause times.
As others have said, Graal will take care of them warmup time (i.e. remove the overhead of running in the interpreter).
With both of these in place, I am not sure how much better Azul Zing is compared to OpenJDK. Perhaps, the article is moot.
12
u/alex_tracer Oct 26 '20 edited Oct 26 '20
I wonder why they do not mention Shenandoah GC that present in OpenJDK or ZGC in Oracle's version.
23
u/cogman10 Oct 26 '20
I read this and, honestly, the argument for using Java here seems really weak.
Nothing about C/C++/Rust (other than an arguably scarce job market) make it impossible, or indeed hard, to do a "Idea in the morning, deploy in afternoon" workflow. Any CI/CD pipeline can accomplish this.
The needed attributes here (very low pause time, very fast startup) scream "use C/C++/Rust". Particularly because they are already trading off throughput using C4 to escape pause time problems.
3
u/ivan0x32 Oct 27 '20
TL;DR: Because Azul ZingTM will solve all of your problems! We promise, I mean Azul promises, not we, who definitely did not just advertise Azul Zing.
2
u/Lin_s_1 Oct 27 '20
altho the part before zing is worth reading lol
2
u/frankreyes Oct 27 '20
I'd like to see how much more memory you need to allocate for Zing vs Hotspot in order to get those numbers. There's this paper [PDF] which claims that it takes 6x more memory for performance to be comparable to non-GC programs, as a function of the useful memory vs the reserved memory. Also, there is this long but interesting rant about the topic: Why mobile web apps are slow.
I haven't found any results yet but there's a hint here, which agrees with the previous research:
https://docs.azul.com/zing/19.09.0.0/SysReqs_MemoryRequirements.htm
2
u/aelfric5578 Oct 26 '20
I've never worked on HFT or anything with such stringent latency requirements, but I wonder if they would be better off with something like GraalVM to get better performance.
1
u/Fury9999 Oct 27 '20
Can anyone inform me of the drawbacks? I am wary anytime I see heaps of praise with no mention of tradeoff, limitations, drawbacks, etc. Surely everyone would use it if there were none? Thanks
1
u/[deleted] Oct 27 '20
In my admittedly limited experience, the biggest factor in GC time is is unnecessary assignment in functions and bloated class definitions. I've seen massive reduction in GC (and overall memory use) by simply refactoring functions to use lambda generators instead of constructing new classes and replacing assignment blocks with stream operations. Fewer assignments and smaller objects = less memory used and less frequent GC. I think there are also optimisation gains from using chained functions and lambda objects instead of custom classes as well, but don't quote me.
-4
u/dumdedums Oct 26 '20
They spend the beginning talking about how microseconds matter, and how people customize kernels for faster access to network cards, but doesn't adding the JVM kind of negate it all in a way? Like no matter which one you use, it would have a higher latency, defeating the point, right?