We have multiple spring boot applications deployed on WAS. Each module is a bundled with spring dependencies making each of them fat. Due to this, all our apps take a lot of memory on start up. For instance, around 120MB for each application. Is there a way that we can reduce the memory footprint?
Shared libraries might be a good solution for you, assuming all the applications use the same version of Spring and there’s no harm in sharing the Class instances. These instructions assume WAS traditional but the process would be similar on Liberty; if you need Liberty instructions let me know and I’ll add a comment.
First, create a shared library with all the necessary Spring classes and their direct dependencies. With the config we’re using, the stuff in the shared library will not be able to directly see anything in the applications, so you’ll need to make sure the packaging is reasonably complete.
Next, you’ll need to associate the shared library with either a custom class loader on the server (making it visible to all applications) or with the applications directly. If you choose the latter, you’ll need to make one other configuration change – by default, shared libraries associated with applications are simply added to the applications’ class paths, which would not help with your memory issues (it’d save on disk space but not memory at runtime). To get that benefit, select the “Use an isolated class loader” checkbox for the shared library, which gives the library its own class loader that’s referenced by the applications.
A useful tech note regarding shared library configuration can be found here: https://www.ibm.com/support/pages/how-create-shared-library-and-associate-it-application-server-or-enterprise-application-websphere-application-server
The “isolated” setting is highlighted in step 3 under “Creating a shared library” if you choose to go that route.