r/devops • • Jun 23 '23

Bazel is absolute pain NSFW

So a couple of months ago i started my new job and one of my first projects was helping setting up monorepo and migrate to bazel from maven. I am coming from maven and gradle background. Since i started using and learning about bazel it has been nothing but absolute confusion and pain. It's so fucking complicated that sometimes you are like whatever i am gonna gain from it, does it really worth it? support clearly is not there. random issues here and there, intellij plugin is super broken. testing frameworks are not supported properly. Behaviors on different operating systems differ critically. What has been your experience with bazel?

105 Upvotes

58 comments sorted by

44

u/[deleted] Jun 23 '23

Bazel was designed for solving a problem you probably don't have: hermetic builds for a 10,000+ developer monorepo.

If you don't have those two requirements I would drop it like a hot rock.

6

u/ThrawnGrows Jun 24 '23

I fucking love that they try to say it's for startups!

10

u/Imanarirolls Jun 24 '23

We’ve got a few hundred devs and a pretty intense monorepo. Feels pretty worth it.

2

u/[deleted] Jun 24 '23

question: did you retrofit or did you start with Bazel from the get go?

my experience was a "boil the ocean" problem. bazel (at the time) didn't play well with other build systems.

1

u/sosou1366 Jun 24 '23

Yeah honestly now I can certainly say we should have even started using bazel.

-15

u/wrexinite Jun 24 '23

I've been a build engineer at a Fortune 100 for 15 years and I've never even heard of it.

23

u/booi Jun 24 '23

A build engineer that hasn’t heard of Bazel?

1

u/Ezio_rev Feb 14 '24

he loves makefiles

11

u/Fiskepudding Jun 23 '23

How big is your org working on this monorepo? This could be a cargo cult scenario.

6

u/sosou1366 Jun 23 '23

Actually it was a hasty decision by management and we never needed bazel. Our org isn't even that big

3

u/baezizbae Distinguished yaml engineer Jun 24 '23

pours one out

9

u/bravinator34 Jun 23 '23

Ugh yes used it a ton at a very small company to build a monorepo for all new projects. It was a huge pain and I seriously considered quitting because I spent so much time learning stuff I didn’t care about and moving so slow to do what could be done with just terraform much quicker. Eventually people smarter than me built some wonderful tooling to make it easier to work with but man our team starting from scratch building a very complex system with it was terrible. I’m still not convinced it was worth it but others on the team were.

5

u/sosou1366 Jun 23 '23

Exactly, as a developer I am just asking myself why the fuck I am even learning how bazel works. Actually for my next job I will check if they use bazel or are going to use it and if the answer is yes I will give it a pass. Super complex and unintuitive.

1

u/bravinator34 Jun 23 '23

Yeah it seems to me if a company uses it then they’re likely all in on it. If you don’t like using a build system like that then avoid the job at all costs. I hate switching jobs so it wasn’t enough to make me leave but man it’s sucks. I took solace in the fact that we were building a pretty complex system unlike I’ve ever built. So while the build system sucked, I learned a whole new system design unrelated to my web dev infra background.

7

u/FatStoic Jun 24 '23

It's absolute pain for sure.

But if you have the time to build the workflows you like, it can make your developer experience fantastic.

Context: a small company of 50 devs, Kubernetes first.

Use existing automations to build Go and Python, write custom automations to build and push docker containers and template helm files for K8s deployment.

Result:

  • 90% of the time, developers were able to deploy new services without any help, just by copying and pasting bazel configuration and modifying a few key vars. Pipeline builds and pushes their docker images, deploys helm charts to K8s - changes pushed to your branch are in the development K8s cluster in under 5 minutes. The help that was needed was almost always related to needing advanced K8s features.

  • Monorepo allowed sweeping changes across codebase to be tested and deployed trvially. Need to make changes how ALL services consume a single library? That's a single PR.

An absolute pain to set up, an absolute joy to use once it was working.

