SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
Challenges of Resource Management
                 in an OSGi Environment
                 Chris Gray, /K/ Embedded Java Solutions
                 Christer Larsson, Makewave

                 20 September 2011




            /K/ Embedded Java Solutions
                                                                            OSGi Alliance Marketing © 2008-2010 . All1
                                                                                                             Page
                 COPYRIGHT © 2008-2011 OSGi Alliance. All Rights Reserved
                                                                            Rights Reserved
onsdag den 21 september 2011
The Problem
                      •        OSGi is a fine dynamic modular system which
                               allows many independent modules to co-exist
                               within a single JVM
                      •         Supports the business objective of offering
                               3rd-party services on top of supplier-
                               provided services
                      •         BUT: there is a need to protect the platform
                               against badly-written / malicious bundles

                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Types of Misbehavior



                                                                                       Other OS Process
                               Bundle                                        Bundle
                                                   Bundle

                                                                                       Other OS Process
                                  Bundle             Bundle                  Bundle



                                                OSGi Framework
                                                                                       Other OS Process
                                                    JVM Process

                                                                  Operating System


                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Types of Misbehavior
                                                                                Excessive Memory
                                                                                    Allocation




                                                                                                   Other OS Process
                               Bundle                                    Bundle
                                                   Bundle

                                                                                                   Other OS Process
                                  Bundle             Bundle                  Bundle



                                                OSGi Framework
                                                                                                   Other OS Process
                                                    JVM Process

                                                                  Operating System


                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Types of Misbehavior
         Excessive CPU usage, or                                                Excessive Memory
         using too many Threads                                                     Allocation




                                                                                                   Other OS Process
                                                                         Bundle
                               Bundle

                                                   Bundle

                                                                                                   Other OS Process
                                  Bundle             Bundle                  Bundle



                                                OSGi Framework
                                                                                                   Other OS Process
                                                    JVM Process

                                                                  Operating System


                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Types of Misbehavior



                                                                                       Other OS Process




                                                                                       Other OS Process




                                                                                       Other OS Process
                                      JVM / OSGi Rebooting. Please Wait.....

                                                                  Operating System


                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Potential solutions to the
                                 problem
                      • Use Resource Management inside the VM
                      • Run multiple VM instances to isolate critical
                               OSGi applications from user application
                      • Careful and rigorous testing of all bundles
                               before the are installed
                      • These three items can of course be
                               combined

                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
A Mika / Knopflerfish solution - resource
                                  constrain the bundles
                  Add a Resource Manager that can account for Bundle Resources using built-in VM features




                                                                                           Other OS Process
                               Bundle                                        Bundle
                                                   Bundle

                                                                                           Other OS Process
                                  Bundle             Bundle                  Bundle


                                                                                Resource
                                           Knopflerfish OSGi Framework            Manager    Other OS Process
                                                    Mika Max

                                                                  Operating System


                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Identifying the culprit (1)
                      •        The first step is to associate resource allocations with
                               modules.
                      •        Various systems have been devised for this, but generally
                               they are not transparent
                               •   Certain APIs must be called for its resource consumption to
                                   be monitored.

                               •   But there is no guarantee all code is written in this way

                               •   And legacy code, or 3rd party libs are certainly not!

                      •        Instead we propose to gather resource usage information
                               by instrumenting the Java runtime itself.

                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Identifying the culprit - (2)
                      •        OSGi helps us by allocating a unique classloader to each
                               bundle. We define the “current bundle class loader” of a
                               thread T as follows:
                      •        If T is the system startup thread then the current bundle
                               class loader of T's base frame is the system class loader.
                      •        Otherwise the bundle class loader of T's base frame is
                               inherited from the thread frame which called T.start().
                      •        The bundle class loader of any other frame is the class
                               loader of the method it is executing, or if this is the system
                               class loader then it is inherited from the parent frame.

                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Identifying the culprit - (3)
                      •        For the purpose of this paper the bootstrap class
                               loader, extension class loader, and system class loader
                               are all lumped together as “system”. Note that this
                               includes resources consumed by the framework itself.
                      •        The overhead is much less than for the “stack
                               inspection” required by the Java2 fine-grained security
                               model, because we only need to follow a few pointers
                               (frame→method→class→loader) and test for
                               equality. Could be further optimised using auxiliary
                               data structures.

                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Resource Accounting
                      •        For each class loader we maintain a data structure with
                               counters for each monitored resource.
                               •   Count up when resource is allocated
                               •   Count down when released, BUT

                      •        Resource is often released by another thread, e.g. Garbage
                               collector or finalizer thread. Therefore we need to remember
                               which class loader allocated which resource! Furthermore the
                               resource may outlive the classloader which allocated it, so we
                               use a “handle” instead of a direct pointer to the class loader.
                      •        CPU usage is tricky, as depends on OS and on threading model.


                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Bundle Resource Accounting
                                                            For each monitored bundle resources are accounted
                                                               and associated with the bundle’s Class Loader




                                                                         Class Loader
                                                                                              Other OS Process
                               Bundle                                        Bundle
                                                   Bundle
                                                                         Class Loader
                                                                                              Other OS Process
                                  Bundle             Bundle                  Bundle



                                           Knopflerfish OSGi Framework            Resource
                                                                                Manager       Other OS Process
                                                    Mika Max

                                                                  Operating System


                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Bundle Resource Accounting
                                                            For each monitored bundle resources are accounted
                                                               and associated with the bundle’s Class Loader




                                                                         Class Loader
                                                                                              Other OS Process
                               Bundle                                        Bundle
                                                   Bundle
                                                                         Class Loader
                                                                                              Other OS Process
                                  Bundle             Bundle                  Bundle



                                           Knopflerfish OSGi Framework            Resource
                                                                                Manager       Other OS Process
                                                    Mika Max

                                                                  Operating System


                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Resource Accounting (2)
                      • Knopflerfish Pro has a Resource Manager
                      • For every bundle quota can be set on CPU,
                               memory and number of Threads used
                      • When a Bundle has exceeded his quota of
                               some resource the Resource Manager is
                               notified and can take action.
                      • But it is not always obvious what to do!
                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Dealing with Resource
                               Overconsumption (1)
                      •        The default action when the bundle over-
                               consumes is as follows
                               •   Overconsumption of Memory
                                   •   Throw an OutOfMemoryError

                               •   Overconsumption of Threads or CPU
                                   •   Throw an InternalError

                      •        Alternatively a user-defined callback can be
                               invoked at that point

                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Dealing with Resource
                               Overconsumption (2)
                      •        The Resource Manager can supply information on over-
                               consuming bundles to a Management Agent.
                      •        The Management Agent can also query the Resource
                               Manager for current bundle resources use and take
                               action before quota is reached
                      •        The Management Agent can then decide to send an alarm
                               and / or stop the bundle.
                      •        For a well-behaving bundle this is no problem
                      •        But for a malicious, or badly written bundle that has gone
                               bananas there are new problems on the horizon...

                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Difficulties with Java
                                     Threads
                      •        Java threads are not OS processes, i.e.
                               •   Java threads can not be destroyed, stopped or suspended.
                                   Attempting to do that is unsafe and may lead to unpredictable
                                   results. See javadoc for java.lang.Thread for more details.

                      •        This means Activator start() and stop() methods that do not
                               return can not be stopped or killed like an OS process.
                      •        If this happens in Knopflerfish we:
                               •   invalidate the Bundle after a timeout period so that bundle no
                                   longer is usable. All its services are unregistered and it can not
                                   get new services.

                               •   Set the threads prio to lowest possible.

                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Showtime!




                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011
