跳到主内容
@wquguru
精选88PostHog 博客(RSS)产品与增长

自建还是购买 Feature Flags:5个非直观决策维度

To build or buy feature flags: Non-obvious things to know

原文
发到 X
推荐理由

给技术负责人和产品经理提供了具体的评估清单,特别是关于集成复杂度和 AI Agent 适配的洞察,能直接用于内部工具选型决策。

AI agents are causing teams to consider whether they should build their own version of tools they pay for.

AI 智能体正促使团队思考:是否应该自行构建他们付费使用的工具版本。

Feature flags have long been a prime target for this "build or buy" question, even before AI got good. This is because, at their most basic, flags are a function. You call them with a key and they return a value. How hard could this be?

功能标志(Feature flags)长期以来一直是这一“自研还是购买”问题的主要目标,甚至在 AI 变得成熟之前就是如此。这是因为,在最基本的层面上,标志是一种函数。你通过键调用它们,它们返回一个值。这能有多难呢?

The complication comes from everything that must happen to return that value reliably, accurately, and fast. Teams deciding on building versus buying quickly run into a bunch of obvious things to consider:

复杂性在于为了可靠、准确且快速地返回该值所必须处理的所有事情。在决定自研还是购买时,团队很快会遇到一堆显而易需考虑的因素:

  • It costs time and money to create, host, and maintain.
  • Lots of feature flag software already exists, is free, and can fit into your compliance requirements if needed.
  • Having fewer flags, users, SDKs, and use cases makes it easier to manage.
  • Making flags usable requires more than just the core functionality; you need features like admin UIs too.
  • 创建、托管和维护需要花费时间和金钱。
  • 市场上已经存在许多功能标志软件,它们是免费的,并且在必要时可以满足你的合规要求。
  • 拥有更少的标志、用户、SDK 和使用场景会使管理变得更加容易。
  • 让标志可用不仅仅需要核心功能;你还需要管理员界面等功能。

As a company that offers feature flags and has thousands of customers who use them, we know the decision goes well beyond these points. To help you, here are some non-obvious things to consider when deciding between building or buying feature flags.

作为一家提供功能标志服务并拥有数千名用户的公司,我们知道决策远不止这些要点。为了帮助你,以下是一些在决定自研或购买功能标志时需要考虑的非显而易见因素。

The real work is in integrations

真正的工作量在于集成

A feature flag implementation starts simple: a database table with a key and a value. As soon as you want to do more, you need to integrate with other services, and this quickly becomes the bulk of the work.

功能标志的实现起初很简单:一个包含键和值的数据库表。一旦你想做更多事情,就需要与其他服务集成,而这很快就会成为工作的主体部分。

Some examples:

一些例子:

  • User identification. You need to know who a user is to target them with a flag. This might be as simple as a user ID, but it can also include properties like plan, location, device, and more.
  • Experimentation. Flags can be used to run experiments, but this requires usage analytics, exposure logging, and statistical analysis to determine the impact of different flag values.
  • Realtime cohorts. Calculating cohorts often has nothing to do with flags themselves. Membership can change in a completely different part of the codebase. Race conditions can cause members to be added or removed at the wrong time. Recomputing constantly can be expensive.
  • Data warehouses. For many companies, the source of truth is the data warehouse, but almost never is this warehouse optimized for the queries flags need to make.
  • 用户识别。你需要知道用户是谁才能向其投放标志。这可能只是一个用户 ID,但也可能包括计划、位置、设备等属性。
  • 实验测试。标志可用于运行实验,但这需要使用分析、曝光日志记录和统计分析来确定不同标志值的影响。
  • 实时群体。计算群体通常与标志本身无关。成员资格可能在代码库的完全不同部分发生变化。竞态条件可能导致成员在错误的时间被添加或移除。不断重新计算可能会非常昂贵。
  • 数据仓库。对于许多公司来说,数据仓库是单一事实来源,但几乎从未针对标志所需的查询进行优化。

Getting these wrong can not only mean flags don't work, but also cause issues for the services they integrate with. Imagine a flag service using a database table that is also used by other services. A bad query can leak sensitive data. A malformed request can lock up the table and cause issues elsewhere.

处理不当不仅会导致功能开关失效,还可能影响与其集成的服务。想象一下,一个功能开关服务使用了一个也被其他服务使用的数据库表。一个错误的查询可能会泄露敏感数据。一个格式错误的请求可能会锁住该表并引发其他问题。

Although the implementation in your codebase looks like a single function call, the data to calculate the return value can come from multiple services. The queries and calculations to get the right value can be complex too. Getting all this right requires a focus teams building flags might not have.