1

u/sosou1366 Jun 24 '23

Still I think the important question the team should ask themselves is, is it worth it? As I said the learning curve is steep and migration can be painful, if you think you are gonna scale up so much that migrating to bazel will pay back, then go for it, otherwise it's a complete waste of time, money and talent.

1

u/FatStoic Jun 25 '23

Yeah like all things there's a trade off to be considered.

For us it worked well, because everyone was consuming compute in the exact same way, which gave us the time to build good integrations around it.

If you've got lots of people needing very different builds and deployments... might be more of a pain.

5

u/zpallin Jun 24 '23 edited Jun 24 '23

My company uses Bazel and we’re moving off of it. Company was founded by Googlers who were myopic and didn’t see the value in picking more ubiquitous build patterns. When they all eventually departed, the rest of our development team who had no prior experience with Bazel were left with an indeterminable mess to clean up. To say the least, what teams have already been able to move out of the Bazel monorepo very much enjoy the fresh air.

My take on Bazel is that it was built by a bunch of very smart people who never really cared if less smart people ever had to manage a build system. They assumed people as intelligent as them would immediately ascertain the nuances of their design choices, and perhaps did not even consider what other people in their field had done before them. No, they wanted something that felt new, different, and Google-ey. Their singular goal was to make Google’s monorepo very effective at builds without ever asking the question, “is this dependency necessary?” No, every dependency was necessary so long as it existed. They just needed to find a very smart way to skip rebuilding it.

Still, I think if you’re determined to have a monorepo, doesn’t make much sense to pick anything else than Bazel. Just really wish it was more intuitive to understand. It is good at what it does if you can figure out how to do it… but there are just too many potential hazards to count. FFS I don’t know why anyone would choose a monorepo at this day and age.

3

u/sosou1366 Jun 26 '23

I also cannot understand the necessity of putting all your code base in monorepo and then needing a broken-ass complicated tool like bazel to manage dependencies and build process. At least in my team what I am seeing is these types of decisions are made with little to zero considerations of their long-term consequences. Complete waste of time, talent and money. Honestly as a developer i want to work on what i love to work which is writing code and solving business problems but as far as i get paid I don't give a single fuck if management desperately wants to burn some cash on useless projects such as migration to bazel.

2

u/Dufferston Oct 07 '23 edited Oct 07 '23

My take on Bazel is that it was built by a bunch of very smart people who never really cared if less smart people ever had to manage a build system.

That's not true. Bazel is obviously just a bundle of features that were piled on top of each other to solve narrow bespoke problems. It's a schizophrenic mess. Good developers create software that solves problems from a set of logical primitives. That's what programming is.

Bazel is like: Oh you want to solve that problem, pass this switch. It's better to think of it as an execution engine with its own bespoke language, and a bazillion workarounds accrued through solving real world problems.

The idea of Bazel is sound. It makes a great sales pitch. It needs to be nuked from orbit, and rewritten from scratch by a talented engineer with an eye for language design.

1

u/zpallin Oct 07 '23

Good points, but I don’t think what we are saying is mutually exclusive except that there may be a disagreement in terms of what smart people are apt to “do.” IMO I think it’s very easy for people to build systems in very smart ways that end up with really messy results.

3

u/chandrash3khar Jun 23 '23

I am also trying to bring bazel to a monorepo containing JavaScript, Golang and Java code and it has been a pain. I have used gazelle to auto generate build files to get me a starting point but stuck making the third party dependencies to work with the ecosystem.

4

u/sosou1366 Jun 23 '23

Making external dependencies work with bazel is such a pain in the ass

2

u/sosou1366 Jun 23 '23

Literally took me a day to find out this fucker is not compatible with junit 5 natively, took me another day to make it compatible with it since app were not going to user junit 4. Like I never worried about these things with Maven and Gradle. I mean this is just one example, there are issues left and right with bazel and you get to a point you are like what I am going to get from this much hassle and time wasting.