Thank you




                               Chris Gray - /K/ Embedded Java Solutions - www.k-embedded-java.com
                                        Christer Larsson - Makewave - www.makewave.com



                 OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson


onsdag den 21 september 2011

Weitere ähnliche Inhalte

Mehr von mfrancis

OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...mfrancis
 
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...mfrancis
 
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)mfrancis
 
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...mfrancis
 
OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)mfrancis
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...mfrancis
 
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...mfrancis
 
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...mfrancis
 
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)mfrancis
 
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)mfrancis
 
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)mfrancis
 
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...mfrancis
 
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)mfrancis
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...mfrancis
 
How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)mfrancis
 
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...mfrancis
 
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)mfrancis
 
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...mfrancis
 
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)mfrancis
 
Journey from Monolith to a Modularized Application - Approach and Key Learnin...
Journey from Monolith to a Modularized Application - Approach and Key Learnin...Journey from Monolith to a Modularized Application - Approach and Key Learnin...
Journey from Monolith to a Modularized Application - Approach and Key Learnin...mfrancis
 

Mehr von mfrancis (20)

OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
 
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
 
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
 
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
 
OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
 
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
 
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
 
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
 
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
 
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
 
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
 
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
 
How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)
 
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
 
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
 
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
 
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
 
Journey from Monolith to a Modularized Application - Approach and Key Learnin...
Journey from Monolith to a Modularized Application - Approach and Key Learnin...Journey from Monolith to a Modularized Application - Approach and Key Learnin...
Journey from Monolith to a Modularized Application - Approach and Key Learnin...
 

Kürzlich hochgeladen

Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 

Kürzlich hochgeladen (20)

Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

