What Is Faster--EJBs Or CDI? A JMH Benchmark

"Premature Optimization Is The Root Of Some Evil"

This screencast is an outtake from the Java EE 7 Testing online workshop. Bootstrap Java EE 7 and Effective Java EE 7 (explains how a real Java EE application looks like) are also available online.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW online workshop: WebStandards Igniter (online)

Airport MUC workshops: Java EE 7: Bootstrap, Effective, Architectures, Web, React and Angular, Testing and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Comments:

Just curious, is @Stateless to @RequestScoped really a valid comparison? I'm thinking @Stateless to @ApplicationScoped would be more of an apples-to-apples test. Thoughts?

Posted by Michael Remijan on December 07, 2015 at 07:16 PM CET #

Thank you Adam. I had never used JMH before. It looks like a very useful tool, and I'll definitely be trying it out.

How would you compare JMH to using something like jmeter?

Posted by John on December 09, 2015 at 05:18 PM CET #

Hello Adam! Thank you very much for the video. I was inspired by your work and just repeat the benchmark on WebSphere Application Server 8.5.5.7, but adding the Spring Framework version. The my results are the following:

Benchmark (implementation) (path) (port) (server) Mode Samples Score Error Units
p.d.r.b.RestImplementationsBenchmark.messages ejb /message 9080 localhost thrpt 80 1793,453 - 26,130 ops/s
p.d.r.b.RestImplementationsBenchmark.messages cdi /message 9080 localhost thrpt 80 1505,911 - 11,167 ops/s
p.d.r.b.RestImplementationsBenchmark.messages spring /message 9080 localhost thrpt 80 1776,184 - 39,421 ops/s

If the table is corrupted just the numbers:

ejb thrpt 80 1793,453 - 26,130 ops/s
cdi thrpt 80 1505,911 - 11,167 ops/s
spring thrpt 80 1776,184 - 39,421 ops/s

As we all can see, EJBs have the same performance as Spring, but CDI is much slowly.

Posted by Pavel Samolysov on December 11, 2015 at 01:50 PM CET #

Adam and colleagues, let me share my benchmark source code and some results on IBM WebSphere Application Server for z/OS (executing on a 'small' IBM Mainframe - z BC 12) and on IBM WebSphere Application Server ND (executing on Windows 7): https://github.com/samolisov/spring-vs-ejb-vs-cdi-benchmark

The code is similar like Adam's one but a Spring MVC version is added.

Posted by Pavel Samolysov on December 25, 2015 at 07:49 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
realworldpatterns.com
Online Workshops
...the last 150 posts
...the last 10 comments
License