2

u/Fsmv Jun 24 '23 edited Feb 27 '24

You have to should vendor the dependencies. Import them into a folder in your repo and replace their build system with bazel.

This has the benefit of pinning the versions so things don't break. You can run all the tests that depend on it when you update it.

1

u/dzintars_dev Jun 24 '23

^ Very much this ^This is also how Google work internally AFAIC. They don't trust external deps (and you should not). They pull everything in-house with tool like Copybara, wrap that thing with Bazel and use it as internal dependency so that they can build it, patch it and cache it every time there is any upstream change.

1

u/Dufferston Oct 07 '23

Nothing that a few lines of bash cannot do. Literally.

69

u/jews4beer Jun 23 '23

Bazel, as with a lot of things Google, really only begins to offer payback at enormous scale from things like the distributed caching. Beyond that it is just a giant ass hammer for a tiny ass nail most of the time. And when you run into something it doesn't support natively - figuring out how to add the support is a mindfuck.

37

u/subjectivemusic Jun 23 '23

giant ass hammer

If you don't use hyphens someone is going to get the wrong idea

17

u/jews4beer Jun 23 '23

Hey - I don't judge

15

u/donjulioanejo Chaos Monkey (Director SRE) Jun 23 '23

Where do I get this giant ass-hammer?

0

u/[deleted] Jun 24 '23

[deleted]

2

u/majorpotatoes Jun 24 '23

This was my first read-through

6

u/cptjpk Jun 24 '23

It’s an XKCD classic!

2

u/TomahawkChopped Jun 24 '23

Giant ass-hammer. FTFY?

11

u/Romeo3t Jun 23 '23

Agree. I feel like many engineers understand that and don't value simplicity enough. I've had, what I would call, fairly small companies who barely have a platform team that think they'll be able to make Bazel work and support it. It boggles my mind.

There is already so much complexity in software, why would you not just use a Makefile and get away with that for as long as is reasonable.

2

u/Dufferston Oct 07 '23

Make is a superior technology. Most people don't know how to use it properly, which is too bad, because the manual isn't that long. I'm somewhat an expert in Bazel and and make.

2

u/meyerhot Jun 24 '23

Not really, for languages it supports heavily like Golang it can offer huge speed ups for local development over standard build tool and docker

20

u/lakkthereof Jun 23 '23

Bazel is the Vulkan of Build Tools. Fine grain control. Infinite possibilities for optimizations. Extremely complex. Lots of boilerplate. You better know what you're doing or you're gonna have a bad time. So to answer your question: Is it worth it? If you are even asking that question, the answer is most likely no.

7

u/Jerhaad Jun 24 '23

Bazel is amazing! Migrating to bazel is absolute pain.

3

u/Siggi3D Jun 24 '23

Basel blows, unless you have:

  1. A dedicated team to run it

  2. Devs fully integrating into it

  3. At least 1 team member in each team that is bagel tech support and knows how the magic works behind the scenes.

  4. The requirements for it: huge team using a monorepo

We switched from Bazel to GitHub actions and helm deployments ..what a relief it was

1

u/meltbox Aug 19 '24

Sorry for bringing this back, but I really had to say I would enjoy someone on the team being bagel tech support. It would make me tolerate bazel better if they came as a package.

3

u/cfife_dawg Jul 25 '23 edited Jul 25 '23

In my current job, I got hired on as a frontend/fullstack-ish engineer on a pretty green project. My manager was also coming from a fairly large company (not FAANG, but definitely a high-caliber larger-scale org) where Bazel was used company-wide. It seems that one of the most common cases for companies choosng Bazel is just some engineer who left a FAANG/HFT to join a startup and basically is using tech they already know and like. That doesn't mean Bazel is bad, but I agree it's a terrible fit for startups as others have said.

