
Java at Alibaba [pdf] - marktangotango
https://jcp.org/aboutJava/communityprocess/ec-public/materials/2017-02-14/Java_at_Alibaba.pdf
======
_old_dude_
There was a presentation with more info at last JVM Language Summit
[https://www.youtube.com/watch?v=X4tmr3nhZRg](https://www.youtube.com/watch?v=X4tmr3nhZRg)

The scary things is that they have implemented coroutine (generalized
async/await) by copying the stack back and forth instead of putting the stack
in the heap like in stackless python or in scheme.

~~~
srean
Could you please explain which stack you are talking about here. If I am not
wrong, Java language semantics does not have stack allocated variables, hence
my confusion. I sampled the video at random offsets but could not find the
location where coroutine implementation was discussed.

~~~
noelwelsh
It is the call stack that is being copied. It doesn't have to do so much with
stack allocated variables (which may be created in Java according to the whim
of the compiler) but with capturing the current state of a computation in a
relatively light weight manner, so that light weight threads / coroutines can
be saved and restored without the context switch and memory overhead of a full
thread. This is basically the old "green threads" implementation used in the
early JVMs.

The big idea behind this is the concept of a continuation, and a conversion
between programs in "direct style" (the way you normally write them) and
"continuation passing style" which makes control flow explicit. You could
start reading here if interested: [http://matt.might.net/articles/by-example-
continuation-passi...](http://matt.might.net/articles/by-example-continuation-
passing-style/) Or read about how Scheme compilers work to support first class
continuations, and the tricks you can play with them.

~~~
srean
That makes sense. I wasn't sure which stack parent was referring to, stack of
java activation records, the underlying C call stack of a JVM implemented in
C.

------
sago
Either I'm being very dense, or something doesn't quite make sense about these
numbers.

The slides say that on the busiest day of the year, they were serving around
175,000 transactions per second (126k of which, or maybe additionally, were
payments).

On the next slide it says they have 'millions of JVMs' running an
'insurmountable number' of requests.

Is each JVM really taking 10s+ per transaction? Even assuming those JVMs are
split between servers, messaging, caching, database, etc, I don't get why they
need millions of them to handle c. 200k transactions per second.

Needless to say, I am not DevOps, so feel free to set me right.

~~~
jjirsa
There’s probably a 10:1 or 100:1 page view to transaction ratio, and a 10:1 or
100:1 api request to page view ratio

200k transactions is a crazy number - a normal second for amazon is probably a
few thousand orders (4-5k). This is 20x higher.

~~~
jjirsa
This tweet suggests I’m probably off by quite a bit (overestimating amazons
orders)

[https://twitter.com/joelcomm/status/917229394212675584](https://twitter.com/joelcomm/status/917229394212675584)

That’s $3400/second in transactions for amazon, and certainly their average
price/transaction is more than $1:1

------
Cyph0n
Impressive stuff. They have basically forked their entire backend stack,
starting from the OS and moving upwards. I am particularly interested in how
much AliOS deviates from mainline Linux.

~~~
baybal2
>Alibaba Runs Millions of Custom JVMs

>They have basically forked their entire backend stack, starting from the OS
and moving upwards.

I doubt this being a cool thing. Sure, they are the second biggest IT employer
in the country, and have excess resources for everything, but...

A thing about big dotcoms - architects there try to use off-the-shelf software
for everything, even if the software is clearly unsuited for the task and its
use will require hacks and massive re-engineering.

Putting efforts to use of off-the-shelf software without modifications and
hacks greatly reduces all aspects of infrastructure support burden.

BUT, attempting to use of off-the-shelf software everywhere at all costs, that
will of course give you problems. And the bigger your are, the worse this is.
Read the article from a month ago how Alibaba got stuck with using MySQL for
mission critical tasks, and how much efforts they put to "unhack" it

~~~
disposable_123
Can you add a link to the article (Alibaba/mysql/etc ?!)

~~~
baybal2
A video from Alibaba's mysql specialist,
[http://www.highload.ru/2015/abstracts/1915.html](http://www.highload.ru/2015/abstracts/1915.html)

------
nullnilvoid
Alibaba is one of the heavy users of JVM. They have done some amazing
engineering work on jvm.

------
boulos
Cool presentation! I'm not sure why the submitter editorialized this title,
instead of the straightforward "Java at Alibaba" title from the presentation.

------
ninjakeyboard
Java is well suited to very large projects only because developers are
"commodity." With the modern language updates, the core java collections
library is really broken for modern multi-paradigm programming. There are no
true immutable collections in the core lib which makes Java really show its
age with the newer language features compared to other more modern languages
such as scala. Functions are bolted on as "Single Abstract Method" classes,
which make functions essentially syntactic sugar instead of a first class
language feature. Java9 makes some improvements but I wouldn't consider using
Java for any new projects unless I was at a big enterprise that can only hire
really cheap developer and needs to hire a whole lot of em really fast.

~~~
andonisus
What kind of applications are you building that really require immutable
collections and functional programming? In my opinion, Java is best suited for
running web servers (and thus microservices), where the work doesn't really
require any functional programming at all.

~~~
erokar
Web servers' performance benefit from concurrent programming models.
Concurrent programming is certainly possible in Java, but Java/JVM is not
particularly well suited for it compared to other languages/VMs, e.g. Erlang.

~~~
andonisus
The concurrency model you use is heavily dependent on the scale of your
application. Java is just fine for the typical web server stack.

------
purplezky
Does anyone know if their zprofiler is in the public domain?

