Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSGi and performance?

Is OSGi adapted for high performance application servers?

OSGi helps a lot to produce highly modular applications but what is the impact on performance since the model of execution is different than regular Java applications (since I understand that the OSGi applications run on specific platform, as Apache Felix).

What are your experiences with the different implementations in term of performance?

Thanks

like image 782
manash Avatar asked Nov 30 '22 23:11

manash


2 Answers

In my experience, moving applications from non-OSGi to an OSGi environment (using Felix) has made no impact on performance. Each build I produce is subjected to stress tests; the results of the stress tests have indicated no drop in performance.

It might depend on what your application does. I'll discount explicit OSGi concepts such as services as such new code will need your own testing and I'm assuming you're asking what the impact is on existing POJO code.

The implicit impact of an OSGi environment is mainly on class loading. As you probably know, OSGi mandates separate class loaders for each bundle, and provides a way of wiring code in bundles to dependencies in other bundles. When a class in a bundle calls a class in a different bundle, it is the second bundle's classloader that is responsible for loading that second class class.

It might be (but probably won't be) that this class loading logic consumes a little extra work than the default class loaders used in a vanilla Java environment. However, unless your code is itself re-creating and reloading classes constantly, which is unlikely, any performance impact is likely to be negligible. And in any case, that's just a theoretical possibility. It's up to the implementation you choose to be as efficient as possible.

There is also a small impact on memory footprint. It's best to take a heap dump and use something like mat to analyse this.

You'll spend much more time getting your head around OSGi conceptually, differences between OSGi containers, tools, version management and more than you will waiting for classes to load, believe me ;)

like image 174
Dan Gravell Avatar answered Dec 04 '22 12:12

Dan Gravell


OSGi can result in a very small performance increase due to faster classloading. It can also result in a very small increase in memory consumption due to multiple classloaders.

Contrary to the assertion in your question: OSGi does not change the Java execution model.

like image 20
Neil Bartlett Avatar answered Dec 04 '22 10:12

Neil Bartlett