TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Monorepo – Our Experience

250 点作者 vishnumohandas6 个月前

32 条评论

CharlieDigital6 个月前
<p><pre><code> &gt; Moving to a monorepo didn&#x27;t change much, and what minor changes it made have been positive. </code></pre> I&#x27;m not sure that this statement in the summary jives with this statement from the next section:<p><pre><code> &gt; In the previous, separate repository world, this would&#x27;ve been four separate pull requests in four separate repositories, and with comments linking them together for posterity. &gt; &gt; Now, it is a single one. Easy to review, easy to merge, easy to revert. </code></pre> IMO, this is a huge quality of life improvement and prevents a lot of mistakes from not having the right revision synced down across different repos. This alone is a HUGE improvement where a dev doesn&#x27;t accidentally end up with one repo in this branch and forgot to pull this other repo at the same branch and get weird issues due to this basic hassle.<p>When I&#x27;ve encountered this, we&#x27;ve had to use <i>another repo</i> to keep scripts that managed this. But this was also sometimes problematic because each developer&#x27;s setup had to be identical on their local file system (for the script to work) or we had to each create a config file pointing to where each repo lived.<p>This also impacts tracking down bugs and regression analysis; this is much easier to manage in a mono-repo setup because you can get everything at the same revision instead of managing synchronization of multiple repos to figure out where something broke.
评论 #42066059 未加载
评论 #42067413 未加载
评论 #42073634 未加载
评论 #42066140 未加载
评论 #42070436 未加载
评论 #42070122 未加载
评论 #42069618 未加载
评论 #42064679 未加载
评论 #42067533 未加载
评论 #42083520 未加载
评论 #42074132 未加载
评论 #42076656 未加载
评论 #42073808 未加载
评论 #42073742 未加载
__MatrixMan__6 个月前
Every monorepo I&#x27;ve ever met (n=3) has some kind of radioactive DMZ that everybody is afraid to touch because it&#x27;s not clear who owns it but it is clear from its quality that you don&#x27;t want to be the last person who touched it because then maybe somebody will think that you own it. It&#x27;s usually called &quot;core&quot; or somesuch.<p>Separate repos for each team means that when two teams own components that need to interact, they have to expose a &quot;public&quot; interface to the other team--which is the kind of disciplined engineering work that we should be striving for. The monorepo-alternative is that you solve it in the DMZ where it feels less like engineering and more like some kind of multiparty political endeavor where PR reviewers of dubious stakeholder status are using the exercise to further agendas which are unrelated to the feature except that it somehow proves them right about whatever architectural point is recently contentious.<p>Plus, it&#x27;s always harder to remove something from the DMZ than to add it, so it&#x27;s always growing and there&#x27;s this sort of gravitational attractor which, eventually starts warping time such that PR&#x27;s take longer to merge the closer they are to it.<p>Better to just do the &quot;hard&quot; work of maintaining versioned interfaces with documented compatibility (backed by tests). You can always decide to collapse your codebase into a black hole later--but once you start on that path you may never escape.
评论 #42071215 未加载
评论 #42071587 未加载
评论 #42073813 未加载
评论 #42074344 未加载
评论 #42071606 未加载
评论 #42077937 未加载
评论 #42076974 未加载
评论 #42078248 未加载
评论 #42076553 未加载
评论 #42072592 未加载
bob10296 个月前
The #1 benefit for me regarding the monorepo strategy is that when someone on the team refers to a commit hash, there is exactly one place to go and it provides a consistent point-in-time snapshot of <i>everything</i>. Ideally, all of the commits on master are ~good, so you have approximately a perfect time machine to work with.<p>I have solved more bugs looking at diffs in GitHub than I have in my debugger simply by having everything in one happy scrolly view. Being able to flick my mouse wheel a few clicks and confirm that the schema does indeed align with the new DTO model props has saved me countless hours. Confirming stuff like this across multiple repos &amp; commits can encourage a more lackadaisical approach. This also dramatically simplifies things like ORM migrations, especially if you require that all branches rebase &amp; pass tests before merging.<p>I agree with most of the hypothetical caveats, but if you can overcome them even with some mild degree of suffering, I don&#x27;t see why you wouldn&#x27;t fight for it.
评论 #42072967 未加载
评论 #42076162 未加载
xyzzy_plugh6 个月前
Without indicating my personal feelings on monorepo vs polyrepo, or expressing any thoughts about the experience shared here, I would like to point out that open-source projects have different and sometimes conflicting needs compared to proprietary closed-source projects. The best solution for one is sometimes the extreme opposite for the other.<p>In particular many build pipelines involving private sources or artifacts become drastically more complicated than their those of publicly available counterparts.
评论 #42069098 未加载
评论 #42071212 未加载
gorgoiler6 个月前
Repository boundaries are affected far more by the social structure of your organisation than anything technical.<p>Do you want hard boundaries between teams — clear responsibilities with formal ceremony across boundaries, but at the expense of living with inflexibility?<p>Do you want fluidity in engineering, without fixed silos and a flat org structure that encourages anyone to take on anything that’s important to the business right now, but with the much bigger overhead of needing strong people leaders capable of herding the chaos?<p>I’m sure there are dozens of other examples of org structures and how they are reflected in code layout, repo layout, shared directories, dropboxes, chat channels, and email groups etc.
msoad6 个月前
I love monorepos but I&#x27;m not sure if Git is the right tool beyond certain scale. Where I work doing a simple `git status` takes seconds due to the size of the repo. There has been various attempts to solve Git performance but so far this is nothing close to what I experienced at Google.<p>The Git team should really invest in tooling for very large repos. Our repo is around 10M files and 100M lines of code and no amount of hacks on top of Git (cache, sparse checkout etc etc) is not really solving the core problem.<p>Meta and Google have really solved this problem internally but there is no real open source solution that works for everyone out there.
评论 #42071713 未加载
评论 #42069761 未加载
评论 #42077159 未加载
评论 #42072284 未加载
alphazard6 个月前
The classic micro&#x2F;multi repo mistake is reaching for more repos when you really need better tooling and permissions on single repo. People have probably wasted millions of engineer-hours across the industry with multiple repos, all because GitHub doesn&#x27;t have expressive path-level permissions.
评论 #42077118 未加载
mgaunard6 个月前
Doing modular right is harder than doing monolithic right.<p>But if you do it right, the advantage you get is that you get to pick which versions of your dependencies you use; while quite often you just want to use the latest, being able to pin is also very useful.
评论 #42072294 未加载
评论 #42067217 未加载
stackskipton6 个月前
As DevOps&#x2F;SRE type person that occasionally gets stuck with builds, Monorepos world well if company will invest in the build process. However, many companies don&#x27;t do well in this area and Monorepo blast radius becomes much bigger so individual repos it is. Also, depending on the language, building private repo is easy enough to keep all common libraries in.
photonthug6 个月前
Monorepos: if you don’t have it, everyone wants it, and if you do have it, no one likes it. There are solid, good faith arguments for each way. There are very real benefits to switching in some circumstances, but those reasons are themselves fragile and subject to frequent change based on cultural or operational shake ups.<p>So in the end this is a yaml vs json type of argument mostly, and if you’re thinking about rioting over this there is a very good chance you could find a better hill to die on.
评论 #42075002 未加载
siva76 个月前
Ok, but the more interesting part - how did you solve the CI&#x2F;CD part and how does it compare to a multirepo?
评论 #42064903 未加载
评论 #42064722 未加载
评论 #42065313 未加载
评论 #42073167 未加载
评论 #42076227 未加载
gregmac6 个月前
To me, monorepo vs multi-repo is not about the code organization, but about the deployment strategy. My rule is that there should be a 1:1 relation between a repository and a release&#x2F;deployment.<p>If you do one big monolithic deploy, one big monorepo is ideal. (Also, to be clear, this is separate from microservice vs monolithic app: your monolithic deploy can be made up of as many different applications&#x2F;services&#x2F;lambdas&#x2F;databases as makes sense). You don&#x27;t have to worry about cross-compatibility between parts of your code, because there&#x27;s never a state where you can deploy something incompatible, because it all deploys at once. A single PR makes all the changes in one shot.<p>The other rule I have is that if you want to have individual repos with individual deployments, they must be both forward- and backwards-compatible for long enough that you never need to do a coordinated deploy (deploying two at once, where everything is broken in between). If you have to do coordinated deploys, you really have a monolith that&#x27;s just masquerading as something more sophisticated, and you&#x27;ve given up the biggest benefits of <i>both</i> models (simplicity of mono, independence of multi).<p>Consider what happens with a monorepo with parts of it being deployed individually. You can&#x27;t checkout any specific commit and mirror what&#x27;s in production. You could make multiple copies of the repo, checkout a different commit on each one, then try to keep in mind which part of which commit is where -- but this is utterly confusing. If you have 5 deployments, you now have 4 copies of any given line of code on your system that are potentially wrong. It becomes very hard to not accidentally break compatibility.<p>TL;DR: Figure out your deployment strategy, then make your repository structure mirror that.
评论 #42065717 未加载
评论 #42065692 未加载
评论 #42073352 未加载
default-kramer6 个月前
&gt; Refactoring across repository boundaries requires much more activation energy as compared to spotting and performing gradual refactorings across folder boundaries. Technically it is the same, but the psychological barriers are different.<p>I love the &quot;activation energy&quot; metaphor here. But I don&#x27;t agree that &quot;technically it is the same.&quot; At my current job, we have more than 100 minirepos and I am unable to confidently refactor the system like I normally would in a monorepo. It&#x27;s not merely the psychological barrier. It&#x27;s that I am unable to find all the call sites of any &quot;published&quot; function. Minirepos create too many &quot;published&quot; functions in the form of Nuget packages. Microservices create too many &quot;published&quot; functions in the form of API endpoints. In either case, &quot;Find All References&quot; no longer works; you have to grep, but most names are not unique enough.<p>For this reason, the kind of refactoring that keeps a codebase healthy happens at a much lower rate than all the other projects I&#x27;ve worked on.
vekker6 个月前
I like monorepos as a developer, but as a founder, monorepos have one massive downside: if you want to hire outside help, you have to share <i>everything</i>.<p>While in some cases, the complete context is helpful for the job, in other cases, and I realize this may be pure paranoia but, you may not want to share the complete picture.
评论 #42076222 未加载
LunicLynx6 个月前
There is only one concept of a monorepo. And that is the google approach. This is a project repo and in a project repo things should stay together.<p>Your tooling must be different for it to work.<p>So using git for it will not have a positive result.
akoboldfrying6 个月前
This prompted a shower thought: Isn&#x27;t N separate repos actually strictly worse than a monorepo with N <i>completely independent</i> long-lived branches, where each person checks out all the ones they need to work on under separate folders with `git worktree add`?<p>I can think of only 2 ways that the multiple-branch monorepo is worse:<p>1. If the monorepo is large, everyone has to deal with a fat .git folder even if they have only checked out a branch with a few files.<p>2. Today, everyone expects different branches in a repo to contain &quot;different versions of the same thing&quot;, not &quot;a bunch of different things&quot;. But this is purely convention.<p>The only real benefit that I can see of making a separate repo (over adding a new project directory to a &quot;classic&quot; monorepo) is the lower barrier to <i>getting underway</i> -- you can just immediately start doing whatever you want; the pain of syncing repos comes later. But this is also true when starting work under a new branch in the branch-per-project style monorepo: you can just create a branch from the initial commit, and away you go -- and if you need to atomically make changes across projects, just merge their branches first!<p>What are the downsides I&#x27;m not seeing?
评论 #42074540 未加载
syndicatedjelly6 个月前
Some thoughts:<p>1) Comparing a photo storage app to the Linux kernel doesn&#x27;t make much sense. Just because a much bigger project in an entirely different (and more complex) domain uses monorepos, doesn&#x27;t mean you should too.<p>2) What the hell is a monorepo? I feel dumb for asking the question, and I feel like I missed the boat on understanding it, because no one defines it anymore. Yet I feel like every mention of monorepo is highly dependent on the context the word is used in. Does it just mean a single version-controlled repository of code?<p>3) Can these issues with sync&#x27;ing repos be solved with better use of `git submodule`? It seems to be designed exactly for this purpose. The author says &quot;submodules are irritating&quot; a couple times, but doesn&#x27;t explain what exactly is wrong with them. They seem like a great solution to me, but I also only recently started using them in a side project
评论 #42073151 未加载
评论 #42066078 未加载
评论 #42066192 未加载
评论 #42079601 未加载
paxys6 个月前
All the pitfalls of a monorepo can disappear with some good tooling and regular maintenance, so much so that devs may not even realize that they are using one. The actual meat of the discussion is – should you deploy the entire monorepo as one unit or as multiple (micro)services?
评论 #42071149 未加载
drbojingle6 个月前
a lot of comments here seem to think that mono-repo has to mean something about deployment. I just don&#x27;t want to have to run git fetch and 5 different repos to get everything I need and that&#x27;s good enough reason for me to use one.
评论 #42072683 未加载
评论 #42080407 未加载
h1fra6 个月前
I think the big issue around monorepo is when a company puts completely different projects together inside a single repo.<p>In this article almost everything makes sense to me (because that&#x27;s what I have been doing most of my career) but they put their OTP app inside which suddenly makes no sense. And you can see the problem in the CI they have dedicated files just for this App and probably very few common code with the rest.<p>IMO you should have one monorepo per project (api, frontend, backend, mobile, etc. as long as it&#x27;s the same project) and if needed a dedicated repo for a shared library.
评论 #42065000 未加载
评论 #42072735 未加载
DrBazza6 个月前
It&#x27;s kind of funny that the wisdom in software development is to program against interfaces and not implementations.<p>And yet here we are with monorepos, doing the big-ball of mud approach.<p>I&#x27;ve worked on several multi-repo systems and several monorepos. I have a weak preference for monorepos for some of the reasons given, especially the spread of pull requests, but that&#x27;s almost a &#x27;code smell&#x27; in some respects.<p>Monorepos that I&#x27;ve contributed to that have worked well: mostly one language (but not always), a single top-most build command that builds <i>everything</i>, complete coverage by tests in all dimensions, and the repo has tooling around it (ensure code coverage on check in, and so on).<p>Monorepos that I&#x27;ve contributed to that haven&#x27;t: opposites of the previous points.<p>Multi-repos that have worked well: well abstracted and isolated, some sort of artefact repository (nexus, jfrog, whatever) as the layer between repos, clear separation of concerns.<p>Multi-repos that have not worked well: again, opposites of the previous, including git submodules (please, just don&#x27;t), code duplication, fragile dependencies where changing any repo meant all had to change.
magicalhippo6 个月前
We&#x27;re transitioning from a SVN monorepo to Git. We&#x27;ve considered doing a kind of best-of-both-worlds approach.<p>Some core stuff into separate libraries, consumed as nuget packages by other projects. Those libraries and other standalone projects in separate repos.<p>Then a &quot;monorepo&quot; for our main product, where individual projects for integrations etc will reference non-nuget libraries directly.<p>That is, tightly coupled code goes into the monorepo, the rest in separate repos.<p>Haven&#x27;t taken the plunge just yet tho, so not sure how well it&#x27;ll actually work out.
评论 #42067711 未加载
评论 #42074527 未加载
KaiserPro6 个月前
Monorepos have their advantages, as pointed out, one place to review, one place to merge.<p>But it can also breed instability, as you can upgrade other people&#x27;s stuff without them being aware.<p>There are ways around this, which involve having a local module store, and building with named versions. Very similar to a bunch of disparate repos, but without getting lost in github (github&#x27;s discoverability was always far inferior to gitlab)<p>However it has its draw backs namely that people can hold out on older versions than you want to support.
评论 #42069723 未加载
mcnichol6 个月前
Monolith vs Microservice argument all over again.<p>Tradeoffs for mono are drivers of micro and vice versa.<p>Looking at the GitHub insights it becomes pretty clear there are about two key devs that commit or merge in PRs to main. I&#x27;m guessing this is also whom the code reviews happen etc. Comparing itself to Linux where the number of recurring contributors are more by orders of magnitude just reeks of inexperience. I&#x27;m being tough with my words because at face value, the monorepo argument works but it ends in code-spaghetti and heartache when things like developer succession, corporate strategy, market conditions throw wrenches in the gears.<p>Not for nothing I think a monorepo is perfectly fine when you can hold the dependency graph (that you have influence over) in your head.<p>Maybe there&#x27;s a bit of &#x2F;rant in this because I&#x27;m tired of hearing the same problem with solutions that are spun as novel ideas when it&#x27;s really just: &quot;Pre-optimization is the root of all evil.&quot;<p>You don&#x27;t need to justify using a monorepo if you are small or close to single threaded in sending stuff into main. It&#x27;s like a dev telling me: &quot;I didn&#x27;t add any tests to this and let me explain why...&quot;<p>The explanation is the admission in my mind but maybe I&#x27;m reading into it too much.<p>Article is nicely written and an enjoyable read but the arguments don&#x27;t have enough strength to justify. You are using a monorepo, that&#x27;s okay. Until it&#x27;s not, that&#x27;s okay too.
stillbourne6 个月前
I like to use the monorepo tools without the monorepo repo. If that makes any god damn sense. I use NX at my job and the monorepo was getting out of hand, 6 hour pipeline builds, 2 hours testing, etc. So I broke the repo into smaller pieces. This wouldn&#x27;t have been possible if I wasn&#x27;t already using the monorepo tools universally through the project but it ended up working well.
ofrzeta6 个月前
I am not convinced Git submodules are so bad. Obviously it&#x27;s a bit more work than a monorepo but it actually works quite nice to have the parent repo pin the commits of the submodules. So you can just update, say, the &quot;frontend&quot; when fixing a bug, update the submodule and commit the hash to the parent. lgtm.
yen2236 个月前
&gt; Moving to a monorepo didn&#x27;t change much, and what minor changes it made have been positive.<p>It&#x27;s pretty refreshing to see an experience report whose conclusion is &quot;not much has changed&quot;, even though in practice that&#x27;s the most common result for any kind of process change.
memsom6 个月前
monorepos are appropriate for a single project with many sub parts but one or two artifacts on any given release build. But they fall apart when you have multiple products in the monorepo, each with different release schedules.<p>As soon as you add a second separate product that uses a different subset of any code in the repo, you should consider breaking up the monorepo. If the code is &quot;a bunch of libraries&quot; and &quot;one or more end user products&quot; it becomes even more imperative to consider breaking down stuff..<p>Having worked on monorepos where there are 30+ artifacts, multiple ongoing projects that each pull the monorepo in to different incompatible versions, and all of which have their own lifetime and their own release cycle - monorepo is the antithesis of a good idea.
评论 #42067350 未加载
评论 #42065786 未加载
dboreham6 个月前
The meta-syndrome here is: one person fixing a problem they have, and thereby making problems other people have worse. Often first person doesn&#x27;t have a good awareness of the full melange of problems and participants.
bobim6 个月前
Started to use a monorepo + worktrees to keep related but separated developments all together with different checkouts. Anybody else on the same path?
indulona6 个月前
monorepo is the way to go if the code portrays to the entire application as a whole. otherwise, if there are applications that are not connected in any way, it makes absolutely no sense to pull them together. it&#x27;s really not a rocket science. some people just prefer to ice skate uphill, i guess, and have to make simple things complicated.
oslem6 个月前
Alright everyone, we’ve trained for this. Grab your popcorn and get a good seat. It’s the return of the of great mono&#x2F;poly repo debate.