How is Dropwizard production-ready?
Quick implementation
- Generate a skeleton project.
- Implement a resource.
- Implement a health check.
- Deploy!
Easy testing
public class WizardResourceTest {
@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
.addResource(new WizardResource())
.build();
@Test
public void testWizardHasAName() {
final Wizard wizard = resources.client()
.target("/wizards")
.request()
.get(Wizard.class);
Assert.assertEquals("Saruman", wizard.getName());
}
}
Simple deployment
java -jar path/to/package.war server
Low ops overhead
- Requires only a JVM.
- Runs on almost any type of server OS.
# Debian-based:
apt install openjdk-8-jre-headless
# Redhat-based:
dnf install java-1.8.0-openjdk
Simple to monitor
- Complexity of monitoring is moved from monitoring system to the application.
- Health checks as one-stop solution for monitoring status.
curl http://localhost:8081/healthcheck
Simple to monitor - resource performance
@Path("/wizards")
@Produces(MediaType.APPLICATION_JSON)
public class WizardResource {
@GET
@Timed
public Wizard getFortune() {
return new Wizard();
}
}
Simple to monitor - application metrics
final Graphite graphiteClient = new Graphite("localhost", "2003");
final GraphiteReporter reporter = GraphiteReporter
.forRegistry(environment.metrics())
.prefixedWith("dropwizard-demo")
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.filter(MetricFilter.ALL)
.build(graphiteClient);
reporter.start(10, TimeUnit.SECONDS);
Simple to monitor - processed metrics