161 points · by kiyanwang · 4y ago · 234 comments
I’m sure it’s fascinating for people who are into that, and I’m not saying there isn’t a substantive problem to solve here, but I’d personally never go anywhere near a problem like this. It’s too many steps removed from the value. I’d keep thinking “we are down a very deep rabbit hole. A side quest off a side quest. Should we be doing this?”
But I’ve always worked at smaller places, where things like toolchains and sales ops and marketing tech don’t take on huge lives of their own.
Only valuing easily-measurable work is, frankly, a modern organizational disease. It's like searching for the keys under the streetlight—and why? As a substitute for human judgement or resolving disagreements? As a way to make work more legible for executives? It leads to unforced errors and systemic problems, but we can't seem to do anything about it.
My demo is to pick a random crash and diagnose the root cause while talking. The mean time to resolution is low single digit minutes.
I showed this to an entire team, one person at a time, solving bugs as I went. I showed the junior devs, senior devs, and their manager.
No interest. None. Just… silence.
The tools are amazing, but the lack of motivation from the typical developers for learning to use them is even more amazing.
As for your "side quest off a side quest" observation, I think that is a matter of perspective, about what personally motivates you, and about how work is organized in society. I find that working at a small company makes it easier to have a feeling of focus and purpose -- everybody is focused on one thing. But, I find that working at a large (profitable, well run) company makes it easier to feel like you can actually move the needle and have the resources do large things (and yes, this includes a connection between something like a 'build tools' team and being able to ship a quality product more quickly).
It is easy to miss that every race car needs a pit crew, every pit crew needs equipment and parts, getting parts requires suppliers, parts need to be built, tested, etc., all those people need to eat, all that food needs to be grown, and so on. Organizing all of that "work" into small single-purpose companies, that buy each others' stuff, is one way to go. Another way to go is to organize it into larger companies with sub-teams/groups/departments. So a company's larger mission might be "win races" but, if it is large enough, smaller support efforts in support of the larger goal can make a lot of sense.
I think tech companies should spend a lot more on speeding up their stack. I would love to do something like this (improving developer workflows in a giant organization) as my day job.
But saying that “it’s too many steps removed from the value” appears to be a misrepresentation of the value it adds.
> It’s too many steps removed from the value.
Don't be worried about being too many steps removed from the value. With that logic, CEOs, CTOs, etc are also too many steps removed from the value, yet they are valued very highly. Look at such infra work as multiplying the value of the entire company and in a way, being part of a "CEO team".
And this kind of reasoning is why tooling in most shops absolutely sucks
At scale, rabbit holes can be quite relevant. At scale, you can no longer trust that your personal view of the org is complete enough.
There's still plenty of waste but just because you don't need something doesn't mean it isn't in another team's hot loop. Best to come in with trust first and incredulity second.
There are tools out there, but they're not free and they involve some level of vendor lock in. I've worked on some monorepo build scripting myself.
And in fact, in this very article, the last paragraph actually states that they are aiming to increase the complexity of the change validation process?!?
> Additionally, it helped our team focus on increasing the complexity and features of our change validation process.
Personally, I haven't been super impressed with any of the engineering projects I've heard come out of Uber, but what they're doing obviously works to some degree so I can't be one to judge.
Uber is, partly, a software business. They need to ship software. They get direct value from shipping good software efficiently.
Look at the infrastructure required for that and what we spend on it. It’s massive.
The rest of the article is about their transition from their legacy infra like Jenkins to more modern and flexible things like buildkite (which is of course relevant for anyone in a similar transition).
If your company/project starts with bazel + remote cache + RBE you're pretty close to the end state they're trying to get to.
See also for OSS and paid solutions: https://bazel.build/community/remote-execution-services
With a monorepo, you don‘t need to think about which commits work with which other commits. One commit ID is a full description of every subcomponent.
I've just switched to a company with many tiny repos and IMO it's a huge hassle. There's no automated integration testing, and manual integration testing is a huge pain to set up.
I don't even know how I'd create integration tests that run as part of the CI. What version would I use? If you need to change both sides (very common), coordinating the commits and releases is very painful.
The "monstrously complex" build-and-test pipelines are a significant cost, but the alternative is higher release failure rate and moving slower overall IMO.
No clue if that’s fixed today but it soured the idea of monorepos for me, and that’s not incorporating how often submitqueue would go down.
1 repo == 1 bounded context == 1 isolated unit of deployment.
Which, well, the Uber people clearly have since these big changes exist.
The most obvious counterpoint: many systems of record need to scale command operations (writes) and query operations (reads) separately.
So you absolutely would have separate programs, ASGs etc for those two roles
I've seen people going crazy with this bullshit of monorepos to the point every single directory was a "package" when it could be just a plain module import.
If you want to do microservices, then putting everything back into a single repository and enforcing everyone to use the same version and every change to require upgrades and deploys across the board is totally backwards.
Either do a monolith and have that consistency, or do microservices and allow teams to follow their own rules as long as they keep APIs stable.
Nonorepos + microservices is just a demonstration of everything that's wrong in the technical aspects of our industry. Just applying absolutely everything you read about without even considering if it might be better or not for your specific use case.
The development view need not be connected to the deployment view at all, so unnecessarily coupling them can lead to worse outcomes. On the other hand, having the ability to couple them initially _and decouple them again in future_ works wonders for scaling.
I am consistently amazed that people with opinions on software architecture do not seem to recognise this seminal paper on the topic, or have the ability to re-synthesise it into tactics.
[1]: https://www.cs.ubc.ca/~gregor/teaching/papers/4+1view-archit...
The more clients a library or service has, the more expensive this is, and it's an ongoing maintenance cost for every client. Since people changing the service don't feel the full pain of this maintenance cost, changes keep on happening, and eventually clients get culled because it's too expensive to keep on maintaining them all.
From the outside, this looks like the company abandoning venerable but still working product, and makes people scratch their heads, wondering why.
People often conflate these two things because often teams actually want to have centralized dependencies (so that you're forced to update or die as you said). If that doesn't work for you you can choose to have modules (or groups of modules) keep their independent set of dependencies, all while keeping the code in the monorepo.
* Breaking changes can be done at once. Very helpful for runtime deps.
* No chance that a repo is out of date.
* Upgrades are atomic (may be hard to test a system in a half state).
'A well-designed system should not have X therefore you don't need Y.'
When 'A well-designed system should not have X' is just a matter of opinion, or doesn't acknowledge trade-offs that might make X the better option than Z, then this isn't a useful argument against Y.
at the risk of coming up with a contrived example: let's say you own a service that need to deserialize a datetime in a request in a format you don't currently support. assuming you own the stack, you need to a) update your date library b) update your webserver stack c) possibly update an intermediate webserver stack that includes primitives like logging, telemetry, tracing, auth, service discovery and d) your actual service.
If a->d are all independent, separate components, you have to orchestrate those changes through 4 separate repositories. And god forbid something you did at the lowest point in the stack is completely unworkable higher up.
There's all sorts of rocket science you could do to orchestrate these changes, but it ends up being contrived and edgecasey.
Most of the pain from monorepos can also be addressed with a dash of rocketscience (see:bazel), but the end model tends to have
a) have an easier mental model for the user
b) allow for consolidation of infrastructure work. Ie, your build/ci/language tooling teams can focus their efforts on one place
c) can coordinate changes across the entire stack within one field of view
d) can coral some of the worst, disparate instincts of a growing engineering org (ie, tons of teams optimizing for local maximas without internalizing knock-on effects).
e) fewer weird edgecases.
Besides the "N pull requests" problem you now lose history whenever you move a file across repo boundaries, and you'll eventually have straggler projects staying on old versions for years - so switching to a new way of doing something essentially means supporting both versions forever. Code for common needs gets duplicated, or worse, split out into yet another repository and /then/ duplicated, because no one wants to check if any of 100 repositories rely on the buggy behaviour they want to fix.
I find this to be this a level headed explanation of the advantages of monorepos: https://danluu.com/monorepo/. I'm surprised to see so many comments summarily dismissing them, as if sanely managing thousands of smaller interdependent repositories doesn't require at least as much investment in custom tooling.
Sure, each project team could upgrade independently, but the company that’s chosen a mono-repo for their go code is likely to desire to have a single team tackle this upgrade.
In practice, you often end up with larger changes which are mostly janitorial. Bumping a version of a log library across the infrastructure, or a version of a serialization system. This simplifies dependency convergence and a best handled as if they are cross-project changes.
The other problem is that over time, good factoring tend to deteriorate. A large software project will invariably have people with different brains working on it, and they'll have different needs for the factoring. So the project naturally pushes itself toward situations where cross-project changes become a necessary thing.
i’m finding it hard to think of a system at a large company that would have no internal libraries used by multiple projects, that wouldn’t require ever making a cross project change.
No, that way lies sorrow and despair. There should only be one version of any dependency being used in your company. Any deviations should require like VP-level approvals or something.
But when your team owns a repo, then at least the damage is contained within your team.
Google solves that problem with heavy NIH syndrome (its hard to get promoted by utilizing an external third-party lib, better develop your own), and writing tests, yes. And for those few third-party libraries that google still depends on, updating them is a big PITA.
When teams take the stability & versioning of their APIs seriously, the need to use monorepos to share that info is greatly reduced. A multi-repo approach is perfectly feasible when all components are working to established APIs, which also alleviates the issues mentioned in the article.
- easier to share and import common packages
- proto and thrift files are kept close to services and clients are updated globally automatically
- dependencies and go versions are managed globally and all services get the same security updates
- standardized build processes make it easier to manage large deployments
And honestly, after the initial repo download there were no visible downsides
Is the suggestion just "an easier way to avoid this problem is to not have so many tests?"
They also use mostly homegrown CI tools alongside phabricator for code review, or at least they did while I was there.
But also, why is it any different why are changes at a repo level all that much easier to track than, say, inspecting changed files and running tests according to what changed?
"There is nothing more permanent than a temporary solution"
A monorepo means every service is on the same set of versions of every dependency at a given point in time. It's much easier to reason about what is fixed, and move everything to a known good version.
I worked at a similarly large and almost as popular SF based company and I can assure you every innovation there was 100% motivated by somebody's desie to put.it in their CV. Nothing of what was made there made any sense for the business, it was just people playing with toys. And worst part was people introducing this stuff (such as the one pushing for Lerna and an "UI" monorepo would leave the company after 1 year leaving a mountain of tech debt behind. But hey, they had Lerna in their CV now.
I haven't done any calculation on how long that kind of changes can be done with polyrepo setup.
If they can do that, their story can only be better for single isolated changes. It seems from outside, Uber's monorepo development experience vastly better than many small startups with variety of development methodology (no matter monorepo, polyrepo, or continuous deployment, or waterfall development, or GitFlow (a type of waterfall)).
Much easier to apply horizontal and vertical changes which extend outside individual services e.g. update the interface of a service, or fix a bad pattern.
Zuul (https://zuul-ci.org/) was created for openstack to solve the issue of optimistic merges / PR queue testing.
When you use buildkite with own containers on AWS ecs you can use efs to do a git clone with reference. (https://git-scm.com/docs/git-clone#Documentation/git-clone.t...) Essentially what they do with a packed base repo, but you only end up sending what you need, not more.
The binary cache is available in other flavours too. If you don't use go, then sccache (https://github.com/mozilla/sccache) may be useful.
[0] https://buildjet.com/for-github-actions/blog/a-performance-r...
edited: wrong link
So even though you can more easily horizontally scale and handle infinite requests, the latency of each request will be much poorer than if you were just running on better hardware.
Naturally there is the caveat that using binary libraries isn't a thing in Go.
You either:
* Just don't test such changes at change time, break down and push the testing effort to downstream projects in disguise of "dependency management".
* Structure your engineering effort to avoid such changes, for example avoid having a base library shared between teams.
Neither is ideal for a corporation environment, because both harms velocity. We accept these in the "open source world" because we don't have better options, but the same does not hold for corps.
And now you get into the fun situation of having to handle ecosystemic asynchronous updates between your multiple repositories.
> We do that with all external dependencies.
Indeed. Why you’d want to also suffer that for internal dependencies when there is no reason to, I can’t fathom.
At that scale, anything reducing complexity is a bonus. At that scale, monorepos are great for that.
You call it Merkle-style tree despite the fact it is obviously a DAG?
--
Edit:
> Large changes are also more prone to outages. If we land them outside the working hours, there would be limited resources to mitigate potential outages. To prevent this, we ended up asking engineers to get up early to deploy these changes
Huh, landing changes to HEAD and releasing to production are not decoupled?
All trees are DAGs so that's not really adding much.
And describing it as a Merkle-style tree conveys additional implementation about the implementation - presumably the tree stores the hash ("computed from all of its source files and inputs") which just saying "it's a DAG" doesn't tell you.
Perhaps you’re complaining about it not being a tree because there can be multiple roots which seems fair enough.
[1] I think there are many ‘roots’ as roots are going to be leaf build targets like various executables or test results
https://eng.uber.com/research/keeping-master-green-at-scale/
Picking a language that has fast build speed, allows you to be more flexible, and able to test and deploy quicker
They had Go, wich builds very fast, but they failed to educate their developers to maintain a healthy build pipeline to avoid things getting too slow
This kind of developer will cost your company millions, make sure to educate them properly ;)
I'd never work for a company with slow build speed, part of the reason why i refuse to touch languages like Rust and C++, due to their insanely slow build speed, i refuse to live in a world like that
Use multiple repos. It doesn't hurt you know. And you can have proper granularity
The costs of monorepo seem to be much higher than just dealing with inter-dependencies. And you can always group projects if it makes sense
I'd be happy to see a counter-example, but I've not seen one yet.
Heck, even most individual developers use multiple repos.
Monorepos are usually ok (and even talking about team/project granularity) until you outgrow it.
Buildsystems like one-repo-per-project much better than monorepos. (Shipping a fix doesn't require rebuilding "the whole world" for example)
Seems to me that Git wasn't thought out for "monorepos" at first place as a VCS. Also, these companies should either use something else or not do monorepos.
Does this play nice with gopls (go language server) allowing you to jump around to definitions?
>is used most of the time with svn
It supports mercurial, git, and svn.
>I 'm curious why they opted for it in the first place, instead of a more modern platform.
It is a modern platform and works well.
„We solved an issue we created ourselves”.
Which sometimes is ofcourse what you have to do.
I was new to Phabricator, but I picked it up quickly. Even though it might not constantly pump out new features, Phabricator gets the job done.
Only very recently. Obviously after Uber adopted it.
> from what I remember and is used most of the time with svn
Nope.
> I'm curious why they opted for it in the first place, instead of a more modern platform.
Because it's quite good? It's not some archaic thing like SVN for which there's an obviously better newer option.
Having said that it is much harder to learn from others' mistakes than your own. Learning from your own success is hard too. Learning from others' success is the hardest by far. At least we have a glimpse (albeit indirectly) in this article of the mistakes they made.
I can't imagine deploying a functionality that needs to interact with 20 other services, if I can't have some zero-cost assurances like Go's typing and having all IDL available at developing time. This is of course is even better if at compile time I can check all contracts are still honoured. Monorepo is a really "cheap" way of getting all this for, close to, free.
What you say is also true
- applications: front, backend, background-worker
- libs: database-orm
In a multi-repo layout, if you want to make a change in database-orm, you'll make your PR in its repo, test, and make a release with your changes.
Nice and easy right ? Well, you're not done. Now you have to make a PR to update the dependency on each repo using this library. If you're lucky, nothing breaks and it's quite quick.
But it's not always so easy : you notice that you actually broke something down the line in the backend. You have to fix it (in your library), and do it all over again. You can also have libraries depending on other libraries, multiplying the effort when you messed up something.
The monorepo handles that, you update one library and you can see what you broke down the line, and fix all of that quicker. Also, changes are easier to follow since one modification impacting several applications or libraries can be made into only one commit.
You can tell me that libraries should have a nice definition and the applications should be independent from the actual internals, but that's rarely the case. It's a tradeoff and lots of companies are going this route.
The processes you describe are great to make teams think twice how to go at a change, instead of "let's change everything and see how it goes" attitude.
I built a tool to bring up every microservice locally so you could test every change together so the separate repository problem went away. It coordinates vagrant LXC environments.
The version I built at my employer was integrated with chef and Ansible. The version I built at my employer handled cloning and pulling dependencies too. And could build in parallel and deploy to local load balancer haproxies.
But my open source version is barebones by comparison. In the future I shall try build developer tools open source rather than trapping work at my employer.
HTTPS://GitHub.com/samsquire/platform-up
But yes - GitFlow or Environment Branch HELL is so common in the industry - its hard to talk about better approaches.
The solutions to monorepo taking 10x longer to build seem to be "Spend 10x longer on the manual developer parts doing 10x more procedure with more tools, more rules, more work"
Why build libraries and separate services if an update on some part of the codebase needs changes across all the platform?
This trend of microservices + monorepos sound to me like taking the worst part of everything.
If you do microservices, then let each team have their own stack, their own tools, their own libraries and be independent and just agree on the APIs.
If you want everything super consistent and share as much code as possible, etc then just do a traditional (well architected) monolith, maybe deploy it with different configurations for different scaling needs, etc.
Monorepos are to me a symptom of worse problems.
I worked for a.company where they had a rule that "every repository should be a monorepo". They didn't even understand everything that was wrong with that rule.
Since this is Go, it's trivial to point in-development branches of downstream projects to an in-development branch of a dependency before merging it for those projects' testing processes. (This still doesn't cover 100% of cases of course, but nothing does. The better answer is not to over-factor in the first place.)