
Vert.x native: how to run a JVM app in 10Mb of RAM - based2
https://www.jetdrone.xyz/2018/08/10/Vertx-native-image-10mb.html
======
old-gregg
I haven't been following Java community in a while, can someone clarify this
for me please: so the benefit of "thin" JVM comes from GraalVM or Vert.x? I
looked at [https://vertx.io/](https://vertx.io/) and it says nothing to me, I
have no idea what a "reactive" application is. Is it an async event loop
library? And then there's Polyglot, so now there are 3 new things in the
picture.

What do I need to have a simple "hello world" CLI Java app which starts within
25ms and doesn't eat more than 10MB of RAM? Is GrallVM enough?

~~~
yunyu
Vert.x is a framework for developing server applications using an event loop
(think Node.js but for the JVM, with the ability to fallback to normal
threads). If you've heard of Spring Boot or Spark, it's a lighter/faster
alternative to those (which are generally based off of heavier webservers like
Tomcat or Jetty).

Graal compiles JVM bytecode to native code, so that's the critical factor for
your CLI app use case. You'd only need Vert.x if you were writing a server.

~~~
needusername
> Spring Boot

Vert.x is nothing like Spring Boot. Spring Boot combines Spring with
autoconfiguration and the ability to run in its own container. Spring Boot can
run on Undertow which the other branch of JBoss marketing promotes a lighter
weight than Netty.

~~~
Areading314
But they're both frameworks for writing a server right?

~~~
needusername
Not Spring Boot. Spring Boot is a framework for implementing a server side
application. For example you use Spring Boot to implement a RESTful server
side application including persistence and security. You do not use Spring
Boot to write an HTTP server, instead Spring Boot uses an existing HTTP
server.

~~~
threeseed
Vert.x uses an existing HTTP server as well: Netty.

~~~
needusername
I look at Netty as an async IO library. You use Netty to build your own
servers. Yes, I know, Netty ships with an HTTP client and server.

------
zmmmmm
Have recently been trying out Micronaut [1] which is a similar idea. However
Micronaut does not use Graal and manages a very similar memory footprint [2].
So I don't think you necessarily need Graal to achieve just that.

I have actually been surprisingly happy with my initial experience with
Micronaut. It is clearly engineered as a next-generation framework where all
the defaults are set to exactly what you want to build small microservices
right from the start. I am using Groovy and it still starts up in ~ 1 second
with minimal memory use.

[1] [http://micronaut.io/](http://micronaut.io/)

[2] [https://jaxenter.com/micronaut-framework-
microservices-14245...](https://jaxenter.com/micronaut-framework-
microservices-142457.html)

~~~
needusername
It looks as if Micronaut is using compile time class generation through
annotation processors. This explains a lot as this probably removes a lot of
not all of their reflection at startup and runtime.

This seems to be the right way to do things in Java to me since I learned
about Dagger
[https://github.com/google/dagger](https://github.com/google/dagger)

------
Fnoord
Bitcoin as example. Ugh. Anyone got a more interesting use case?

Using Unifi Controller in Docker right now, uses 300 MB for Java (OpenJDK 1.8
x86-64) and 63 MB for Mongo DB. Haven't compared with UNMS though which needs
to run in an Ubuntu 16.04 VM.

~~~
johnbellone
I sold my UniFi gear because I shouldn’t have to install software on a server
or buy an accessory to get the full features of my device. Their gear is
great, but there are several lines that can’t be managed from the same control
plane. It was infuriating.

~~~
old-gregg
> It was infuriating.

What part? The Unifi controller software is not for "a device", it's for
multiple devices, imagine having to manage SSIDs / auth for primary+guest Wifi
network across just 5 access points. I don't think anyone would enjoy logging
into 5 separate AP UIs. Add your Unifi gateway + switches to that and the need
to have a unified control plane is pretty obvious.

If you want self-contained, that's a separate product line, usually prefixed
with "Edge". What's "infuriating" about having two product lines I don't
understand. Honda makes motorcycles, boat engines, cars and jets and nobody
gets pissed about it.

~~~
blattimwind
GP is saying the exact opposite of what you think he's saying

> there are several lines that _can’t_ be managed from the same control plane.

------
std_throwaway
Minor typo in the title: "10Mb" would be 10 Megabits.

They really mean "10 MB" as in 10 Megabytes.

~~~
sadamznintern
Its pretty clear from context what it means

~~~
std_throwaway
Megabits is often used in the context of RAM.

~~~
icedchai
At the hardware (RAM chip) level, yes. At the software level, basically never.

------
beders
Vert.x is pretty sweet. It's basically like Node.js but automagically multi-
threaded and will also play nicely with fibers.

Performance is usually way better than any Spring-driven app.

------
th3iedkid
Was trying to seek akka support(for native-image), but looks it has sadly been
left behind [https://discuss.lightbend.com/t/akka-and-graal-s-native-
imag...](https://discuss.lightbend.com/t/akka-and-graal-s-native-image-
tool/940)

~~~
spockz
That seems more like the work just hasn’t been done yet, not that is has
explicitly been left behind as your phrasing suggests. In fact, multiple
requests to file issues/bugs have been made in that thread.

