Skip to content

Instantly share code, notes, and snippets.

@misTrasteos
Last active December 8, 2021 18:59
Show Gist options
  • Save misTrasteos/0d70da25e3db9101b4d47d20f86ee566 to your computer and use it in GitHub Desktop.
Save misTrasteos/0d70da25e3db9101b4d47d20f86ee566 to your computer and use it in GitHub Desktop.

How to ...

How to run

jbang run https://gist.github.com/misTrasteos/0d70da25e3db9101b4d47d20f86ee566#file-quarkusrest-java

How to generate load

echo "GET http://localhost:8080/MyObject" | vegeta attack -duration=1s -rate=1000 | vegeta report --type=text

How to get an object histogram

jcmd $(jps | grep GeneratedMain | cut -d " " -f1) GC.class_histogram -all | grep MyObject

How to gc

jcmd $(jps | grep GeneratedMain | cut -d " " -f1) GC.run

Test

  • Start Quarkus Rest server
  • Make a couple of request using curl http://localhost:8080/MyObject
  • Ensure there are two instances of MyObject using the histogram
  • Force a collection
  • Ensure there are not MyObject instances in the heap
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.quarkus:quarkus-resteasy:2.5.1.Final
//DEPS io.quarkus:quarkus-resteasy-jackson:2.5.1.Final
//JAVAC_OPTIONS -parameters
//JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager
import io.quarkus.runtime.Quarkus;
import javax.enterprise.context.ApplicationScoped;
import io.quarkus.runtime.annotations.RegisterForReflection;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.function.Supplier;
@Path("/MyObject")
@ApplicationScoped
public class QuarkusRest {
// I need this annotation as the bean is empty
@RegisterForReflection
class MyObject{}
@GET
@Produces(MediaType.APPLICATION_JSON)
public MyObject getMyObject() {
return new MyObject();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment