You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
We have a cloud service written on Azure Service Fabric. It has self owin controller web apis for which throttling has been enforced using WebApiThrottle.
Cloude service is deployed on azure service fabric which gets deployed on multiple nodes. This allows service fabric to fail over in case of and service down/crashes.
We are seeing issue with updating throttle policy at run time. WebApiThrottling is applied for the riles defined in App.config but when updating the policy at run time, the same is not reflected.
When trying to fetch policy from "PolicyMemoryCacheRepository" at run time, we see older policy
some times and some times new policy updated.
We also tried removing the policy and adding it. But are still seeing the same issue.
How are are such things handled in case where cache is replicated ? Do you have any scenario for a service fabric application ? Please comment.
More Information:
As per the documentation, in the startup Register.cs, we registered throttling handler as :
//Register throttling handler
config.MessageHandlers.Add(new ThrottlingHandler(
policy: ThrottlePolicy.FromStore(new PolicyConfigurationProvider()),
policyRepository: new PolicyMemoryCacheRepository(),
repository: new MemoryCacheRepository(),
logger: new WebApiThrottle.TracingThrottleLogger(traceWriter)
));
Helper functions to fetch and update throttle policy:
private string GetPolicyConfiguration()
{
try
{
string id = "throttle_policy";
PolicyMemoryCacheRepository policyRepository = new PolicyMemoryCacheRepository();
ThrottlePolicy policyObject = policyRepository.FirstOrDefault(id);
if (policyObject == null)
{
return "Provisioning Service Policy Configuration doesnot exist.";
}
else
{
return JsonConvert.SerializeObject(policyObject);
}
}
catch (Exception e)
{
throw;
}
}
private string UpdatePolicyConfig(string policyConfig)
{
try
{
string id = "throttle_policy";
if (string.IsNullOrEmpty(policyConfig))
throw new Exception("Policy configuration passed was either null or empty.");
//Deserialize policyConfig
ThrottlePolicy policyObject = JsonConvert.DeserializeObject<ThrottlePolicy>(policyConfig);
//init policy repo
var policyRepository = new PolicyMemoryCacheRepository();
//apply policy updates
policyRepository.Remove(id);
if (policyRepository.FirstOrDefault(id) == null)
{
//Policy id : successfully removed from repository of type
}
else
{
//Could not remove policy id : from repository of type
}
//apply policy updates
ThrottleManager.UpdatePolicy(policyObject, policyRepository);
return "Successfully updated policy configuration for type";
}
catch (Exception ex)
{
throw;
}
}
The text was updated successfully, but these errors were encountered:
@udbach instead of using the PolicyMemoryCacheRepository. You should implement a Redis Cache implementation or Table Storage. That way you can have a global policy over all the fabric nodes.
Hi,
We have a cloud service written on Azure Service Fabric. It has self owin controller web apis for which throttling has been enforced using WebApiThrottle.
Cloude service is deployed on azure service fabric which gets deployed on multiple nodes. This allows service fabric to fail over in case of and service down/crashes.
We are seeing issue with updating throttle policy at run time. WebApiThrottling is applied for the riles defined in App.config but when updating the policy at run time, the same is not reflected.
When trying to fetch policy from "PolicyMemoryCacheRepository" at run time, we see older policy
some times and some times new policy updated.
We also tried removing the policy and adding it. But are still seeing the same issue.
How are are such things handled in case where cache is replicated ? Do you have any scenario for a service fabric application ? Please comment.
More Information:
As per the documentation, in the startup Register.cs, we registered throttling handler as :
//Register throttling handler
config.MessageHandlers.Add(new ThrottlingHandler(
policy: ThrottlePolicy.FromStore(new PolicyConfigurationProvider()),
policyRepository: new PolicyMemoryCacheRepository(),
repository: new MemoryCacheRepository(),
logger: new WebApiThrottle.TracingThrottleLogger(traceWriter)
));
Helper functions to fetch and update throttle policy:
private string GetPolicyConfiguration()
{
try
{
string id = "throttle_policy";
The text was updated successfully, but these errors were encountered: