Azure函数中的内存中缓存 [英] In-memory caching in Azure function

查看:46
本文介绍了Azure函数中的内存中缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要缓存对象以提高我的Azure函数的性能.我尝试了.NET ObjectCache(System.Runtime.Caching),它在我的测试中表现良好(测试了长达10分钟的缓存保留期).

There is a need to cache objects to improve the perf of my Azure function. I tried .NET ObjectCache (System.Runtime.Caching) and it worked well in my testing (tested with upto 10min cache retention period).

为了推动该解决方案的发展,我有几个简短的问题:

In order to take this solution forward, I have few quick questions:

  1. Azure功能的回收策略是什么.是否有默认值?可以配置吗?

  1. What is the recycling policy of Azure function. Is there any default? Can it be configured?

费用的含义是什么?

我的方法正确还是有更好的解决方案?

Is my approach right or are there any better solutions?

您可能知道的任何问题,请帮忙.

Any questions that you may know, please help.

谢谢.

推荐答案

熟透了,

建议使用进程外解决方案,例如Redis(或根据工作负载使用表存储).

An out-of-process solution such as Redis (or even using Table storage, depending on the workload) would be recommended.

根据经验,函数应该是无状态的,特别是如果您在动态运行时中运行,在这种情况下缩放操作(向上和向下)可能随时发生,并且不能保证主机保持正常运行.

As a rule of thumb, functions should be stateless, particularly if you're running in the dynamic runtime, where scaling operations (up and down) could happen at any time and your host is not guaranteed to stay up.

如果您选择使用经典主机,则确实具有更大的灵活性,因为可以启用始终在线"功能,但是我仍然建议您使用进程外方法.由于您不再利用动态托管提供的基于消费的计费模型,因此在经典模式下运行也确实具有成本隐患.

If you opt to use the classic hosting, you do have a little more flexibility, as you can enable the "always on" feature, but I'd still recommend the out-of-process approach. Running in the classic mode does have a cost implication as well, since you're no longer taking advantage of the consumption based billing model offered by the dynamic hosting.

我希望这会有所帮助!

这篇关于Azure函数中的内存中缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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