如何计算Firebase远程配置速率限制? [英] How is the Firebase Remote Config rate limit counted?

查看:194
本文介绍了如何计算Firebase远程配置速率限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

问题是我知道在很短的时间内多次从服务器获取配置可能会导致一个节流异常。在一个生产应用程序,每小时有5个请求的限制,但我不知道这个限制是每个用户或全球计数。



这是我有的代码:


$ b $

  //首先搜索缓存结果,如果存在的话
String key = FirebaseRemoteConfig.getInstance()。getString(key ); (key!= null&&!key.isEmpty()){
setKeyAndGoHome(key);
} else {
//不存在任何键,让我们从配置文件中获取它
FirebaseRemoteConfig.getInstance()。fetch()。addOnCompleteListener(new OnCompleteListener< Void>(){
@Override
public void onComplete(@NonNull Task< Void> task){
if(task.isSuccessful()){
FirebaseRemoteConfig.getInstance()。activateFetched();
// key被缓存12小时
String key = FirebaseRemoteConfig.getInstance()。getString(key);
setKeyAndGoHome(key);
} else {
// this可能发生由于节流异常
}

}
});





$ p这是非常重要的,因为没有这个键我的应用程序不能工作。我需要知道是否可以达到限制异常情况。



你知道限额是如何计算的吗?

感谢。

解决方案

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



当您考虑FirebaseRemoteConfig的预期应用程序时,如果全部提取一个应用程序的实例被限制在一个小数字,如5。



在您的文章中,您使用了术语用户。请注意,FirebaseRemoteConfig不需要登录用户,也不会提供任何基于特定用户标识提供配置参数的功能,例如应用版本,设备语言或国家/地区等。 b
$ b

由于您正在考虑使用远程配置存储密钥,因此您应该在 documentation
$ b


不要将机密数据存储在远程配置参数键或
参数值。可以解码存储在您的项目的远程配置设置中的任何参数键或
值。


I am using Firebase Remote Config to store a secret key for a mobile app ( I do not want to include in client app due to security problems).

The problem is I know that fetching config from server many times in a short period of time can throw a throttling exception. In a production app there is a limit of 5 requests per hour but I do not know if this limit is count per user or globally.

This is the code I have:

//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
                }

            }
        });
    }

This is very important because without this key my app can not work. I need to know if throttling exception condition can be reached.

Do you know how is the limit counted?

Thanks.

解决方案

The counts are maintained for each app instance. In other words, for each device on which your app runs. I confirmed this by repeatedly running code similar to yours on one device until the fetch status was LAST_FETCH_STATUS_THROTTLED. I then ran the same app on a different device, which fetched successfully.

When you think about the intended application for FirebaseRemoteConfig, it couldn't work if the fetches by all instances of an app were limited to a small number, like 5.

In your post you used the term "user". Note that FirebaseRemoteConfig does not require a signed-in user and does not provide any capability to deliver configuration parameters based on a specific user ID, as it does for other things such as app version, device language, or country.

Because you are considering using Remote Config "to store a secret key", you should be aware of this warning in the 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.

这篇关于如何计算Firebase远程配置速率限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