Challenges of resource management in an os gi environment chris gray + christer larsson

  • 1. Challenges of Resource Management in an OSGi Environment Chris Gray, /K/ Embedded Java Solutions Christer Larsson, Makewave 20 September 2011 /K/ Embedded Java Solutions OSGi Alliance Marketing © 2008-2010 . All1 Page COPYRIGHT © 2008-2011 OSGi Alliance. All Rights Reserved Rights Reserved onsdag den 21 september 2011
  • 2. The Problem • OSGi is a fine dynamic modular system which allows many independent modules to co-exist within a single JVM • Supports the business objective of offering 3rd-party services on top of supplier- provided services • BUT: there is a need to protect the platform against badly-written / malicious bundles OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 3. Types of Misbehavior Other OS Process Bundle Bundle Bundle Other OS Process Bundle Bundle Bundle OSGi Framework Other OS Process JVM Process Operating System OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 4. Types of Misbehavior Excessive Memory Allocation Other OS Process Bundle Bundle Bundle Other OS Process Bundle Bundle Bundle OSGi Framework Other OS Process JVM Process Operating System OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 5. Types of Misbehavior Excessive CPU usage, or Excessive Memory using too many Threads Allocation Other OS Process Bundle Bundle Bundle Other OS Process Bundle Bundle Bundle OSGi Framework Other OS Process JVM Process Operating System OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 6. Types of Misbehavior Other OS Process Other OS Process Other OS Process JVM / OSGi Rebooting. Please Wait..... Operating System OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 7. Potential solutions to the problem • Use Resource Management inside the VM • Run multiple VM instances to isolate critical OSGi applications from user application • Careful and rigorous testing of all bundles before the are installed • These three items can of course be combined OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 8. A Mika / Knopflerfish solution - resource constrain the bundles Add a Resource Manager that can account for Bundle Resources using built-in VM features Other OS Process Bundle Bundle Bundle Other OS Process Bundle Bundle Bundle Resource Knopflerfish OSGi Framework Manager Other OS Process Mika Max Operating System OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 9. Identifying the culprit (1) • The first step is to associate resource allocations with modules. • Various systems have been devised for this, but generally they are not transparent • Certain APIs must be called for its resource consumption to be monitored. • But there is no guarantee all code is written in this way • And legacy code, or 3rd party libs are certainly not! • Instead we propose to gather resource usage information by instrumenting the Java runtime itself. OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 10. Identifying the culprit - (2) • OSGi helps us by allocating a unique classloader to each bundle. We define the “current bundle class loader” of a thread T as follows: • If T is the system startup thread then the current bundle class loader of T's base frame is the system class loader. • Otherwise the bundle class loader of T's base frame is inherited from the thread frame which called T.start(). • The bundle class loader of any other frame is the class loader of the method it is executing, or if this is the system class loader then it is inherited from the parent frame. OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 11. Identifying the culprit - (3) • For the purpose of this paper the bootstrap class loader, extension class loader, and system class loader are all lumped together as “system”. Note that this includes resources consumed by the framework itself. • The overhead is much less than for the “stack inspection” required by the Java2 fine-grained security model, because we only need to follow a few pointers (frame→method→class→loader) and test for equality. Could be further optimised using auxiliary data structures. OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 12. Resource Accounting • For each class loader we maintain a data structure with counters for each monitored resource. • Count up when resource is allocated • Count down when released, BUT • Resource is often released by another thread, e.g. Garbage collector or finalizer thread. Therefore we need to remember which class loader allocated which resource! Furthermore the resource may outlive the classloader which allocated it, so we use a “handle” instead of a direct pointer to the class loader. • CPU usage is tricky, as depends on OS and on threading model. OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 13. Bundle Resource Accounting For each monitored bundle resources are accounted and associated with the bundle’s Class Loader Class Loader Other OS Process Bundle Bundle Bundle Class Loader Other OS Process Bundle Bundle Bundle Knopflerfish OSGi Framework Resource Manager Other OS Process Mika Max Operating System OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 14. Bundle Resource Accounting For each monitored bundle resources are accounted and associated with the bundle’s Class Loader Class Loader Other OS Process Bundle Bundle Bundle Class Loader Other OS Process Bundle Bundle Bundle Knopflerfish OSGi Framework Resource Manager Other OS Process Mika Max Operating System OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 15. Resource Accounting (2) • Knopflerfish Pro has a Resource Manager • For every bundle quota can be set on CPU, memory and number of Threads used • When a Bundle has exceeded his quota of some resource the Resource Manager is notified and can take action. • But it is not always obvious what to do! OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 16. Dealing with Resource Overconsumption (1) • The default action when the bundle over- consumes is as follows • Overconsumption of Memory • Throw an OutOfMemoryError • Overconsumption of Threads or CPU • Throw an InternalError • Alternatively a user-defined callback can be invoked at that point OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 17. Dealing with Resource Overconsumption (2) • The Resource Manager can supply information on over- consuming bundles to a Management Agent. • The Management Agent can also query the Resource Manager for current bundle resources use and take action before quota is reached • The Management Agent can then decide to send an alarm and / or stop the bundle. • For a well-behaving bundle this is no problem • But for a malicious, or badly written bundle that has gone bananas there are new problems on the horizon... OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 18. Difficulties with Java Threads • Java threads are not OS processes, i.e. • Java threads can not be destroyed, stopped or suspended. Attempting to do that is unsafe and may lead to unpredictable results. See javadoc for java.lang.Thread for more details. • This means Activator start() and stop() methods that do not return can not be stopped or killed like an OS process. • If this happens in Knopflerfish we: • invalidate the Bundle after a timeout period so that bundle no longer is usable. All its services are unregistered and it can not get new services. • Set the threads prio to lowest possible. OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 19. Showtime! OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011
  • 20. Thank you Chris Gray - /K/ Embedded Java Solutions - www.k-embedded-java.com Christer Larsson - Makewave - www.makewave.com OSGi Community Event 2011 Darmstadt - Chris Gray / Christer Larsson onsdag den 21 september 2011