Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many EJBs is too many?

I'm currently developing a large piece of software base on JavaEE. We have followed the general guidelines of JavaEE that says that each related set of operations should go into their own EJB. We currently have over 275 different EJB classes (Stateless Session beans). This number is most likely going to grow to at least double that number.

I would like to know if the EJB containers are designed to hold that many different kinds of EJBs. I'm interested in knowing if we are going to get some bad performance penalty from having too many such classes, and if some application server level tweaking can help alleviate those hypothetical problems.

We are using Glassfish v2 with JavaEE 5 on sun's Java 6, so advice on this particular platform would be most appreciated.

like image 323
LordOfThePigs Avatar asked Apr 19 '09 23:04

LordOfThePigs


People also ask

Why is EJB not used anymore?

For simpler web applications that can run inside less complex servlet containers like Tomcat, you wouldn't use EJB. The problem with EJBs is that they still bear all the blame they gained with early versions - most of which they honestly deserved , so nowadays they aren't so much popular.

How many types of EJB are there?

Types of EJBs. There are three types of EJBs: session beans, entity beans, and message-driven beans.

How do EJBs work?

The EJB container interacts directly with a message-driven bean—creating bean instances and passing JMS messages to those instances as necessary. The container creates bean instances at deployment time, adding and removing instances during operation based on message traffic.


2 Answers

EJBs should be fine-grained, so there is no problem with what you are doing if you are consistent in your design.

The EJBs are just classes, so there's nothing to worry about except for general load, which is orthogonal to the number of EJBs you have deployed.

If you are worried about performance, put in some monitoring or other performance metrics and see how things go as you add new features.

At the end of the day, would you rather maintain fewer classes with many methods, or many classes with fewer methods? I know which one I'd pick.

like image 186
davetron5000 Avatar answered Nov 30 '22 21:11

davetron5000


(Is there a way I can say "any at all" without being voted down?)

On a serious note, use as many as you need. My rule of thumb is (for both EJBs and classes in general) if you can't fully describe what the thing does in a class name of about three words, you've got it doing too much.

As far as performance goes, I suspect that if the system starts to suffer from "too many EJBs" you've got much bigger problems somewhere.

like image 33
Electrons_Ahoy Avatar answered Nov 30 '22 22:11

Electrons_Ahoy