Adam Bien's Weblog

The EJB Overhead--Screencast

What is the actual overhead of an EJB?

See also other screencasts at: or subscribe to

See you at Java EE Workshops at MUC Airport!

NEW 2016: Java EE 7 Workshops: Bootstrap, Effective, Architectures, April, 4th-6th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7 and NEW: Java EE 7 Testing are available for streaming


A book about rethinking Java EE Patterns


Hi Adam,

thank you for this post - evtl. very usefull to avoid some endless discussions...

A CDIBean with manual Transcations would be interesting in this comparison.

Posted by Thomas on January 31, 2013 at 01:22 PM CET #

So why don't you show the difference between simple stateless and stateless EJBs with TransactionAttribute set to false? I mean what is the value of the comparison when you compare different component containers but not configure them to have similar behavior?

Posted by Christian Beikov on January 31, 2013 at 08:17 PM CET #


An EJB with TransactionAttribute set to false is pointless: I always need transactions in my projects. The EJB performance, even with TX set to on, is stunning: 15k transactions per second. More realistic scenario would be with access to JPA and with several other components injected.

My point is: ask in a meeting about how many TX per second you will get with an EJB. You will never get: 15k / second as an answer.

However: you are right as well: my screencast is garbage from scientific point of view (I had to restart the servers, clear the pools etc.), but it is good enough to shorten endless discussions :-)

thanks for your comment,


Posted by on January 31, 2013 at 08:25 PM CET #

@Adam You could try to evaluate the differences between simple POJOs and EJBs without transactions and in addition to that compare POJOs that use e.g. a UserTransaction with EJBs that use transactions.

IMO that would be valueable, because then we can see the differences between the component containers. Although I don't really think that CDI is really faster since as far as I know it has a more complex resolution process thus resulting in worse performance compared to EJB.

Of course you mostly need transactions and the Tx/sec is probably more interesting. My point was not only about the testing of EJBs without transactions, but in addition to that also the transactional scenario.

By the way, since you pointed out that you always need transactions, do you even use transactions for simple data access? I preferre to set TransactionAttribute to SUPPORTS on data access methods.

Posted by Christian Beikov on February 01, 2013 at 01:16 AM CET #

Adam i thanks you for your doings,please i really have a challenge which left me disturbed for three weeks now .i want to use Entity-Beans from Database and session bean for entity class in my desktop application.if i want to create session bean for my remote App this error will be show on my netbean 7.3 rc1 "EJB Remote Interface depends on JPA Entity classes. JPA Entities are inaccessible if they are located in testin."

1. some said that i should create a entity bean in a class library
2.add library to my created session bean which now support remote desktop App.
3.use InitialContext to look up the session bean ,invock the session's method and run the App.
But if i try to insert data ,it will not reflect in my Microsoft Sql database.

i am new to ejb3 please throw more light on it using screen-Cast .Thank you Adam

Posted by Bartholomew on February 01, 2013 at 04:00 AM CET #

Hi Adam,

I tried to make same test on my machine because want to see the throughput but it seems I need another configuration for my Glassfish :) Can you post what you configured in Glassfish (Java Heap and so on...) and what your Hardware configuration is?


Posted by Dirk Dreyer-Hochstein on February 08, 2013 at 12:34 PM CET #


I ran the test on / with:

- "stock" GlassFish without any changes
- JDK 1.7u12 (Not entirely sure about that, it could be also JDK 1.6)
- JMeter + GF on the same machine
- MBP, Mountain Lion 2.7 GHz, 16 GB RAM (amount of RAM shouldn't matter), encrypted hard drive.

However: the point of the screencast is not the amazing EJB performance, rather than the small difference between EJBs and CDI beans,

thanks for testing! What are your numbers?


Posted by on February 11, 2013 at 11:06 AM CET #

Almost 20 years of Java experience and you still haven't filled code templates in Netbeans?

Posted by Dariusz on February 14, 2013 at 11:40 PM CET #

Hi Dariusz,

I try to avoid NetBeans wizards and custom templates in my workshops and screencasts. Reason: in my opinion it is harder for the audience to recap what I actually did. Do you think it is a bad idea?

I'm working with Java since 1995, but I started to use NetBeans around 5.0. Before 5.0 I really didn't like it... Around 2001 I was an Eclipse fanboy.

What is the point of your comment? Should I prepare the code upfront and shorten the screencasts?


Posted by Adam Bien on February 17, 2013 at 08:13 PM CET #

Well, my comment maybe wasn't too thoughtful and there is no much of "the point". I was kind of surprised that you don't run preconfigured IDE.

But when I think more a about it, it seems to me that it wouldn't hurt to follow some best practices like keeping irrelevant comments out of code. That way there would be less "noise".

On the other hand, the screencast was clear, so there's no need to improve on details. So I guess my comments are quite pointless, better spend time on new posts than responding to me ;)

Posted by Dariusz on February 19, 2013 at 12:08 AM CET #

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