When I joined, I quickly got assigned with setting up our frontend build tools (i.e. Angular, Webpack, etc.) to build through Bazel. Honestly speaking, that was really really tough. As others have said, adding support for things not supported natively (i.e. most node build tools) was just a fucking mess. Very little documentation, and a lot of just pure trial and error. I think over time, I've gotten a deeper understanding of how different parts of Bazel work, and a lot of things that would've originally taken me months might now only take a day or two. Now that most of the Bazel tooling side of our project has stopped, I'd be lying if I didn't say I actually thought having Bazel is great. If nothing else, it's useful to be able to cache every step of our builds.

However, if I were starting over, I wouldn't choose Bazel again. It took many many months to set up some pipelines that probably could've been set up in a few weeks just using shell scripts, or docker-compose or just something else. The concept of "hermeticity" is nice, but I sorta feel like for a smaller org, just using docker is probably good enough. Finally, even though Bazel is pretty performant in the long-run, me and my manager are probably the only people in the company who really understand it well, and I'm pretty sure that if we ever left, the next person would just scratch their head until they finally said "yeah, we're not doing this" and moved our entire project to something else.

Tl;Dr: I think a lot of ex-google or ex FAANG people join a startup, choose parts of their old stack like Bazel, even though it's really probably not that great of a fit. That being said, once the infrastructure exists, even for a small group, it's great. But for the amount of time and effort it takes and how much expertise it requires, I wouldn't use it for a new project - even though I do actually like it.

1

u/Psychological_March2 Nov 29 '23

Hey, so if you've made the investment to use Bazel, we just released something that will make merges better. Most merge queues that don’t use dependency graphs. We've added parallel mode so that code changes that don't affect each other can merge together. This means no more waiting in line for unrelated code changes to merge. Check out our docs: https://docs.trunk.io/merge

1

u/Psychological_March2 Nov 29 '23

Agreed. Once someone gets used to Bazel, they start using it at their next gig.
However, there is one benefit. We started changing our merge queues to take advantage of the dependency graph that Bazel generates. It lets us merge PRs in parallel, and push some PRs to the front of the line when we have a break-fix situation. It's also made some engineers delightfully happy when their small fix to the website got pushed through quickly.
We just released a self-onboarding version and would love feedback from the community. Give it a try and let us know what you think.

4

u/Yasuraka Jun 23 '23

Anyone looked into https://bob.build/ ?

Relies on nix over containers and promises to be a simpler alternative to Bazel

0

u/[deleted] Jun 24 '23

[deleted]

1

u/Yasuraka Jun 24 '23

Looks like an open source tool with some managed SaaS version being in the works

2

u/neopointer Jun 24 '23

Almost no one need monorepo nor Bazel. Stop it while there's still time.

1

u/coloradofever29 Jun 24 '23

I'm currently using Gradle for a monorepo with ~200 modules.

We're starting to hit our limits. I just found out about https://github.com/dropbox/focus though... It's a possibility, but I don't love it.

1

u/livebeta Jun 24 '23

I'm also on /r/tenseislime and thought you meant King Gazel of the Draven Nation

0

u/[deleted] Jun 23 '23

[deleted]

12

u/Yeroc Jun 23 '23

Can't speak to your situation but for our situation having all the libraries and modules in a single monorepo has made refactoring a lot easier. Another bonus for us is we no longer need to version our library versions. They're simply tagged along with the main artifact in the mono repo. That said, I'm sure there are situations where it's more of a pain but for our situation it definitely saves us a lot of time.

2

u/NormalUserThirty Jun 24 '23

Ugh we have multi-repo and I miss this so much

2

u/sosou1366 Jun 23 '23

Literally not worth it if you are asking that question. it gives you nice features such as caching artifacts which can result in faster build but what's the cost, you could spend that time on improving your code.

3

u/hacksnake Jun 23 '23

You can turn a number of runtime issues into build time failures if the systems need to communicate.

If the systems are completely disjoint it's not going to add a ton probably.