尽管在你的代码库中实现看起来像是一个单一函数调用,但计算返回值所需的数据可能来自多个服务。获取正确值的查询和计算过程也可能很复杂。要确保这一切都正确无误,需要团队投入大量精力,而这可能是构建功能开关的团队所不具备的。

Flags on your critical path

关键路径上的功能开关

Just like science advances one funeral at a time, feature flag reliability advances one outage at a time.

正如科学界常说的那样,科学进步是送葬一位老科学家一次前进一步;功能开关的可靠性也是随着每次故障而逐步提升的。

Flags often sit on your critical path. An issue with them can mean users get the wrong experience or no experience at all. In some cases, they've even lost companies millions.

功能开关通常位于你的关键路径上。它们的问题可能导致用户获得错误的体验,甚至完全无法体验。在某些情况下,这甚至让公司损失了数百万美元。

There are plenty of unknown unknowns when it comes to building a feature flag service. Problems and blind spots that only become apparent when the service is in production such as:

在构建功能开关服务时,存在许多未知的未知因素。一些问题只有在服务投入生产后才会显现出来,例如:

  • Hitting efficiency limits of our main Django service.
  • Niche Rust issues causing latency spikes.
  • Using way more RAM than we needed to.
  • 触及了我们主要 Django 服务的效率极限。
  • 罕见的 Rust 问题导致延迟激增。
  • 使用了远超我们需求的内存。

Every flags platform has had problems, including us. All of them have learned from the issues and improved. Our p99 is now below 25ms and we have 100% uptime in the last 90 days (between June 17th and September 14th, 2026).

每个功能开关平台都曾遇到过问题,包括我们自己。所有平台都从这些问题中吸取教训并进行了改进。目前我们的 p99 延迟已低于 25ms,并且在过去 90 天(2026年6月17日至9月14日)内实现了 100% 的正常运行时间。

This is something you are forgoing when you build your own service. You will make mistakes, and it will be your responsibility to fix them, not a vendor's.

这是你在自建服务时所放弃的东西。你会犯错,并且修复这些错误是你的责任,而不是供应商的责任。

The architecture needs to be future-proofed

架构需要具备面向未来的能力

Flags start simple. A toggle in a database can switch features on and off, but more features will inevitably be added. You won't be the only person using it, and these other personas will have different needs.

功能开关起初很简单。数据库中的一个开关可以开启或关闭功能,但随着功能的不断增加,情况会发生变化。你不可能是一个人使用它,其他使用者会有不同的需求。

A structure that works early might be wrong later. For example, adding basic user targeting to your database toggles requires writing an entire new service as evaluation isn't read-only anymore. Add percentage targeting and you need deterministic bucketing, which you might only realize after a user complains a feature disappears.

早期有效的结构后期可能不再适用。例如,向数据库开关添加基本的用户定向功能,意味着评估过程不再是只读的,因此需要编写一个全新的服务。如果还要添加百分比定向功能,你就需要确定性的分桶机制,而这可能直到有用户抱怨某个功能消失时才被发现。

Are you ready to handle many languages? Even ones you're less familiar with? Airbnb built a Kubernetes sidecar specifically to avoid reimplementing config in multiple languages. Restructures to handle new features often require rewrites and risky migrations.

你准备好处理多种语言了吗?甚至是那些你不那么熟悉的语言?Airbnb 专门构建了一个 Kubernetes sidecar,以避免用多种语言重新实现配置。为了支持新功能而进行的结构调整通常需要重写代码和进行高风险的数据迁移。

Even big companies struggle with the future-proofing and maintainability aspect of flags. Dropbox built their own feature flag service called Stormcrow in 2017. It had Hive-based populations wired to their analytics warehouse, a selector inferring graph, JSON config delivery, batched delivery for mobile/desktop clients, real-time monitoring, a static analyzer for tracking flags in code, audit history, and overrides. Still, in 2026, they moved to a flags platform.

即使是大型公司,在标志的未来适应性和可维护性方面也会遇到困难。Dropbox 于 2017 年构建了名为 Stormcrow 的自有功能标志服务。它将与 Hive 基础的用户群体连接到分析数据仓库、基于推断图的选择器、JSON 配置交付、针对移动/桌面客户端的分批交付、实时监控、用于跟踪代码中标志的静态分析器、审计历史记录以及覆盖机制。尽管如此,他们在 2026 年还是转向了标志平台。

Agent ergonomics

智能体的人机工程学

Agents are becoming the primary users of feature flags. ~60% of PostHog flags are created outside the UI. 33% by the MCP specifically.

