5 ms·
Alternately: design your application as a bunch of Service objects with clear APIs that make (the moral equivalent of) RPC requests to one-another. Do this all
by derefr 11y ago
Alternately: design your application as a bunch of Service objects with clear APIs that make (the moral equivalent of) RPC requests to one-another. Do this all in the same process. Whenever a Service turns out to need separate scaling, hoist the code for it out (no need to change it) and replace the "null modem" RPC layer between it and the rest of your code with a real socket-based gateway.
Hey! You've just invented Erlang!
- taeric 11y agoThat "with clear APIs" is where you are going to fall on your face. Hard. And is the point. At the beginning, you often don't know where the actual useful boundaries will be. You probably know where you want them, but ultimately that is just an aspirational point.
- ecoffey 11y agoYes, but discovering and refactoring to those clear APIs is easier across the in-process call stack. Have to delay the "hoist and introduce a socket" until you're /reasonably/ confident you have the API more-or-less settled
- tel 11y agoThis is where types come in handy. With types you are constantly declaring APIs, publicly and with confidence, so it's easier when one starts to bear real load.
- taeric 11y agoOddly, this is just another place this same problem can hit you. Sometimes, cleanly defining your types is not easy at the outset.
- ecnahc515 11y agoWhy is why it's nice to start with things more coupled together, so that when you need to change the interface, it's only a difference in how you call your interface, and this is much easier when everything is in the same service.
- dllthomas 11y ago"Oddly, this is just another place this same problem can hit you. Sometimes, cleanly defining your types is not easy at the outset." The problem ("you don't entirely understand the space your solution will inhabit; some of what you build will be wrong") will hit you regardless of how coupled or decoupled, typed or untyped. The question is, "do your tools help you adapt", and having defined your interfaces with types your tooling will quickly tell you - when you change the interface - everything you broke. Without types, this is tremendously more painful (feeling this in Python presently).
- taeric 11y agoThis only applies if the only tool you have is your type system. It is not inconceivable to have a system that verifies you do not pass anything to a function that can not satisfy the methods that you call on it. For all functions you have in your system. Is this close to 100% inferred types. Yeah. But that is ultimately the point. Explicitly typing your code can be error prone. And, yes. So can leaving out all types. Far as I am aware, nobody has found a silver bullet, yet.
- dllthomas 11y agoYour comment is incoherent. First, it applies so long as a type system is an effective tool at telling you this, and so long as that tool is not completely (or at least substantially) supplanted by other tools. In no way does it have to be "the only tool" - there are lots of tools I find useful to tell me when things are going wrong in my code: types, tests, assertions, linting. Even with the other three, types cover meaningful territory. Second, as you half note, the system you describe would be a type system (and sounds somewhat similar to core.typed in clojure, though my understanding thereof is tremendously superficial). The rest of your comment just seems not to follow. Type systems aren't silver bullets for keeping agility in the face of changes, in the same way that hammers aren't silver bullets for driving nails. You can use them wrong, you can hurt yourself, but you sure want one (... but probably not the weird shaped one with a loose head over there labeled "Java"...).
- 11y ago
- socceroos 11y agoYes, you're right. This is what kept me from pursuing CQRS+Event Sourcing+DDD. It's not very flexible if you don't get it right the first time.
- wskinner 11y agoChris Stucchio advocates exactly this approach here: https://www.chrisstucchio.com/blog/2014/microservices_for_the_grumpy_neckbeard.html https://www.chrisstucchio.com/blog/2014/microservices_for_th... tl;dr: "When building reliable software, the network is your enemy. Distributed systems are simply hard."
- wskinner 11y agoChris Stucchio advocates exactly this approach here: https://www.chrisstucchio.com/blog/2014/microservices_for_the_grumpy_neckbeard.html https://www.chrisstucchio.com/blog/2014/microservices_for_th... tl;dr: "When building reliable software, the network is your enemy. Distributed systems are simply hard."
- Too 11y agoHey! Suddenly code that ran quickly serially will have tons of network latency blocking in places where it shouldn't. Code that should communicate over network must be written with that in mind from the start, i'm not saying doing this locally can't be done but designing this api correctly will be just as hard as making a distributed one from the start. People with the monolith mindset will not be able to do it.
- derefr 11y ago> People with the monolith mindset will not be able to do it. That's like saying "people with the phlostigon mindset will not be able to electrically insulate your house." Of course they won't, but why are you letting them touch your house in the first place? Designing components for the possibility that they'll be used in a distributed context is just proper software engineering—it's just thinking quantitatively about cohesion and coupling, really—and is to be expected of a proper software engineer. ...but that sounds crazy, right? I mean, we both know how hard it is to hire a proper distributed systems engineer. That's the implicit complaint you're making here. Well, but wait—why is it hard? I don't think it's an intrinsic thing. Distributed systems aren't any more complicated than calculus or graph theory. It's not like we couldn't make the proper design of them a required course in colleges. Thus, I would say it's hard precisely because people (including curriculum planners) think that there are only the two alternatives: either up-front-designing a monolith with low operational costs and fast iteration, or up-front-designing a formation of distributed components with high operational costs and slow iteration. The second alternative is obviously bad anywhere but at scale, and we need very few engineers that can operate "at scale", so it ends up not being seen as a required skill. But, obviously, those aren't the only two options! If you have the engineers with the skill to design distributed systems, and then have them start off your software design as a "distributed system all in one process", then you get the best of both worlds: low operational overhead, fast iteration from the start (redrawing the service boundaries when you're still at the experimentation phase will be painless as long as you use a framework/language/platform that abstracts away inter-service RPC), and a design that organically "anneals into" a proper set of services, instead of a big ball of circularly-dependent mud. But, again, you need actually-competent engineers.
- deleted 11y ago[deleted]