@nicolas_frankel
Shorten all URLs:
Quarkus, Kotlin,
Hazelcast and GraalVM
Nicolas Fränkel
@nicolas_frankel
Me, myself and I
 Former developer, team lead, architect,
blah-blah
 Developer Advocate
@nicolas_frankel
Hazelcast
HAZELCAST IMDG is an operational,
in-memory, distributed computing
platform that manages data using
in-memory storage and performs
execution for breakthrough
and scale.
HAZELCAST JET is the ultra
fast, application embeddable,
3rd generation stream
processing engine for low
latency batch and stream
processing.
@nicolas_frankel
The Cloud “Gold” Rush
@nicolas_frankel
Why the Cloud?
1. Cost management
2. Flexibility
• “You pay for what you use”
@nicolas_frankel
The way to the Cloud
1. “Lift and shift”
2. “Rewrite all the things”
3. The middle path?
@nicolas_frankel
Lift and Shift
 The Cloud is just somebody else’s
computer
 Relatively easy
• “Just” containerize the app
 Run can be (a lot) more expensive than
on-premise!
• Worst case, all hell breaks loose
@nicolas_frankel
12-factors app
1. There should be exactly one codebase for a deployed service with the
codebase being used for many deployments.
2. All dependencies should be declared, with no implicit reliance on system
tools or libraries.
3. Configuration that varies between deployments should be stored in the
environment.
4. All backing services are treated as attached resources and attached
and detached by the execution environment.
5. The delivery pipeline should strictly consist of build, release, run.
6. Applications should be deployed as one or more stateless processes with
persisted data stored on a backing service.
@nicolas_frankel
12-factors app
7. Self-contained services should make themselves available to other
services by specified ports.
8. Concurrency is advocated by scaling individual processes.
9. Fast startup and shutdown are advocated for a more robust and
resilient system.
10. All environments should be as similar as possible.
11. Applications should produce logs as event streams and leave the
execution environment to aggregate.
12. Any needed admin tasks should be kept in source control and packaged
with the application.
@nicolas_frankel
A “standard” JVM web application
# Factor Issue
2 Declared deps App server is a dependency that is not
provided
3 Configuration Application server dependent
9 Fast startup The JVM takes a long time to startup
10 Streaming logs Write in different files
@nicolas_frankel
More startup performance hits from frameworks
Reflection Classpath scanning
@nicolas_frankel
Rewrite the app
1. Cost
2. Delay
3. Risks
4. Team organization
@nicolas_frankel
The middle path
 Reuse existing code
• e.g. annotations from Spring/Java EE
 Change the way they are used
@nicolas_frankel
GraalVM
 JVM platform by Oracle
 Polyglot
• Java, Python, JavaScript, R, Ruby, C
 Truffle
• Programming Language
implementation framework
@nicolas_frankel
Substrate VM
 Create native executables from bytecode
 Ahead-Of-Time compilation
 Some limitations
• Needs to be configured for traditional
reflection
• Not cross-platform
• etc.
@nicolas_frankel
JVM vs. native executable
JVM Native
Memory consumption +++ +
Startup time +++ +
Write Once Run Everywhere ✓ ✘
Adapt to the workload ✓ ✘
@nicolas_frankel
Common approaches
1. GraalVM native-image friendly
2. Build-time reflection generation
@nicolas_frankel
“Cloud-native” frameworks
( )
@nicolas_frankel
The use-case: a URL shortener
 Traditional approach
• Create a bijection between
⁃ Space(URL)
⁃ Space(short)
• Collisions handling
@nicolas_frankel
URL shortener: alternative approach
 Generate random short links
 Re-generate if already existing
 Store mappings
 Trade-off: CPU time vs. storage
@nicolas_frankel
Stack
 Legacy Java EE application
 Written in Kotlin
 Using JAX-RS
 Storing data in Hazelcast IMDG
@nicolas_frankel
AS-IS state
@nicolas_frankel
TO-BE state - Development
@nicolas_frankel
TO-BE state - Production
@nicolas_frankel
Talk is cheap, show me the code!
@nicolas_frankel
Recap: walk the middle path when possible
 Use existing code
 Use frameworks that know how to
leverage previous framework’s code
 Better ROI 4TW!
@nicolas_frankel
Thanks for your attention!
 https://blog.frankel.ch/
 @nicolas_frankel
 https://bit.ly/quarkus-hazelcast
 https://bit.ly/url-shrtnr

OSCONF Hyderabad - Shorten all URLs!

Editor's Notes

  • #23 @startuml database "Hazelcast IMDG" as hz actor User as user node "JVM" { node "Tomcat" { interface HTTP artifact "application.war" { control "Controller" as ctrl artifact "hazelcast-client.jar" as hzclient } artifact "servlet.jar" as servlet artifact "jax-rs.jar" as jaxrs artifact "catalina.jar" as catalina } } user -right-> HTTP HTTP -down- catalina catalina - ctrl ctrl - hzclient hzclient - hz ctrl .down.> servlet catalina .down.> servlet ctrl .down.> jaxrs catalina .down.> jaxrs @enduml
  • #24 database "Hazelcast IMDG" as hz actor User as user node "JVM" { interface HTTP artifact "application.jar" { control "Controller" as ctrl file quarkus file "quarkus-hazelcast-client" as hzclient file "servlet" as servlet file "jax-rs" as jaxrs } } user -right-> HTTP HTTP -down- quarkus quarkus - ctrl ctrl - hzclient hzclient - hz ctrl .down.> servlet quarkus .down.> servlet ctrl .down.> jaxrs quarkus .down.> jaxrs
  • #25 database "Hazelcast IMDG" as hz actor User as user interface HTTP artifact "application.exe" { control "Controller" as ctrl file quarkus file "quarkus-hazelcast-client" as hzclient file "servlet" as servlet file "jax-rs" as jaxrs } user -right-> HTTP HTTP -down- quarkus quarkus - ctrl ctrl - hzclient hzclient - hz ctrl .down.> servlet quarkus .down.> servlet ctrl .down.> jaxrs quarkus .down.> jaxrs