Microservices and Stored ProceduresMicroservices Architecture separating backend and front endHow can I create a Python microservice on AWS that both accepts REST connections and processes SQS messages?How to build a scalable, containerizable and manageable API with GraphQL, Kafka, Docker, Kubernetes and MongoDB?Microservices and data storageMicroservices: MonolithFirst?Should I Microkernel or Microservice my legacy ERP?Event Driven Microservice Architecture & Dealing with synchronous external neighboring systemsApplication architecture using CQS and DDD AggregatesIs a “User” microservice a good idea?
Who are the people reviewing far more papers than they're submitting for review?
Which block header fields are miners able to change in an effort to avoid having to recalculate the Merkle Root?
Statistical tests for benchmark comparison
How do rulers get rich from war?
Why are there no programmes / playbills for movies?
Why do IXPs need ASN?
All numbers in a 5x5 Minesweeper grid
How to make classical firearms effective on space habitats despite the coriolis effect?
Why would a fighter use the afterburner and air brakes at the same time?
What exactly is a web font, and what does converting to one involve?
Why are two-stroke engines nearly unheard of in aviation?
Are lay articles good enough to be the main source of information for PhD research?
How can I add a link on the "Structure" admin page?
How to give my students a straightedge instead of a ruler
Hobby function generators
If a PC's ability score increases due to an item, does it increase the corresponding modifier for the ability score or any skills/attacks?
Amortized Loans seem to benefit the bank more than the customer
Why do things cool off?
Talk about Grandpa's weird talk: Who are these folks?
How to generate short fixed length cryptographic hashes?
All numbers twice in a 7x7 Minesweeper grid
Bash attempts to write two shell prompts?
Wrong Schengen Visa exit stamp on my passport, who can I complain to?
Is my sink P-trap too low?
Microservices and Stored Procedures
Microservices Architecture separating backend and front endHow can I create a Python microservice on AWS that both accepts REST connections and processes SQS messages?How to build a scalable, containerizable and manageable API with GraphQL, Kafka, Docker, Kubernetes and MongoDB?Microservices and data storageMicroservices: MonolithFirst?Should I Microkernel or Microservice my legacy ERP?Event Driven Microservice Architecture & Dealing with synchronous external neighboring systemsApplication architecture using CQS and DDD AggregatesIs a “User” microservice a good idea?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
My question is are stored procedures considered bad practice in microservice architecture?
Here are my thoughts:
most books on microservices recommend one database per microservice.
Stored procedures typically work on a monolith database.again most microservice architecture books state that they should be autonomous and loosely coupled. Using stored procedures written say specifically in Oracle, tightly couples the microservice to that technology.
most msa books (that I have read) recommend that microservices should be business oriented (designed using ddd). By moving business logic into stored procedures in the database this is no longer the case.
Any thoughts on this?
architecture microservices
New contributor
Johnny Alpha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment
|
My question is are stored procedures considered bad practice in microservice architecture?
Here are my thoughts:
most books on microservices recommend one database per microservice.
Stored procedures typically work on a monolith database.again most microservice architecture books state that they should be autonomous and loosely coupled. Using stored procedures written say specifically in Oracle, tightly couples the microservice to that technology.
most msa books (that I have read) recommend that microservices should be business oriented (designed using ddd). By moving business logic into stored procedures in the database this is no longer the case.
Any thoughts on this?
architecture microservices
New contributor
Johnny Alpha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
A multitier architecture encourages application logic to be decoupled from the data storage. It's alright to have stored procedures sanitize any data issues you have, as long as it doesn't go beyond that.
– john
8 hours ago
add a comment
|
My question is are stored procedures considered bad practice in microservice architecture?
Here are my thoughts:
most books on microservices recommend one database per microservice.
Stored procedures typically work on a monolith database.again most microservice architecture books state that they should be autonomous and loosely coupled. Using stored procedures written say specifically in Oracle, tightly couples the microservice to that technology.
most msa books (that I have read) recommend that microservices should be business oriented (designed using ddd). By moving business logic into stored procedures in the database this is no longer the case.
Any thoughts on this?
architecture microservices
New contributor
Johnny Alpha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
My question is are stored procedures considered bad practice in microservice architecture?
Here are my thoughts:
most books on microservices recommend one database per microservice.
Stored procedures typically work on a monolith database.again most microservice architecture books state that they should be autonomous and loosely coupled. Using stored procedures written say specifically in Oracle, tightly couples the microservice to that technology.
most msa books (that I have read) recommend that microservices should be business oriented (designed using ddd). By moving business logic into stored procedures in the database this is no longer the case.
Any thoughts on this?
architecture microservices
architecture microservices
New contributor
Johnny Alpha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Johnny Alpha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 8 hours ago
Johnny Alpha
New contributor
Johnny Alpha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 9 hours ago
Johnny AlphaJohnny Alpha
92 bronze badges
92 bronze badges
New contributor
Johnny Alpha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Johnny Alpha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
A multitier architecture encourages application logic to be decoupled from the data storage. It's alright to have stored procedures sanitize any data issues you have, as long as it doesn't go beyond that.
– john
8 hours ago
add a comment
|
A multitier architecture encourages application logic to be decoupled from the data storage. It's alright to have stored procedures sanitize any data issues you have, as long as it doesn't go beyond that.
– john
8 hours ago
A multitier architecture encourages application logic to be decoupled from the data storage. It's alright to have stored procedures sanitize any data issues you have, as long as it doesn't go beyond that.
– john
8 hours ago
A multitier architecture encourages application logic to be decoupled from the data storage. It's alright to have stored procedures sanitize any data issues you have, as long as it doesn't go beyond that.
– john
8 hours ago
add a comment
|
3 Answers
3
active
oldest
votes
There is nothing that explicitly forbids or argues against using stored procedures with microservices.
Disclaimer: I don't like stored procedures from a developer's POV, but that is not related to microservices in any way.
Stored procedures typically work on a monolith database.
I think you're succumbing to a logical fallacy.
Stored procedures are on the decline nowadays. Most stored procedures that are still in use are from an older codebase that's been kept around. Back then, monolithic databases were also much more prevalent compared to when microservices have become popular.
Stored procs and monolithic databases both occur in old codebases, which is why you see them together more often. But that's not a causal link. You don't use stored procs because you have a monololithic database. You don't have a monolithic database because you use stored procs.
most books on microservices recommend one database per microservice.
There is no technical reason why these smaller databases cannot have stored procedures.
As I mentioned, I don't like stored procs. I find them cumbersome and resistant to future maintenance. I do think that spreading sprocs over many small databases further exacerbates the issues that I already don't like. But that doesn't mean it can't be done.
again most microservice architecture books state that they should be autonomous and loosely coupled. Using stored procedures written say specifically in Oracle, tightly couples the microservice to that technology.
On the other side, the same argument can be made for whatever ORM your microservice uses. Not every ORM will support every database either. Coupling (specifically its tightness) is a relative concept. It's a matter of being as loose as you can reasonably be.
Sprocs do suffer from tight coupling in general regardless of microservices. I would advise against sprocs in general, but not particularly because you're using microservices. It's the same argument as before: I don't think sprocs are the way to go (in general), but that might just be my bias, and it's not related to microservices.
most msa books (that I have read) recommend that microservices should be business oriented (designed using ddd). By moving business logic into stored procedures in the database this is no longer the case.
This has always been my main gripe about sprocs: business logic in the database. Even when not the intention, it tends to somehow always end up that way.
But again, that gripe exists regardless of whether you use microservices or not. The only reason it looks like a bigger issue is because microservices push you to modernize your entire architecture, and sprocs are not that favored anymore in modern architectures.
I'm not sure if it is correct to say that microservices push you to modernize your entire architecture. More often than not, they end up being a thin layer over a behemoth of a mess of poorly planned code. They can be pretty good when well done, but they don't really push you in any way towards better coding than any other architecture. Still, good answer. You got a +1 from me.
– T. Sar
4 hours ago
@T.Sar modern is not the same as better. Refactoring (to microservices or whatever) means change. Change forces you to use your current ideas. We hope they are better ideas.
– candied_orange
4 hours ago
@T.Sar: Hacks are timeless, and you can usually abuse any system (modern or not) to do something it can technically handle but was never intended for. Microservices urge you to do it differently (and thus reevaluate some old approaches) but they can't universally enforce it. With universal enforcement you usually suffer in the compatibility/valid fringe case department.
– Flater
4 hours ago
@candied_orange "modern is not the same as better" - I think I wholeheartedly agree to that. Very good point.
– T. Sar
2 hours ago
add a comment
|
To write software requires that you tightly couple to a technology.
At the very least to the runtime environment provided by the programming language being developed within.
More generally though you will find that your micro-service is tightly coupled to several technologies:
- Network Service Framework to provide high level http/ssl/soap protocol implementations
- Repository/ORM/DAO Framework to provide persistence.
- Data Manipulation Frameworks to provide tools for working with data.
- Process/Threading/OS Framework to provide access to os resources such as multi-tasking, the file system, memory, gpu compute, expansion cards, etc...
And that is to make a bare-bones micro-service.
Stored procedures
A stored procedure is simply another technology that you could choose to use or not use. It does not magically make your code monolithic, or micro.
What it is though is:
- Another technology. Each technology present in the application decreases the likely-hood that any given programmer can read, understand, and make wise design choices for that technology mix.
- A language using a different programming paradigm. It is far too easy for non-experts to try and force their own imperative/functional/oo/etc... perspective onto it, which often leads to less than stellar results.
- An API. Which must be maintained like any other class in the code base. It also means that the database is providing a non-generic interface. This makes it harder to both replace the database engine itself, and to transparently apply generic behaviour such as in memory caching.
- An artefact. Which must be versioned, tested, and deployed. This can be done, but databases are living artifacts requiring a different approach. You cannot usually just delete the original, and replace it. Often a careful orchestration of changes over-time are needed to migrate the system to the desired state.
Each of these is a real cost. In some cases the cost is justifiable, in others it is not.
You would be paying almost the same set of costs by hosting a scripting engine. The sole reduction is that you could choose the same programming paradigm as the host language.
Business Logic
Moving business rules into the database is bad practice. Just not because of stored procedures.
Its a bad practice because the database and business logic operate on different shearing levels.
A database in a mature applications can be in use for decades. Generally these systems will have the engine periodically updated, but the database itself was migrated. It was not killed and rebuilt from the start. There is no reason a micro service cannot be equally so long lived.
Contrast decades against how quickly business rules change. In my experience an old business rule is perhaps a few years old, most however change quickly, and you can never tell which one will change next. A new requirement from a regulator, an old product being decommissioned, changes to the letter head, changes to how many employees report to a boss, etc, etc, etc...
If the business logic is distributed across the shearing layers, particularly into a slower and longer lived layer, it will generate resistance to change. This is not necessarily a bad thing. Afterall the only database that has zero business logic in it is a triple store.
The mere act of specifying a table schema is moving business logic into the database.
Architecture
You are contending with using the appropriate tool for the appropriate problem, without needing too many tools, nor making it too hard to solve, in order to make and maintain a solution.
This isn't easy.
But lets think the unthinkable, how would you maintain business logic distributed across several languages?
- A catalogue... so that each business rule implementation can be tracked and maintained.
- Tests... that could be used against each business rule regardless of where and how it was implemented.
- A reference implementation.. so that when discrepancies are found, a source of truth exists (or at least a source of debate).
But this has a cost too.
- Is it better to allow the business rules to have many implementations? That can each take advantage of the team skills, and framework provisions, but needing tight quality controls to ward off having many small vagaries?
- Or is it better to have a single source of truth, written in a single language? Arguably cheaper to implement, yet also a single source of failure, itself a monolithic component that resists change in the face of different platforms, frameworks, or as yet to be invented tools?
add a comment
|
Stored procedures are implementation details. Database functions, lambdas or a shell script stored somewhere in the file system all are implementation details and irrelevant for the architecture. Microservice doesn't forbid the implementation of one or another solution. As soon as we don't break the golden rule of decoupling because it would defeat the purpose of the architecture, hence the chances for the business' strategy to success.
Bear always in mind that any architecture is a meant to an end. We don't build MS ecosystems for fashion or love to the art.
most books on microservices recommend one database per microservice.
Ok, so we can code the store procedures in these databases.
again most microservice architecture books state that they should be
autonomous and loosely coupled
Between business capabilities, development's life cycles, management,
deployments, team's locations, etc. Nothing to do with the implementation details. Microservices don't solve a technical problem (just the opposite). They come to solve problems with the management and the time-to-market. It's a strategy, not a tactic. A way to fail-fast with the least costs possibles. If a certain business capability is proven to be wrong or unworthy, we drop it without messing other capabilities.
Note that the "splitting" already acts like a decoupling agent. I mean, we have two services, A is backed by Oracle and B by MongoDB. If we didn't break the golden rule, should be possible for us to drop A + Oracle with 0 side effects on B. Look at the big picture, because the small one is irrelevant for the MS architecture.
Using stored procedures written say specifically in Oracle, tightly
couples the microservice to that technology.
It might cause vendor locking. Many times, the vendor is imposed by the business by historical or contractual reasons. I have worked on projects where everything was unclear but the database. The database already was there. In any case, is important to know how to not lock our code to the vendor. Some ORM and frameworks implement an abstraction language that hides the database built-in functions and features.
Although, if our services are micro enough, vendor locking is no longer a problem since it impacts a small part of the whole. A small part that should be possible to be replaced (or isolated) quickly.
most MSA books (that I have read) recommend that microservices should
be business oriented (designed using DDD).
Should be business-driven and here the thing. Not all business' takes advantage of DDD. DDD and MS overlap in many points, but they are not cause-effect. We could end up with an MS ecosystem of anaemic services and still be a good implementation of the architecture.
Regarding books. Bear in mind that they only focus on the execution of the strategy. The tactic. How to make possible a strategy based on distributed computing, but they are (usually) agnostic to the strategy. So you still have to extrapolate what they said to your specific case.
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "131"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Johnny Alpha is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsoftwareengineering.stackexchange.com%2fquestions%2f398436%2fmicroservices-and-stored-procedures%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
There is nothing that explicitly forbids or argues against using stored procedures with microservices.
Disclaimer: I don't like stored procedures from a developer's POV, but that is not related to microservices in any way.
Stored procedures typically work on a monolith database.
I think you're succumbing to a logical fallacy.
Stored procedures are on the decline nowadays. Most stored procedures that are still in use are from an older codebase that's been kept around. Back then, monolithic databases were also much more prevalent compared to when microservices have become popular.
Stored procs and monolithic databases both occur in old codebases, which is why you see them together more often. But that's not a causal link. You don't use stored procs because you have a monololithic database. You don't have a monolithic database because you use stored procs.
most books on microservices recommend one database per microservice.
There is no technical reason why these smaller databases cannot have stored procedures.
As I mentioned, I don't like stored procs. I find them cumbersome and resistant to future maintenance. I do think that spreading sprocs over many small databases further exacerbates the issues that I already don't like. But that doesn't mean it can't be done.
again most microservice architecture books state that they should be autonomous and loosely coupled. Using stored procedures written say specifically in Oracle, tightly couples the microservice to that technology.
On the other side, the same argument can be made for whatever ORM your microservice uses. Not every ORM will support every database either. Coupling (specifically its tightness) is a relative concept. It's a matter of being as loose as you can reasonably be.
Sprocs do suffer from tight coupling in general regardless of microservices. I would advise against sprocs in general, but not particularly because you're using microservices. It's the same argument as before: I don't think sprocs are the way to go (in general), but that might just be my bias, and it's not related to microservices.
most msa books (that I have read) recommend that microservices should be business oriented (designed using ddd). By moving business logic into stored procedures in the database this is no longer the case.
This has always been my main gripe about sprocs: business logic in the database. Even when not the intention, it tends to somehow always end up that way.
But again, that gripe exists regardless of whether you use microservices or not. The only reason it looks like a bigger issue is because microservices push you to modernize your entire architecture, and sprocs are not that favored anymore in modern architectures.
I'm not sure if it is correct to say that microservices push you to modernize your entire architecture. More often than not, they end up being a thin layer over a behemoth of a mess of poorly planned code. They can be pretty good when well done, but they don't really push you in any way towards better coding than any other architecture. Still, good answer. You got a +1 from me.
– T. Sar
4 hours ago
@T.Sar modern is not the same as better. Refactoring (to microservices or whatever) means change. Change forces you to use your current ideas. We hope they are better ideas.
– candied_orange
4 hours ago
@T.Sar: Hacks are timeless, and you can usually abuse any system (modern or not) to do something it can technically handle but was never intended for. Microservices urge you to do it differently (and thus reevaluate some old approaches) but they can't universally enforce it. With universal enforcement you usually suffer in the compatibility/valid fringe case department.
– Flater
4 hours ago
@candied_orange "modern is not the same as better" - I think I wholeheartedly agree to that. Very good point.
– T. Sar
2 hours ago
add a comment
|
There is nothing that explicitly forbids or argues against using stored procedures with microservices.
Disclaimer: I don't like stored procedures from a developer's POV, but that is not related to microservices in any way.
Stored procedures typically work on a monolith database.
I think you're succumbing to a logical fallacy.
Stored procedures are on the decline nowadays. Most stored procedures that are still in use are from an older codebase that's been kept around. Back then, monolithic databases were also much more prevalent compared to when microservices have become popular.
Stored procs and monolithic databases both occur in old codebases, which is why you see them together more often. But that's not a causal link. You don't use stored procs because you have a monololithic database. You don't have a monolithic database because you use stored procs.
most books on microservices recommend one database per microservice.
There is no technical reason why these smaller databases cannot have stored procedures.
As I mentioned, I don't like stored procs. I find them cumbersome and resistant to future maintenance. I do think that spreading sprocs over many small databases further exacerbates the issues that I already don't like. But that doesn't mean it can't be done.
again most microservice architecture books state that they should be autonomous and loosely coupled. Using stored procedures written say specifically in Oracle, tightly couples the microservice to that technology.
On the other side, the same argument can be made for whatever ORM your microservice uses. Not every ORM will support every database either. Coupling (specifically its tightness) is a relative concept. It's a matter of being as loose as you can reasonably be.
Sprocs do suffer from tight coupling in general regardless of microservices. I would advise against sprocs in general, but not particularly because you're using microservices. It's the same argument as before: I don't think sprocs are the way to go (in general), but that might just be my bias, and it's not related to microservices.
most msa books (that I have read) recommend that microservices should be business oriented (designed using ddd). By moving business logic into stored procedures in the database this is no longer the case.
This has always been my main gripe about sprocs: business logic in the database. Even when not the intention, it tends to somehow always end up that way.
But again, that gripe exists regardless of whether you use microservices or not. The only reason it looks like a bigger issue is because microservices push you to modernize your entire architecture, and sprocs are not that favored anymore in modern architectures.
I'm not sure if it is correct to say that microservices push you to modernize your entire architecture. More often than not, they end up being a thin layer over a behemoth of a mess of poorly planned code. They can be pretty good when well done, but they don't really push you in any way towards better coding than any other architecture. Still, good answer. You got a +1 from me.
– T. Sar
4 hours ago
@T.Sar modern is not the same as better. Refactoring (to microservices or whatever) means change. Change forces you to use your current ideas. We hope they are better ideas.
– candied_orange
4 hours ago
@T.Sar: Hacks are timeless, and you can usually abuse any system (modern or not) to do something it can technically handle but was never intended for. Microservices urge you to do it differently (and thus reevaluate some old approaches) but they can't universally enforce it. With universal enforcement you usually suffer in the compatibility/valid fringe case department.
– Flater
4 hours ago
@candied_orange "modern is not the same as better" - I think I wholeheartedly agree to that. Very good point.
– T. Sar
2 hours ago
add a comment
|
There is nothing that explicitly forbids or argues against using stored procedures with microservices.
Disclaimer: I don't like stored procedures from a developer's POV, but that is not related to microservices in any way.
Stored procedures typically work on a monolith database.
I think you're succumbing to a logical fallacy.
Stored procedures are on the decline nowadays. Most stored procedures that are still in use are from an older codebase that's been kept around. Back then, monolithic databases were also much more prevalent compared to when microservices have become popular.
Stored procs and monolithic databases both occur in old codebases, which is why you see them together more often. But that's not a causal link. You don't use stored procs because you have a monololithic database. You don't have a monolithic database because you use stored procs.
most books on microservices recommend one database per microservice.
There is no technical reason why these smaller databases cannot have stored procedures.
As I mentioned, I don't like stored procs. I find them cumbersome and resistant to future maintenance. I do think that spreading sprocs over many small databases further exacerbates the issues that I already don't like. But that doesn't mean it can't be done.
again most microservice architecture books state that they should be autonomous and loosely coupled. Using stored procedures written say specifically in Oracle, tightly couples the microservice to that technology.
On the other side, the same argument can be made for whatever ORM your microservice uses. Not every ORM will support every database either. Coupling (specifically its tightness) is a relative concept. It's a matter of being as loose as you can reasonably be.
Sprocs do suffer from tight coupling in general regardless of microservices. I would advise against sprocs in general, but not particularly because you're using microservices. It's the same argument as before: I don't think sprocs are the way to go (in general), but that might just be my bias, and it's not related to microservices.
most msa books (that I have read) recommend that microservices should be business oriented (designed using ddd). By moving business logic into stored procedures in the database this is no longer the case.
This has always been my main gripe about sprocs: business logic in the database. Even when not the intention, it tends to somehow always end up that way.
But again, that gripe exists regardless of whether you use microservices or not. The only reason it looks like a bigger issue is because microservices push you to modernize your entire architecture, and sprocs are not that favored anymore in modern architectures.
There is nothing that explicitly forbids or argues against using stored procedures with microservices.
Disclaimer: I don't like stored procedures from a developer's POV, but that is not related to microservices in any way.
Stored procedures typically work on a monolith database.
I think you're succumbing to a logical fallacy.
Stored procedures are on the decline nowadays. Most stored procedures that are still in use are from an older codebase that's been kept around. Back then, monolithic databases were also much more prevalent compared to when microservices have become popular.
Stored procs and monolithic databases both occur in old codebases, which is why you see them together more often. But that's not a causal link. You don't use stored procs because you have a monololithic database. You don't have a monolithic database because you use stored procs.
most books on microservices recommend one database per microservice.
There is no technical reason why these smaller databases cannot have stored procedures.
As I mentioned, I don't like stored procs. I find them cumbersome and resistant to future maintenance. I do think that spreading sprocs over many small databases further exacerbates the issues that I already don't like. But that doesn't mean it can't be done.
again most microservice architecture books state that they should be autonomous and loosely coupled. Using stored procedures written say specifically in Oracle, tightly couples the microservice to that technology.
On the other side, the same argument can be made for whatever ORM your microservice uses. Not every ORM will support every database either. Coupling (specifically its tightness) is a relative concept. It's a matter of being as loose as you can reasonably be.
Sprocs do suffer from tight coupling in general regardless of microservices. I would advise against sprocs in general, but not particularly because you're using microservices. It's the same argument as before: I don't think sprocs are the way to go (in general), but that might just be my bias, and it's not related to microservices.
most msa books (that I have read) recommend that microservices should be business oriented (designed using ddd). By moving business logic into stored procedures in the database this is no longer the case.
This has always been my main gripe about sprocs: business logic in the database. Even when not the intention, it tends to somehow always end up that way.
But again, that gripe exists regardless of whether you use microservices or not. The only reason it looks like a bigger issue is because microservices push you to modernize your entire architecture, and sprocs are not that favored anymore in modern architectures.
edited 8 hours ago
answered 8 hours ago
FlaterFlater
9,8313 gold badges18 silver badges28 bronze badges
9,8313 gold badges18 silver badges28 bronze badges
I'm not sure if it is correct to say that microservices push you to modernize your entire architecture. More often than not, they end up being a thin layer over a behemoth of a mess of poorly planned code. They can be pretty good when well done, but they don't really push you in any way towards better coding than any other architecture. Still, good answer. You got a +1 from me.
– T. Sar
4 hours ago
@T.Sar modern is not the same as better. Refactoring (to microservices or whatever) means change. Change forces you to use your current ideas. We hope they are better ideas.
– candied_orange
4 hours ago
@T.Sar: Hacks are timeless, and you can usually abuse any system (modern or not) to do something it can technically handle but was never intended for. Microservices urge you to do it differently (and thus reevaluate some old approaches) but they can't universally enforce it. With universal enforcement you usually suffer in the compatibility/valid fringe case department.
– Flater
4 hours ago
@candied_orange "modern is not the same as better" - I think I wholeheartedly agree to that. Very good point.
– T. Sar
2 hours ago
add a comment
|
I'm not sure if it is correct to say that microservices push you to modernize your entire architecture. More often than not, they end up being a thin layer over a behemoth of a mess of poorly planned code. They can be pretty good when well done, but they don't really push you in any way towards better coding than any other architecture. Still, good answer. You got a +1 from me.
– T. Sar
4 hours ago
@T.Sar modern is not the same as better. Refactoring (to microservices or whatever) means change. Change forces you to use your current ideas. We hope they are better ideas.
– candied_orange
4 hours ago
@T.Sar: Hacks are timeless, and you can usually abuse any system (modern or not) to do something it can technically handle but was never intended for. Microservices urge you to do it differently (and thus reevaluate some old approaches) but they can't universally enforce it. With universal enforcement you usually suffer in the compatibility/valid fringe case department.
– Flater
4 hours ago
@candied_orange "modern is not the same as better" - I think I wholeheartedly agree to that. Very good point.
– T. Sar
2 hours ago
I'm not sure if it is correct to say that microservices push you to modernize your entire architecture. More often than not, they end up being a thin layer over a behemoth of a mess of poorly planned code. They can be pretty good when well done, but they don't really push you in any way towards better coding than any other architecture. Still, good answer. You got a +1 from me.
– T. Sar
4 hours ago
I'm not sure if it is correct to say that microservices push you to modernize your entire architecture. More often than not, they end up being a thin layer over a behemoth of a mess of poorly planned code. They can be pretty good when well done, but they don't really push you in any way towards better coding than any other architecture. Still, good answer. You got a +1 from me.
– T. Sar
4 hours ago
@T.Sar modern is not the same as better. Refactoring (to microservices or whatever) means change. Change forces you to use your current ideas. We hope they are better ideas.
– candied_orange
4 hours ago
@T.Sar modern is not the same as better. Refactoring (to microservices or whatever) means change. Change forces you to use your current ideas. We hope they are better ideas.
– candied_orange
4 hours ago
@T.Sar: Hacks are timeless, and you can usually abuse any system (modern or not) to do something it can technically handle but was never intended for. Microservices urge you to do it differently (and thus reevaluate some old approaches) but they can't universally enforce it. With universal enforcement you usually suffer in the compatibility/valid fringe case department.
– Flater
4 hours ago
@T.Sar: Hacks are timeless, and you can usually abuse any system (modern or not) to do something it can technically handle but was never intended for. Microservices urge you to do it differently (and thus reevaluate some old approaches) but they can't universally enforce it. With universal enforcement you usually suffer in the compatibility/valid fringe case department.
– Flater
4 hours ago
@candied_orange "modern is not the same as better" - I think I wholeheartedly agree to that. Very good point.
– T. Sar
2 hours ago
@candied_orange "modern is not the same as better" - I think I wholeheartedly agree to that. Very good point.
– T. Sar
2 hours ago
add a comment
|
To write software requires that you tightly couple to a technology.
At the very least to the runtime environment provided by the programming language being developed within.
More generally though you will find that your micro-service is tightly coupled to several technologies:
- Network Service Framework to provide high level http/ssl/soap protocol implementations
- Repository/ORM/DAO Framework to provide persistence.
- Data Manipulation Frameworks to provide tools for working with data.
- Process/Threading/OS Framework to provide access to os resources such as multi-tasking, the file system, memory, gpu compute, expansion cards, etc...
And that is to make a bare-bones micro-service.
Stored procedures
A stored procedure is simply another technology that you could choose to use or not use. It does not magically make your code monolithic, or micro.
What it is though is:
- Another technology. Each technology present in the application decreases the likely-hood that any given programmer can read, understand, and make wise design choices for that technology mix.
- A language using a different programming paradigm. It is far too easy for non-experts to try and force their own imperative/functional/oo/etc... perspective onto it, which often leads to less than stellar results.
- An API. Which must be maintained like any other class in the code base. It also means that the database is providing a non-generic interface. This makes it harder to both replace the database engine itself, and to transparently apply generic behaviour such as in memory caching.
- An artefact. Which must be versioned, tested, and deployed. This can be done, but databases are living artifacts requiring a different approach. You cannot usually just delete the original, and replace it. Often a careful orchestration of changes over-time are needed to migrate the system to the desired state.
Each of these is a real cost. In some cases the cost is justifiable, in others it is not.
You would be paying almost the same set of costs by hosting a scripting engine. The sole reduction is that you could choose the same programming paradigm as the host language.
Business Logic
Moving business rules into the database is bad practice. Just not because of stored procedures.
Its a bad practice because the database and business logic operate on different shearing levels.
A database in a mature applications can be in use for decades. Generally these systems will have the engine periodically updated, but the database itself was migrated. It was not killed and rebuilt from the start. There is no reason a micro service cannot be equally so long lived.
Contrast decades against how quickly business rules change. In my experience an old business rule is perhaps a few years old, most however change quickly, and you can never tell which one will change next. A new requirement from a regulator, an old product being decommissioned, changes to the letter head, changes to how many employees report to a boss, etc, etc, etc...
If the business logic is distributed across the shearing layers, particularly into a slower and longer lived layer, it will generate resistance to change. This is not necessarily a bad thing. Afterall the only database that has zero business logic in it is a triple store.
The mere act of specifying a table schema is moving business logic into the database.
Architecture
You are contending with using the appropriate tool for the appropriate problem, without needing too many tools, nor making it too hard to solve, in order to make and maintain a solution.
This isn't easy.
But lets think the unthinkable, how would you maintain business logic distributed across several languages?
- A catalogue... so that each business rule implementation can be tracked and maintained.
- Tests... that could be used against each business rule regardless of where and how it was implemented.
- A reference implementation.. so that when discrepancies are found, a source of truth exists (or at least a source of debate).
But this has a cost too.
- Is it better to allow the business rules to have many implementations? That can each take advantage of the team skills, and framework provisions, but needing tight quality controls to ward off having many small vagaries?
- Or is it better to have a single source of truth, written in a single language? Arguably cheaper to implement, yet also a single source of failure, itself a monolithic component that resists change in the face of different platforms, frameworks, or as yet to be invented tools?
add a comment
|
To write software requires that you tightly couple to a technology.
At the very least to the runtime environment provided by the programming language being developed within.
More generally though you will find that your micro-service is tightly coupled to several technologies:
- Network Service Framework to provide high level http/ssl/soap protocol implementations
- Repository/ORM/DAO Framework to provide persistence.
- Data Manipulation Frameworks to provide tools for working with data.
- Process/Threading/OS Framework to provide access to os resources such as multi-tasking, the file system, memory, gpu compute, expansion cards, etc...
And that is to make a bare-bones micro-service.
Stored procedures
A stored procedure is simply another technology that you could choose to use or not use. It does not magically make your code monolithic, or micro.
What it is though is:
- Another technology. Each technology present in the application decreases the likely-hood that any given programmer can read, understand, and make wise design choices for that technology mix.
- A language using a different programming paradigm. It is far too easy for non-experts to try and force their own imperative/functional/oo/etc... perspective onto it, which often leads to less than stellar results.
- An API. Which must be maintained like any other class in the code base. It also means that the database is providing a non-generic interface. This makes it harder to both replace the database engine itself, and to transparently apply generic behaviour such as in memory caching.
- An artefact. Which must be versioned, tested, and deployed. This can be done, but databases are living artifacts requiring a different approach. You cannot usually just delete the original, and replace it. Often a careful orchestration of changes over-time are needed to migrate the system to the desired state.
Each of these is a real cost. In some cases the cost is justifiable, in others it is not.
You would be paying almost the same set of costs by hosting a scripting engine. The sole reduction is that you could choose the same programming paradigm as the host language.
Business Logic
Moving business rules into the database is bad practice. Just not because of stored procedures.
Its a bad practice because the database and business logic operate on different shearing levels.
A database in a mature applications can be in use for decades. Generally these systems will have the engine periodically updated, but the database itself was migrated. It was not killed and rebuilt from the start. There is no reason a micro service cannot be equally so long lived.
Contrast decades against how quickly business rules change. In my experience an old business rule is perhaps a few years old, most however change quickly, and you can never tell which one will change next. A new requirement from a regulator, an old product being decommissioned, changes to the letter head, changes to how many employees report to a boss, etc, etc, etc...
If the business logic is distributed across the shearing layers, particularly into a slower and longer lived layer, it will generate resistance to change. This is not necessarily a bad thing. Afterall the only database that has zero business logic in it is a triple store.
The mere act of specifying a table schema is moving business logic into the database.
Architecture
You are contending with using the appropriate tool for the appropriate problem, without needing too many tools, nor making it too hard to solve, in order to make and maintain a solution.
This isn't easy.
But lets think the unthinkable, how would you maintain business logic distributed across several languages?
- A catalogue... so that each business rule implementation can be tracked and maintained.
- Tests... that could be used against each business rule regardless of where and how it was implemented.
- A reference implementation.. so that when discrepancies are found, a source of truth exists (or at least a source of debate).
But this has a cost too.
- Is it better to allow the business rules to have many implementations? That can each take advantage of the team skills, and framework provisions, but needing tight quality controls to ward off having many small vagaries?
- Or is it better to have a single source of truth, written in a single language? Arguably cheaper to implement, yet also a single source of failure, itself a monolithic component that resists change in the face of different platforms, frameworks, or as yet to be invented tools?
add a comment
|
To write software requires that you tightly couple to a technology.
At the very least to the runtime environment provided by the programming language being developed within.
More generally though you will find that your micro-service is tightly coupled to several technologies:
- Network Service Framework to provide high level http/ssl/soap protocol implementations
- Repository/ORM/DAO Framework to provide persistence.
- Data Manipulation Frameworks to provide tools for working with data.
- Process/Threading/OS Framework to provide access to os resources such as multi-tasking, the file system, memory, gpu compute, expansion cards, etc...
And that is to make a bare-bones micro-service.
Stored procedures
A stored procedure is simply another technology that you could choose to use or not use. It does not magically make your code monolithic, or micro.
What it is though is:
- Another technology. Each technology present in the application decreases the likely-hood that any given programmer can read, understand, and make wise design choices for that technology mix.
- A language using a different programming paradigm. It is far too easy for non-experts to try and force their own imperative/functional/oo/etc... perspective onto it, which often leads to less than stellar results.
- An API. Which must be maintained like any other class in the code base. It also means that the database is providing a non-generic interface. This makes it harder to both replace the database engine itself, and to transparently apply generic behaviour such as in memory caching.
- An artefact. Which must be versioned, tested, and deployed. This can be done, but databases are living artifacts requiring a different approach. You cannot usually just delete the original, and replace it. Often a careful orchestration of changes over-time are needed to migrate the system to the desired state.
Each of these is a real cost. In some cases the cost is justifiable, in others it is not.
You would be paying almost the same set of costs by hosting a scripting engine. The sole reduction is that you could choose the same programming paradigm as the host language.
Business Logic
Moving business rules into the database is bad practice. Just not because of stored procedures.
Its a bad practice because the database and business logic operate on different shearing levels.
A database in a mature applications can be in use for decades. Generally these systems will have the engine periodically updated, but the database itself was migrated. It was not killed and rebuilt from the start. There is no reason a micro service cannot be equally so long lived.
Contrast decades against how quickly business rules change. In my experience an old business rule is perhaps a few years old, most however change quickly, and you can never tell which one will change next. A new requirement from a regulator, an old product being decommissioned, changes to the letter head, changes to how many employees report to a boss, etc, etc, etc...
If the business logic is distributed across the shearing layers, particularly into a slower and longer lived layer, it will generate resistance to change. This is not necessarily a bad thing. Afterall the only database that has zero business logic in it is a triple store.
The mere act of specifying a table schema is moving business logic into the database.
Architecture
You are contending with using the appropriate tool for the appropriate problem, without needing too many tools, nor making it too hard to solve, in order to make and maintain a solution.
This isn't easy.
But lets think the unthinkable, how would you maintain business logic distributed across several languages?
- A catalogue... so that each business rule implementation can be tracked and maintained.
- Tests... that could be used against each business rule regardless of where and how it was implemented.
- A reference implementation.. so that when discrepancies are found, a source of truth exists (or at least a source of debate).
But this has a cost too.
- Is it better to allow the business rules to have many implementations? That can each take advantage of the team skills, and framework provisions, but needing tight quality controls to ward off having many small vagaries?
- Or is it better to have a single source of truth, written in a single language? Arguably cheaper to implement, yet also a single source of failure, itself a monolithic component that resists change in the face of different platforms, frameworks, or as yet to be invented tools?
To write software requires that you tightly couple to a technology.
At the very least to the runtime environment provided by the programming language being developed within.
More generally though you will find that your micro-service is tightly coupled to several technologies:
- Network Service Framework to provide high level http/ssl/soap protocol implementations
- Repository/ORM/DAO Framework to provide persistence.
- Data Manipulation Frameworks to provide tools for working with data.
- Process/Threading/OS Framework to provide access to os resources such as multi-tasking, the file system, memory, gpu compute, expansion cards, etc...
And that is to make a bare-bones micro-service.
Stored procedures
A stored procedure is simply another technology that you could choose to use or not use. It does not magically make your code monolithic, or micro.
What it is though is:
- Another technology. Each technology present in the application decreases the likely-hood that any given programmer can read, understand, and make wise design choices for that technology mix.
- A language using a different programming paradigm. It is far too easy for non-experts to try and force their own imperative/functional/oo/etc... perspective onto it, which often leads to less than stellar results.
- An API. Which must be maintained like any other class in the code base. It also means that the database is providing a non-generic interface. This makes it harder to both replace the database engine itself, and to transparently apply generic behaviour such as in memory caching.
- An artefact. Which must be versioned, tested, and deployed. This can be done, but databases are living artifacts requiring a different approach. You cannot usually just delete the original, and replace it. Often a careful orchestration of changes over-time are needed to migrate the system to the desired state.
Each of these is a real cost. In some cases the cost is justifiable, in others it is not.
You would be paying almost the same set of costs by hosting a scripting engine. The sole reduction is that you could choose the same programming paradigm as the host language.
Business Logic
Moving business rules into the database is bad practice. Just not because of stored procedures.
Its a bad practice because the database and business logic operate on different shearing levels.
A database in a mature applications can be in use for decades. Generally these systems will have the engine periodically updated, but the database itself was migrated. It was not killed and rebuilt from the start. There is no reason a micro service cannot be equally so long lived.
Contrast decades against how quickly business rules change. In my experience an old business rule is perhaps a few years old, most however change quickly, and you can never tell which one will change next. A new requirement from a regulator, an old product being decommissioned, changes to the letter head, changes to how many employees report to a boss, etc, etc, etc...
If the business logic is distributed across the shearing layers, particularly into a slower and longer lived layer, it will generate resistance to change. This is not necessarily a bad thing. Afterall the only database that has zero business logic in it is a triple store.
The mere act of specifying a table schema is moving business logic into the database.
Architecture
You are contending with using the appropriate tool for the appropriate problem, without needing too many tools, nor making it too hard to solve, in order to make and maintain a solution.
This isn't easy.
But lets think the unthinkable, how would you maintain business logic distributed across several languages?
- A catalogue... so that each business rule implementation can be tracked and maintained.
- Tests... that could be used against each business rule regardless of where and how it was implemented.
- A reference implementation.. so that when discrepancies are found, a source of truth exists (or at least a source of debate).
But this has a cost too.
- Is it better to allow the business rules to have many implementations? That can each take advantage of the team skills, and framework provisions, but needing tight quality controls to ward off having many small vagaries?
- Or is it better to have a single source of truth, written in a single language? Arguably cheaper to implement, yet also a single source of failure, itself a monolithic component that resists change in the face of different platforms, frameworks, or as yet to be invented tools?
answered 6 hours ago
Kain0_0Kain0_0
6,2066 silver badges23 bronze badges
6,2066 silver badges23 bronze badges
add a comment
|
add a comment
|
Stored procedures are implementation details. Database functions, lambdas or a shell script stored somewhere in the file system all are implementation details and irrelevant for the architecture. Microservice doesn't forbid the implementation of one or another solution. As soon as we don't break the golden rule of decoupling because it would defeat the purpose of the architecture, hence the chances for the business' strategy to success.
Bear always in mind that any architecture is a meant to an end. We don't build MS ecosystems for fashion or love to the art.
most books on microservices recommend one database per microservice.
Ok, so we can code the store procedures in these databases.
again most microservice architecture books state that they should be
autonomous and loosely coupled
Between business capabilities, development's life cycles, management,
deployments, team's locations, etc. Nothing to do with the implementation details. Microservices don't solve a technical problem (just the opposite). They come to solve problems with the management and the time-to-market. It's a strategy, not a tactic. A way to fail-fast with the least costs possibles. If a certain business capability is proven to be wrong or unworthy, we drop it without messing other capabilities.
Note that the "splitting" already acts like a decoupling agent. I mean, we have two services, A is backed by Oracle and B by MongoDB. If we didn't break the golden rule, should be possible for us to drop A + Oracle with 0 side effects on B. Look at the big picture, because the small one is irrelevant for the MS architecture.
Using stored procedures written say specifically in Oracle, tightly
couples the microservice to that technology.
It might cause vendor locking. Many times, the vendor is imposed by the business by historical or contractual reasons. I have worked on projects where everything was unclear but the database. The database already was there. In any case, is important to know how to not lock our code to the vendor. Some ORM and frameworks implement an abstraction language that hides the database built-in functions and features.
Although, if our services are micro enough, vendor locking is no longer a problem since it impacts a small part of the whole. A small part that should be possible to be replaced (or isolated) quickly.
most MSA books (that I have read) recommend that microservices should
be business oriented (designed using DDD).
Should be business-driven and here the thing. Not all business' takes advantage of DDD. DDD and MS overlap in many points, but they are not cause-effect. We could end up with an MS ecosystem of anaemic services and still be a good implementation of the architecture.
Regarding books. Bear in mind that they only focus on the execution of the strategy. The tactic. How to make possible a strategy based on distributed computing, but they are (usually) agnostic to the strategy. So you still have to extrapolate what they said to your specific case.
add a comment
|
Stored procedures are implementation details. Database functions, lambdas or a shell script stored somewhere in the file system all are implementation details and irrelevant for the architecture. Microservice doesn't forbid the implementation of one or another solution. As soon as we don't break the golden rule of decoupling because it would defeat the purpose of the architecture, hence the chances for the business' strategy to success.
Bear always in mind that any architecture is a meant to an end. We don't build MS ecosystems for fashion or love to the art.
most books on microservices recommend one database per microservice.
Ok, so we can code the store procedures in these databases.
again most microservice architecture books state that they should be
autonomous and loosely coupled
Between business capabilities, development's life cycles, management,
deployments, team's locations, etc. Nothing to do with the implementation details. Microservices don't solve a technical problem (just the opposite). They come to solve problems with the management and the time-to-market. It's a strategy, not a tactic. A way to fail-fast with the least costs possibles. If a certain business capability is proven to be wrong or unworthy, we drop it without messing other capabilities.
Note that the "splitting" already acts like a decoupling agent. I mean, we have two services, A is backed by Oracle and B by MongoDB. If we didn't break the golden rule, should be possible for us to drop A + Oracle with 0 side effects on B. Look at the big picture, because the small one is irrelevant for the MS architecture.
Using stored procedures written say specifically in Oracle, tightly
couples the microservice to that technology.
It might cause vendor locking. Many times, the vendor is imposed by the business by historical or contractual reasons. I have worked on projects where everything was unclear but the database. The database already was there. In any case, is important to know how to not lock our code to the vendor. Some ORM and frameworks implement an abstraction language that hides the database built-in functions and features.
Although, if our services are micro enough, vendor locking is no longer a problem since it impacts a small part of the whole. A small part that should be possible to be replaced (or isolated) quickly.
most MSA books (that I have read) recommend that microservices should
be business oriented (designed using DDD).
Should be business-driven and here the thing. Not all business' takes advantage of DDD. DDD and MS overlap in many points, but they are not cause-effect. We could end up with an MS ecosystem of anaemic services and still be a good implementation of the architecture.
Regarding books. Bear in mind that they only focus on the execution of the strategy. The tactic. How to make possible a strategy based on distributed computing, but they are (usually) agnostic to the strategy. So you still have to extrapolate what they said to your specific case.
add a comment
|
Stored procedures are implementation details. Database functions, lambdas or a shell script stored somewhere in the file system all are implementation details and irrelevant for the architecture. Microservice doesn't forbid the implementation of one or another solution. As soon as we don't break the golden rule of decoupling because it would defeat the purpose of the architecture, hence the chances for the business' strategy to success.
Bear always in mind that any architecture is a meant to an end. We don't build MS ecosystems for fashion or love to the art.
most books on microservices recommend one database per microservice.
Ok, so we can code the store procedures in these databases.
again most microservice architecture books state that they should be
autonomous and loosely coupled
Between business capabilities, development's life cycles, management,
deployments, team's locations, etc. Nothing to do with the implementation details. Microservices don't solve a technical problem (just the opposite). They come to solve problems with the management and the time-to-market. It's a strategy, not a tactic. A way to fail-fast with the least costs possibles. If a certain business capability is proven to be wrong or unworthy, we drop it without messing other capabilities.
Note that the "splitting" already acts like a decoupling agent. I mean, we have two services, A is backed by Oracle and B by MongoDB. If we didn't break the golden rule, should be possible for us to drop A + Oracle with 0 side effects on B. Look at the big picture, because the small one is irrelevant for the MS architecture.
Using stored procedures written say specifically in Oracle, tightly
couples the microservice to that technology.
It might cause vendor locking. Many times, the vendor is imposed by the business by historical or contractual reasons. I have worked on projects where everything was unclear but the database. The database already was there. In any case, is important to know how to not lock our code to the vendor. Some ORM and frameworks implement an abstraction language that hides the database built-in functions and features.
Although, if our services are micro enough, vendor locking is no longer a problem since it impacts a small part of the whole. A small part that should be possible to be replaced (or isolated) quickly.
most MSA books (that I have read) recommend that microservices should
be business oriented (designed using DDD).
Should be business-driven and here the thing. Not all business' takes advantage of DDD. DDD and MS overlap in many points, but they are not cause-effect. We could end up with an MS ecosystem of anaemic services and still be a good implementation of the architecture.
Regarding books. Bear in mind that they only focus on the execution of the strategy. The tactic. How to make possible a strategy based on distributed computing, but they are (usually) agnostic to the strategy. So you still have to extrapolate what they said to your specific case.
Stored procedures are implementation details. Database functions, lambdas or a shell script stored somewhere in the file system all are implementation details and irrelevant for the architecture. Microservice doesn't forbid the implementation of one or another solution. As soon as we don't break the golden rule of decoupling because it would defeat the purpose of the architecture, hence the chances for the business' strategy to success.
Bear always in mind that any architecture is a meant to an end. We don't build MS ecosystems for fashion or love to the art.
most books on microservices recommend one database per microservice.
Ok, so we can code the store procedures in these databases.
again most microservice architecture books state that they should be
autonomous and loosely coupled
Between business capabilities, development's life cycles, management,
deployments, team's locations, etc. Nothing to do with the implementation details. Microservices don't solve a technical problem (just the opposite). They come to solve problems with the management and the time-to-market. It's a strategy, not a tactic. A way to fail-fast with the least costs possibles. If a certain business capability is proven to be wrong or unworthy, we drop it without messing other capabilities.
Note that the "splitting" already acts like a decoupling agent. I mean, we have two services, A is backed by Oracle and B by MongoDB. If we didn't break the golden rule, should be possible for us to drop A + Oracle with 0 side effects on B. Look at the big picture, because the small one is irrelevant for the MS architecture.
Using stored procedures written say specifically in Oracle, tightly
couples the microservice to that technology.
It might cause vendor locking. Many times, the vendor is imposed by the business by historical or contractual reasons. I have worked on projects where everything was unclear but the database. The database already was there. In any case, is important to know how to not lock our code to the vendor. Some ORM and frameworks implement an abstraction language that hides the database built-in functions and features.
Although, if our services are micro enough, vendor locking is no longer a problem since it impacts a small part of the whole. A small part that should be possible to be replaced (or isolated) quickly.
most MSA books (that I have read) recommend that microservices should
be business oriented (designed using DDD).
Should be business-driven and here the thing. Not all business' takes advantage of DDD. DDD and MS overlap in many points, but they are not cause-effect. We could end up with an MS ecosystem of anaemic services and still be a good implementation of the architecture.
Regarding books. Bear in mind that they only focus on the execution of the strategy. The tactic. How to make possible a strategy based on distributed computing, but they are (usually) agnostic to the strategy. So you still have to extrapolate what they said to your specific case.
edited 3 hours ago
answered 3 hours ago
LaivLaiv
8,3981 gold badge15 silver badges45 bronze badges
8,3981 gold badge15 silver badges45 bronze badges
add a comment
|
add a comment
|
Johnny Alpha is a new contributor. Be nice, and check out our Code of Conduct.
Johnny Alpha is a new contributor. Be nice, and check out our Code of Conduct.
Johnny Alpha is a new contributor. Be nice, and check out our Code of Conduct.
Johnny Alpha is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Software Engineering Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsoftwareengineering.stackexchange.com%2fquestions%2f398436%2fmicroservices-and-stored-procedures%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
A multitier architecture encourages application logic to be decoupled from the data storage. It's alright to have stored procedures sanitize any data issues you have, as long as it doesn't go beyond that.
– john
8 hours ago