image blog java containerization
July 22, 2020

Pros and Cons of Java Containerization

Microservices
Java Application Development

Everywhere you look today, you see people talking about Docker, Kubernetes, microservices, or CI/CD. But at the heart of those technologies and approaches lies a central concept — containerization. In this blog, we look at the benefits of Java containerization, and offer a comparison of pros and cons for containers vs. application servers for Java applications.

Let's get started with the basics.

Back to top

What Is Java Containerization?

Java containerization is the process of packaging a Java service or application within a software container. This container typically includes everything needed to execute that Java package.

Containers are often used in the creation of microservices-based applications, and allow for easily-replicable and scalable services within an application.

Back to top

4 Benefits of Java Containerization

There are a number of benefits for Java containerization, but the biggest four are scalability, flexibility, resilience, and cost. It's important to note that Java containerization, while beneficial, isn't a one size fits all solution (as we'll cover in the next section).

1. Granular Scalability

Java containerization means that both technology, and teams are broken up into smaller sizes, often with one or two teams responsible for production, deployment, scalability  issues, performance downtime, etc. From a managerial perspective, that makes it easier to scale up and down teams as needed.

On the software side, that means your application can scale to meet demand as it appears, and scale down once it's no longer needed.

2. Flexibility

Containers also give developers the flexibility to experiment and try new things. That can mean different languages and their accompanying tools, or even the freedom to try new techniques, protocols, or service meshes.

3. Resilience

Resilience should have an asterisk here. If done well, Java containerization means you can implement service meshes, or resiliency patterns like circuit breakers. That means a lot less exposure to risk for the application at large, since, ideally, a single service can fail without  causing a cascading failure for your application.

4. Cost

Because containerized applications can be scaled horizontally, applications (in many cases) no longer need the powerful hardware that enables a high vertical performance ceiling.

Back to top

Pros and Cons of Containerization vs. Application Servers for Java Applications

For Java, the central question of containerization comes down to whether or not the benefits of containerization are worth the hassle of spending the time and money needed to make that change. After all, with many application servers you get full access to the hardware virtual machine. With these, you also get shared caches and pools because you have access to all the memory.

That means that all the application instances or threads can share the same data. You don't have a lot of copies, so there's less overhead. Then you also have relational databases, which are more familiar for a lot of developers, and, again, you typically get full control over how those databases are used.

Container vs. Application Server Pros

Container

Application Server

Granular scalability

Full access to hardware

Flexibility to experiment

Shared caches and pools

Better resilience

Simple storage

Lower cost

Latency

But one of the big risks for using an application server is that if that app server crashes, your application is crashing. That means that you need to deploy clustering, which is expensive, and carries the risk of bad performance if you have a resource hog within that cluster. You also have to have a vertical hardware ceiling that can accommodate heavy load, but goes underutilized a majority of the time. 

Container vs. Application Server Cons

Container

Application Server

Tyranny of choice

High impact crashes

More moving parts

One bad app can hurt all apps

Less familiar for devs

Planning for capacity is difficult

Persistence

Language and platform limitations

Using an application server also typically means you're locked into a language and platform. There's less ability to experiment with other languages, features, technologies, etc. But that also means that it's functionally less complex, since one developer can theoretically work on another area of the application with no language or technology barriers.

Back to top

Final Thoughts

Making the choice to containerize or develop a containerized Java application isn't as clear cut a decision as it seems. After all, containers, just like microservices, can add complexity to an application and increase the chance at developing a big ball of mud.

Our advice is to weight the pros and cons of containerization carefully, and decide what the right approach is for your team.

Additional Resources

Want to learn more about the history of containers, what benefits they offer for Java applications, and what the future looks like for container technologies like Docker? This webinar from Rod Cope, CTO at Perforce Software, is a must-watch.

Looking for additional resources on containers, container technologies, and microservices? These resources are a great place to start.

Are redeploy times driving your consideration of transitioning your application to microservices? Be sure to check out JRebel. It allows Java developers to completely skip the redeploy process. meaning developers can spend more time coding, and less time waiting. Want to try it out on your project? Click the link below to grab a free 14-day trial.

Try JRebel Free for 14 Days

Back to top