Firebase Remote Config 限速是怎么计算的?

How is the Firebase Remote Config rate limit counted?

我正在使用 Firebase Remote Config 存储移动应用程序的密钥(由于安全问题,我不想包含在客户端应用程序中)。

问题是我知道在短时间内多次从服务器获取配置会引发限制异常。在生产应用程序中,每小时有 5 个请求的限制,但我不知道这个限制是按用户还是全局计算的。

这是我的代码:

//first search cached result, if present
    String key = FirebaseRemoteConfig.getInstance().getString("key");
    if(key != null && !key.isEmpty()){
        setKeyAndGoHome(key);
    }else {
        //no key present, let's fetch it from config
        FirebaseRemoteConfig.getInstance().fetch().addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if(task.isSuccessful()){
                    FirebaseRemoteConfig.getInstance().activateFetched();
                    //key is cached 12 hours
                    String key = FirebaseRemoteConfig.getInstance().getString("key");
                    setKeyAndGoHome(key); 
                } else {
                    //this can happen due to a throttling exception
                }

            }
        });
    }

这非常重要,因为如果没有这个密钥,我的应用程序将无法运行。我需要知道是否可以达到节流异常条件。

你知道限额是怎么算的吗?

谢谢。

为每个应用程序实例维护计数。换句话说,对于运行您的应用程序的每台设备。我通过在一台设备上重复 运行 类似于您的代码来确认这一点,直到获取状态为 LAST_FETCH_STATUS_THROTTLED。然后我 运行 在另一台设备上成功获取了相同的应用程序。

当您考虑 FirebaseRemoteConfig 的预期应用程序时,如果一个应用程序的所有实例的提取都被限制在较小的数量(例如 5),它就无法工作。

在您的 post 中,您使用了术语 "user"。请注意,FirebaseRemoteConfig 不需要登录用户,也不提供任何根据特定用户 ID 提供配置参数的功能,就像它对应用程序版本、设备语言或国家/地区等其他内容所做的那样。

因为您正在考虑使用远程配置 "to store a secret key",所以您应该注意 documentation 中的这个警告:

Don't store confidential data in Remote Config parameter keys or parameter values. It is possible to decode any parameter keys or values stored in the Remote Config settings for your project.

每个应用实例每个设备每小时计算 5 次。如果您清除应用程序的数据,此限制将被重置。您可以在 03:50 秒开始观看 Firebase Remote Config 产品经理制作的视频,了解有关此问题的更多信息 - https://www.youtube.com/watch?v=Vn8X-KQsb6w&t=230s