Could Go Defeat Java in the Cloud Computing Era?

With the emergence of new asynchronous frameworks and languages such as Go, the Alibaba tech team now wonder whether Java is still applicable to the latest cloud scenarios

Introduction

Quick Start

curl https://gosling.alibaba-inc.com/sh/enable-wisp2.sh | sh
ajdk 8.7.12_fp2 rpm
sudo yum install ajdk -b current #
java -XX:+UseWisp2 .... #

Overhead of Multithreading

Misunderstanding 1: Context Switching is Caused by Accessing the Kernel

pipe(a);
while (1) {
write(a[1], a, 1);
read(a[0], a, 1);
n += 2;
}

Misunderstanding 2: The Overhead of Context Switching is High

Overhead

Relationship Between Asynchronization and Coroutine

private void writeQuery(Channel ch) {
ch.write(Unpooled.wrappedBuffer("query".getBytes())).sync();
logger.info("write finish");
}
private void writeQuery(Channel ch) {
ch.write(Unpooled.wrappedBuffer("query".getBytes()))
.addListener(f -> {
logger.info("write finish");
});
}
suspend fun Channel.aWrite(msg: Any): Int =
suspendCoroutine { cont ->
write(msg).addListener { cont.resume(0) }
}
suspend fun writeQuery(ch: Channel) {
ch.aWrite(Unpooled.wrappedBuffer("query".toByteArray()))
logger.info("write finish")
}

Performance Comparison: Manual Asynchronous Programming vs WISP Programming

Write a New Application Based on Existing Components

Develop a New Application from Scratch

Adapted Workload

Project Loom

FAQs

Why is the Overhead Small in Case of Scheduled Coroutines?

Why Doesn’t WISP 2 Use ForkJoinPool to Schedule Coroutines?

What Do You Think of Reactive Programming?

What are the Main Constraints at the Moment?

Alibaba Tech

First-hand & in-depth information about Alibaba's tech innovation in Artificial Intelligence, Big Data & Computer Engineering. Follow us on Facebook!