智能体正逐渐成为功能标志的主要使用者。约 60% 的 PostHog 标志是在 UI 之外创建的,其中 33% 是由 MCP 专门创建的。

Developers on your team will want to use agents to create and edit them. This is an important surface to maintain and it means you need:

你团队中的开发人员将希望使用智能体来创建和编辑这些标志。这是一个需要维护的重要交互面,这意味着你需要:

  • MCP with tools
  • CLI
  • Agent access controls
  • Audit log
  • Debugging tools
  • 带有工具集的 MCP
  • CLI(命令行界面)
  • 智能体访问控制
  • 审计日志
  • 调试工具

This is another surface where issues arise. We've had cases where agents mess with flags they weren't supposed to, causing the customer to reevaluate read vs write access for agents. They could only figure out what happened because of the audit log.

这是另一个容易出现问题的交互面。我们曾遇到过智能体篡改其无权操作的标志的情况,导致客户重新评估对智能体的读取与写入访问权限。他们之所以能查明发生了什么,全靠审计日志。

Also, just having tools available to agents does not mean they are right. Our MCP flag tool error rate was at ~5% last month because of malformed calls and hallucinated IDs. Thanks to MCP Analytics, we were able to fix this and bring these down, but a team without MCP performance visibility would waste time and tokens every time it happened.

此外,仅仅为智能体提供可用工具并不意味着它们的使用就是正确的。上个月由于调用格式错误和幻觉生成的 ID,我们的 MCP 标志工具错误率约为 5%。得益于 MCP 分析功能,我们能够修复此问题并降低错误率,但对于缺乏 MCP 性能可见性的团队来说,每次发生此类问题时都会浪费时间和 Token。

Adoption, developer experience, and docs

采用率、开发者体验和文档

At big companies, adoption can be a legitimate problem. Companies like Dropbox and monday.com have written about their internal dev tools fragmentation and how it leads to many tools of varying quality doing the same things.

在大型公司中,采用率可能成为一个真正的问题。像 Dropbox 和 monday.com 这样的公司曾撰文描述其内部开发工具的碎片化情况,以及如何导致许多质量参差不齐的工具执行相同的任务。

We didn't have one tool, but several: some for the monolith, others for microservices, with no clear guidelines on which to use, when, or why. There was no happy path, just a fragmented set of solutions and a lot of undocumented knowledge. - Yoni Alaluf, Tech Lead at monday.com

我们没有单一的工具,而是有多个:一些用于单体应用,另一些用于微服务,且没有明确的指南说明何时、为何或使用哪一个。没有顺畅的路径,只有一组碎片化的解决方案和大量未记录的隐性知识。——Yoni Alaluf,monday.com 技术主管

Like any other tool, developers will need to be convinced to use yours. What's stopping them from building their own feature flag tool for their simple use case?

像任何其他工具一样,你需要说服开发人员使用你的工具。是什么阻止了他们为自己的简单用例构建自己的功能标志工具?

A key part of doing this is documentation and developer experience. A company like PostHog can afford to invest here because we have many people using Feature Flags. Our teams are constantly making updates to our docs, agent tools, and best practices to help users. This might not happen for a self-built tool.

做到这一点的关键部分是文档和开发者体验。像 PostHog 这样的公司可以在此处投入资源,因为有许多人使用 Feature Flags。我们的团队不断更新文档、智能体工具和最佳实践以帮助用户。而对于自建的工具,这种情况可能不会发生。

When are you better off building?

什么时候更适合自行构建?

Although we made a lot of points about why buying is better, building can still make sense in some cases. Here are a few examples:

尽管我们列举了大量关于“购买优于自建”的理由,但在某些情况下,自建仍然具有合理性。以下是一些示例:

  • When it's a company differentiator. You sell feature flags, experiments, or related products as a service.
  • You have an in-house team to maintain it. Even if you aren't selling flags, you need a team to treat it like a product. They will need to be responsible for building new features, fixing bugs, and making improvements.
  • You can't stop worrying about a third party. If you have strong reasons to distrust a vendor, whether that is because of reliability, compliance, or other reasons, building your own flags might be the only thing that brings you peace of mind.
  • 当它成为公司的差异化优势时。例如,你们将功能开关、实验或相关产品作为服务进行销售。
  • 你们拥有内部团队来维护它。即使不对外销售功能开关,也需要一个团队将其视为产品进行管理。该团队需负责开发新功能、修复缺陷以及持续改进。
  • 你无法完全放心依赖第三方。如果出于可靠性、合规性或其他原因对供应商存在强烈不信任感,那么自建功能开关可能是唯一能让你安心的选择。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件