TLDR;
what if you are tasked with taking out a feature and making it app 2 to reduce memory/compute foot print from app 1? Making an API contract between app 1 & 2 would defeat the purpose because APIs run on app 1.
How then could we split a feature from a monolith that relies on the same data of app 1?
I need to review our architecture and wonder if any of you want to give it a go, I would appreciate learning from the insights.
We have a main spring java web app - Central. We had an export feature that exported our data via a background job. As the export component began to have more features added to it - send live events instead of daily exports etc, our architect decided to make it a separate app called integration(ims). His motivation? If the feature is separate, it can scale and not increase load (JVM) of Central as Central is user-facing and IMS is used for all kinds of requests from clients (exports, events etc). On paper, sounds nice. Here are the concerns below.
so IMS now queries Central because it needs data to export. All those queries were already present in Central, but they had to be copied and pasted - along with utils, ORM Entity classes - et al.
I shared with my product owner that IMS directly querying Central database as opposed to using API contracts - is an anti-pattern because any change in Central database is unknown to IMS app. If the contract is done via API and not queries, any change in DB structure is invisible to the API and would work for Central and IMS. My boss agreed. However, wasn't the whole idea of splitting the app because we didn't want to increase load on Central? Making API contracts between IMS and Central would be back to square one (as those APIs would run on Central)
Apart from DB changes, the other issue I am finding is the repition of code. As IMS needs to query Central for everything, it requires the same kind of service classes, utils, security improvements, S3 implemetations etc. So we're having a
problem no. 2: "have you remembered to make this change on IMS too?" - i.e Inablility to share code
We're not the first ones to split an app to reduce JVM load. And IMS is merely querying (read-only) Central. How do other teams tackle DB change impacts on shared java apps & inability to share util, classes etc? Or what have we done wrong and what could we have done better?
I don't think this question is limited to Java, its an architectural design questions that applies to all technologies.
The split has already occured, so any thoughts are appreciated.