News for hackers. Stuff that matters.
Re:Monolith First (2015) by eropple on Saturday July 15, 2017 @05:19PM (#14779007)
I do devops. I consult for startups. And while it would make me a lot more money in the short term to fuel their microservice-first, sparkly-architecture aspirations, this is exactly the approach I take when I pour some water on that. Your Big Ugly Monolith will get you where you're trying to go if anything will. You don't need services, you don't need microservices, you don't need some bloggable-as-heck Kubernetes setup with pet sets holding your billionty different datastores--you need a webserver and one data store and maybe a cache, eventually. You grow from there.

Where I do push, though (and this often surprises people because "what does a devops person know about code architecture"--the answer is "a lot, both from writing it and seeing it badly written"), is hard demands of app statelessness and an encouragement of business logic internals that are functional in nature, with I/O, wireups, etc. handled at the outer edges of the application. Functional-core-imperative-shell lends itself to decomposition later if you need services (and I say "need services" because the size of the set of companies that "need microservices" is within epsilon of zero)--you replace RPC with a network layer because you built your app with clean, bright-line divisions.

Rule of thumb: if you have two "service" talking to the same set of data in the same general-purpose datastore (i.e., not pub-sub, not opposite ends of a job queue), they're the same service.

Re:Monolith First (2015) by Animats on Saturday July 15, 2017 @06:16PM (#14779315)
Rule of thumb: if you have two "service" talking to the same set of data in the same general-purpose datastore (i.e., not pub-sub, not opposite ends of a job queue), they're the same service.

Why? The whole point of a general-purpose database is to allow multiple applications to use the same data. Consider an online ordering system for merchandise. There's an service for checking product availability. There's a service for building a shopping cart. There's checkout and payment, the only one that faces the outside world that needs high security. There's customer order tracking. On the back end, there are various services which deal with fulfillment, shipping, accounting, and reordering. There may also be customer-relationship systems which can read order data for marketing purposes. Each of those functions can be worked on independently.

Re:Monolith First (2015) by dasil003 on Saturday July 15, 2017 @08:36PM (#14779867)
In this case I think it's proper to consider the database as a service in its own right. This is the way it always used to be done, and there are significant advantages, such as being able to focus on safeguarding the data, and leveraging ACID and constraints/stored procs to make the application code less error-prone.

The downside is you have a potentially hard scalability ceiling, and you have coupling of every downstream service to the schema which means all teams have to coordinate with the DB team for schema changes.

I think startups now always go the vertical services route without thinking too hard about it because A) they all aspire to be Amazon/Facebook/Google even though 99.99% will never face that scale and B) resume-driven development.

Re:Monolith First (2015) by humanrebar on Sunday July 16, 2017 @09:16AM (#14781861)
> resume-driven development

To be fair, until companies are willing to pay a premium (1) for working on bad-for-resume projects, this is very rational behavior on the part of the technical team.

1) That is, job listings can't have merely "competitive" or "market rate" salary expectations.

Re:Monolith First (2015) by ris on Sunday July 16, 2017 @02:20AM (#14780785)
> The downside is you have a potentially hard scalability ceiling

Which 99.9% of projects will never ever hit, and those that do will by that point have become such an extreme scale that significant reengineering should be something that's happening anyway.

I couldn't agree more with your last paragraph.

Re:Monolith First (2015) by vog on Sunday July 16, 2017 @02:41AM (#14780846)
This can't be said often enough: Scaling is a luxury problem!

It is far more likely that a company gets a "small", stable user base that provides enough income, than it is to become the next Google.

It doesn't make sense to apply all the complexity for large-scale problems when your user base isn't even small-scale. And if your monolith is structured in a remotely sane way, you can introduce microservices (or whatever will be best practice) later on.

On the other hand, it doesn't hurd to write your code with performance and scalability in mind. Neglecting this too hard may result in bad performance even for the first 10 users. But that's more in the sense of "keep it simple enough so it can be easily restructured later on". And in the sense of "measure performance to know your hot spots" ... and concentrate you efforts there.

Re:Monolith First (2015) by ris on Sunday July 16, 2017 @12:16PM (#14782626)
> On the other hand, it doesn't hurt to write your code with performance and scalability in mind. Neglecting this too hard may result in bad performance even for the first 10 users.

Absolutely. But the architectural choices you make for making the first 1000 users fast are often the complete opposite of ones you'd have to make to make it "scale" to 100k users.

Service/microservice architectures that I've seen are, from an absolute point of view, hideously inefficient, simply because the component that needs data isn't able to ask for the data from the other component (way across the other side of the architecture) in a precise enough fashion. Cue reams of data being sent to you that you don't need because you need to figure out one small aspect of it. And of course, jsonifying it all and de-jsonifying it a few times for good measure. All this with no transaction safety.

Now, if you're operating at the kind of scale where you know that these specific calls are now part of your business critical requirements, you can spend the effort optimizing the hell out of them and reap the gain of horizontal scalability. Of course, that comes at the expense of flexibility.

Re:Monolith First (2015) by kpil on Sunday July 16, 2017 @08:03AM (#14781639)
The main problem is that micro service based architecture is sold as a silver bullet that takes care of all problems.

Knowledgeable and experienced people know that there is no free lunch, but not every opiniated voice isn't necessarily so, and refuting bullshit takes ten times more effort than producing it, so objections might be handwaved away as backwardness if there is a strong force for a modern architecture.

I mean, more of the same old shit isn't exactly an easy sell either, even if every old bad choice could be rationalized at the time...

Re:Monolith First (2015) by Animats on Saturday July 15, 2017 @11:47PM (#14780368)
As I point out occasionally, Wikipedia is MariaDB front-ended by various caching systems. There's some auxiliary stuff for logging and searching, but its synchronization is not mission critical. Wikipedia is the ninth most popular site on the web. You're probably not going to be bigger than that.
Re:Monolith First (2015) by jon-wood on Sunday July 16, 2017 @03:16AM (#14780941)
Wikipedia is also massively cacheable, much more so than almost any other application.
Re:Monolith First (2015) by rdnetto on Saturday July 15, 2017 @09:24PM (#14780018)
A variation on this would be to put the database behind a service that abstracted over the schema, though that only works for basic CRUD queries and not complex aggregations. This service would probably evolve from the monolith.
Re:Monolith First (2015) by rhizome on Sunday July 16, 2017 @01:11PM (#14782965)
It sounds like you're describing ORM-as-API. Which, if you find you need it, great, but I wouldn't try to fool myself that introducing a mediating process like that is all that different from what the language/framework likely already provides (contemporary development frameworks are common). It's just ("just") abstracted to operate on network basis. Actually, what you describe sounds like a reduction in functionality from a non-API model.

Hopefully that parses as English, it's still morning for me.

Re:Monolith First (2015) by collyw on Sunday July 16, 2017 @05:21AM (#14781250)
You mean like an API?
Re:Monolith First (2015) by sbov on Saturday July 15, 2017 @06:32PM (#14779406)
A huge point of microservices is to create code that is independent of eachother. Your database backend is tightly coupling what should be completely independent services. Microservices were designed to scale your engineering departments just as much (if not more than) your performance. You are throwing away the major point of why microservices were created in the first place when you do what you're doing: so teams in large organizations can do independent releases. That you cannot see this as a major benefit makes me think microservices are a poor choice for your use case.
Re:Monolith First (2015) by eternalban on Saturday July 15, 2017 @11:17PM (#14780294)
> You are throwing away the major point of why microservices were created in the first place when you do what you're doing: so teams in large organizations can do independent releases.

Let's ammend this: so teams in large organizations +{that lack both a coherent architecture and the ability to devise one} can do independent releases +{by adoptiong the no-architecture architecture}.

Re:Monolith First (2015) by marcuslager on Sunday July 16, 2017 @12:10AM (#14780439)
"teams in large organizations"

Could be simplified to just "teams.

These days from what I can see teams in organizations with no ability to devise a sane architecture usually take the microservice route. Management loves this new buzzword. To them it means problems go away.

Re:Monolith First (2015) by tajen on Sunday July 16, 2017 @05:58AM (#14781328)
Atlassian started rearchitecturing around services in 2013. They were 1500ppl at the time. Confluence and JIRA were not only monoliths, but non-multitenant, so they had to have one instance per customer (700Mb RAM JIRA, 700Mb Confluence, a dozen gigs on SSD). The worst was restarting upon upgrades: Easily 3-5 minutes per instance, which, at scale, was a huge burden.

After rearchitecting around services, pieces could be restarted and upgraded independently. As a customer, we didn't notice differences in the UI (e.g. the file storage on AWS).

Epilogue: They had a shared login system, multi tenant and all... which they recently replaced by a third party. Proof that services are replaceable, but also an acknowledgment that simple critical services can be hard at scale.

I personally believe that Atlassian switched to services at the right time, when it's hard to coordinate teams of thousands working on a dozen products, and when the monolithic approach was way past refactoring date ;)

Re:Monolith First (2015) by tokenizerrr on Sunday July 16, 2017 @09:00AM (#14781797)
On the flip side, cloud hosted jira is soooo slow now.
Re:Monolith First (2015) by tajen on Sunday July 23, 2017 @06:32PM (#14834769)
A bit late to answer, but by their EULA you are not allowed to talk about the performance of their products.

Yes, they did that!

Re:Monolith First (2015) by eternalban on Saturday July 22, 2017 @03:32PM (#14828920)
Rather a late reply but Service Oriented Architecture is in fact an architectural approach. "Micro" services deem even the burdern of devising a coherent "service" as too great a burden to tackle.
Re:Monolith First (2015) by ris on Sunday July 16, 2017 @12:26PM (#14782686)
> Confluence and JIRA were not only monoliths, but non-multitenant, so they had to have one instance per customer (700Mb RAM JIRA, 700Mb Confluence, a dozen gigs on SSD).

I don't understand how you engineer even a monolith like that in the first place.

Re:Monolith First (2015) by kod on Sunday July 16, 2017 @10:22AM (#14782053)
And Jira still can't handle email in a sane fashion...

I wouldn't look to Atlassian for anything regarding engineering practices.

Re:Monolith First (2015) by tomerbd on Monday July 17, 2017 @03:08PM (#14791432)
can you describe a coherent architecture that will turn microservices uneeded?
Re:Monolith First (2015) by eternalban on Sunday July 23, 2017 @09:08PM (#14835271)
Missed this but in case you read this, well that depends on the purpose of the system, but in most cases modular schemas and allowing for loose coupling via data/message bus does the job.
Re:Monolith First (2015) by tunesmith on Saturday July 15, 2017 @06:48PM (#14779503)
If that needs to be scaled out to many services, then you also want to scale out the data model. Meaning, events in a commit log, and services that subscribe to that commit log to create their own schemas that are tuned for their own needs. The more I think about commit logs, the more I think giant monolithic database schemas are just kind of weird - a strange compromise between history and state.
Re:Monolith First (2015) by xxxn on Saturday July 15, 2017 @08:16PM (#14779820)
this sounds like an absolutely enormous pain in the arse (cognitive overhead if you prefer.) what, specifically, is the bigger pain in the arse out there that one needs all this in order to avoid? it must be pretty awful.

also, what happens down the line when you suddenly need a service which is contingent on the data stored in multiple other services? do you add another synchronisation layer over the top?

Re:Monolith First (2015) by catern on Saturday July 15, 2017 @07:18PM (#14779647)
That's an interesting idea. If I understand correctly, you're suggesting that services simply broadcast the data mutations they are going to perform. Then, any other services that wish to use that data can filter those broadcasted mutations down to what is relevant to the other services, and store the data in a way that is efficient for what the other services want to do.

Are there any examples of things architected in that way?

Doesn't it also run into the problem of needing to version the events that you broadcast?

Re:Monolith First (2015) by jamesblonde on Saturday July 15, 2017 @07:28PM (#14779689)
It's the Kafka cool-aid being regurgitated. Kafka is the pipe that you need. Micro-services provide APIs to state that they manage that they get from Kafka. That all scales out and services have nice independent failure modes (as long as Kafka doesn't fail). What it doesn't consider, however, is if you have to perform atomic operations across micro-services (you can't easily do this with existing technology). And, yes, you would like exactly-once processing of events, which is non-trivial - even with the new exactly-once message reception feature in Kafka.

If your services are completely separable, this approach is great. Otherwise, monolith it.

Re:Monolith First (2015) by tomnipotent on Saturday July 15, 2017 @07:26PM (#14779679)
Event Sourcing [0] & CQRS [1] come to mind. I'm also a fan of Bottled Water [2] that turns Postgres ops into a stream of events that you can then push to other services.

[0] https://martinfowler.com/eaaDev/EventSourcing.html

[1] https://martinfowler.com/bliki/CQRS.html

[2] https://github.com/confluentinc/bottledwater-pg

Re:Monolith First (2015) by taurath on Saturday July 15, 2017 @07:35PM (#14779705)
It's hilarious to me that that came up, because that was a big part of the 6 month delay.
Re:Monolith First (2015) by raarts on Sunday July 16, 2017 @02:51AM (#14780871)
Any particular one or all three of them?
Re:Monolith First (2015) by karmajunkie on Saturday July 15, 2017 @06:55PM (#14779533)
Whether they can be worked on independently is not the criteria that matters (and in point of fact, its a false assertion in this case if they're using the same database, as neither can iterate on the schema of the data completely independently of the other). What matters is, can I take this service completely offline and have the other still function? If the share a datastore, then the answer is no.
Re:Monolith First (2015) by srtjstjsj on Saturday July 15, 2017 @07:50PM (#14779746)
All services depend on a router, so you can't take any one service _completely_ offline, so they are all part of one service.
Re:Monolith First (2015) by erikpukinskis on Monday July 17, 2017 @02:30PM (#14791141)
You presumed before you even started design that there would be such a thing as an order, which would be implicated in shopping, payment, and tracking.

There could also be separate order, invoice, and delivery.

Essentially your question is: what if my models are highly overloaded? Won't they need to be used in multiple places?

And of course the answer is yes. But if you are using the same model in dramatically different contexts you probably have a problem of another sort. This is the dreaded "One Object To Rule Them All" OO anti-pattern.

Re:Monolith First (2015) by Ma8ee on Saturday July 15, 2017 @06:37PM (#14779432)
And one day you realize you have to change your data model, and absolutely all your application are coupled to your whole database. Oups!
Re:Monolith First (2015) by Animats on Saturday July 15, 2017 @07:38PM (#14779715)
You can add a column to an SQL database without difficulty. If you're using one of those "turn database rows into objects" packages, you may have problems, but if you use SQL properly, it's fine. Components that are only data consumers will not even see the new column.
Re:Monolith First (2015) by olmo on Sunday July 16, 2017 @04:07AM (#14781079)
There is a solution for this problem: I use a monolith that make 100% of my sql queries using LINQ (including massive updates and so). Since Linq is strongly typed you can rename/remove/split tables and columns, fix compilation issues, create a migration and deploy the new monolith. We create an average of 5 migrations per day in a project with around 300 table for 2 years and no signs of an unmantainable mud so far.

Disclaimer: I'm the main developer behind Signum Framework

Re:Monolith First (2015) by noir_lord on Sunday July 16, 2017 @09:01AM (#14781806)
Just inherited exactly that.

The final cherry is that it uses zero joins, it's all done in code.

It's going to be a bastard to unfuck that mess.

Re:Monolith First (2015) by tnolet on Sunday July 16, 2017 @06:54AM (#14781472)
This is exactly what happened / is happening at my former employer. Already 2 years of work, team of 5 engineers, Kubernetes, dozens of microservices. Lot's of time wasted on CI/CD, orchestration, monitoring, refactoring. Live date? Probably somewhere next year. It was sad to watch. 100% resume-based development.
Re:Monolith First (2015) by avip on Sunday July 16, 2017 @10:12AM (#14782018)
RDD is 2010. It's called blog-driven development now (BDD)
Re:Monolith First (2015) by ebiester on Sunday July 16, 2017 @11:04AM (#14782258)
I agree with the rest of this, but CI isn't hard on a monolith, and it's well worth it. (CD is a tradeoff. If you understand why it's important for you, it might be worth it, but does add complexity.)
Re:Monolith First (2015) by taurath on Saturday July 15, 2017 @05:29PM (#14779064)
Couldn't agree more - inheritance chains and heavily stateful instruction environments are the number one blocker to eventually decoupling a monolith. The "enterprise" code style is absolutely what you need to avoid in a startup.
Re:Monolith First (2015) by JBReefer on Saturday July 15, 2017 @11:22PM (#14780311)
Absolutely agreed, where Enterprise === "making a profit"
Re:Monolith First (2015) by quickben on Saturday July 15, 2017 @09:52PM (#14780088)
If you avoid what you listed in actual software, you'll be left with a mess they will take years and tons of money to fix.
Re:Monolith First (2015) by beat on Sunday July 16, 2017 @12:43AM (#14780525)
Yes, but if you don't avoid it, you might never get off the ground to the point where you have years of time and tons of money in the first place.
Re:Monolith First (2015) by quickben on Monday July 17, 2017 @04:56PM (#14792195)
I guess it depends on the viewpoint. Yours sounds valid. Mine comes from the occasional fixing people's messes. But I agree with you, some product is better than no product in most cases.
Re:Monolith First (2015) by beat on Tuesday July 18, 2017 @02:38PM (#14798975)
I have a lot of career experience dealing with legacy software. I feel that pain intensely. But still... a working product with bugs and flaws is better than a not-working product that is elegantly built. Or half-built.
Re:Monolith First (2015) by srtjstjsj on Saturday July 15, 2017 @07:52PM (#14779752)
what is "enterprise" code style?