• Post Reply Bookmark Topic Watch Topic
  • New Topic

Static on the JEE server

 
Markus Schmider
Ranch Hand
Posts: 137
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo,

I have a running argument with colleague.
His application has a front of EJBs. All those delegate the real work to classes which have only static methods.
His reasoning is that this improves performance because no objects have to be instantiated.
Of cause we know that this is not valid because the JEE server maintains a pool of EJBs which are reused, when you stick to the JEE programming model.
My point is that he actually creates artificial bottlenecks in the application which is supposed to support multiple users, because he effectively creates singletons.
Preliminary performance tests have already shown that latency increases dramatically when several users try to use the system.
Unfortunately we have a management which has near zero knowledge of software development and tends to believe everything my colleague says.
So I am looking for some reliable source that shows, that you dont do statics in JEE applications.
I have googled a bit and have already read some of the standard books on EJB but found nothing useful. I think that might be the cause because everbody assumes that you use the JEE programming model, when you deploy on an JEE server.

Any help would be appreciated.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The overhead of object creation has decreased a lot over the years; it's no longer a valid reason to avoid it. That's also the reason why using object pools has fallen out of favor (except for DB connection pools and such, where networks object are involved) - it's no longer worth the code complication.

The other factor is thread-safety. With static methods everything needs to be carefully synchronized, which can effectively kill parallel performance if too much is synchronized; I suspect that's what you're seeing with the increased latency.

 
Markus Schmider
Ranch Hand
Posts: 137
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer, I totally forgot about thread-safety.
Well nothing in the code is synchronized as far as I know.
But what about my bottleneck I surmise?
One advantage of using EJBs is that you can handle concurrent requests of multiple users on the servers and make use of multi-core, multi-processor machines as I understood it.
Isn't negated when you use static methods?
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like your colleague is protecting his/her job by using bearish coding techniques and keeping you at bay. Maybe he/she doesn't understand the Java EE programming model completely and is intimidated by your knowledge. Perception is everything. He/she seems to have the trust of management, so this may present a challenge. Stop arguing and let him/her drive for a while, things eventually will fall apart and you can be there to pick up the pieces... ... management should start to trust you then and question this other person.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marcus Didius Falco wrote:His application has a front of EJBs. All those delegate the real work to classes which have only static methods.

If the EJBs are being used as a facade, you still get the benefits of EJB pooling.

I don't understand the perceived performance problem. Unless you use "syncrhonized", the multiple pooled EJBs can execute the static methods at the same time.

It's odd design, but not a performance problem. Statics aren't evil from a performance point of view. (They aren't so hot from a design/maintenance/extension point of view, but that's another story.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!