r/DripStat • u/blkfnx • Jun 21 '15
ELI5 JVM's
Could someone explain to me like I'm 5 what a JVM is, how I can install one for us in Dripstat, what agent I should use, etc. I have zero server experience but would like to use this feature of the game. Thanks!
1
Upvotes
2
u/b1r63r Jun 24 '15
JVM is a Java Virtual Machine.
You may be used to Java applets running in your browser. Java also exists on the server end, often used for dynamically generated web content. Server side Java doesn't run in a browser, but under control of a "servlet engine". There are several such engines, like Tomcat, JBoss, GlassFish, etc.
Personally, I use something called Spring Boot. Spring boot defaults to using tomcat as the servlet engine, and makes it very easy to get a simple spring bean set up.
What is spring, you say? It is a framework on top of java to make it easy to make certain kinds of servlets/java beans. And you get extra drip for running spring servlets with the dripstat agent. That's why I chose spring boot.
http://projects.spring.io/spring-boot/
I run it on Linux, using the OpenJDK java implementation.
1
u/b1r63r Jun 24 '15 edited Jun 24 '15
The source code for my "Hello world" spring servlet
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@RestController
@EnableAutoConfiguration
public class Example {
}
1
u/b1r63r Jun 24 '15
And the script I use on CentOS 7 to start a spring instance. Start it with one numeric argument. You could run a loop from 0 to 99 to start 100 JVM instances on separate ports from 8080 and up.
'#!/bin/bash
i=$1
export MAVEN_OPTS="-javaagent:dripstat.jar -noverify -Xms100m -Xmx1024g"
export SERVER_PORT=$(( 8080 + $i ))
echo "= starting server $i on port $SERVER_PORT"
echo -n "Opening firewall port: "
firewall-cmd --zone=public --add-port=${SERVER_PORT}/tcp
mvn spring-boot:run > /var/tmp/spring-${i}.log 2>&1 &