使用Redis HASH而不是SET来减少缓存大小和操作成本

What if we told you that there was a way to dramatically reduce the cost to operate on cloud providers? That’s what we found when we dug into the different data structures offered in Redis. Before we committed to one, we did some research into the difference in memory usage between using HASH versus using SET. We found that HASHes can be used to potentially reduce the cost to operate by at least 50% over SET. Read on to see how we determined this and how you can put these savings into practice for yourself!

如果我们告诉你,有一种方法可以极大地降低云计算供应商的运营成本,你会怎么想?这就是我们在钻研Redis中提供的不同数据结构时发现的。在我们致力于其中一个之前,我们对使用HASH和使用SET之间的内存使用差异做了一些研究。我们发现,HASH可以用来降低操作成本 至少减少50%而不是SET。请继续阅读,看看我们是如何确定这一点的,以及你如何将这些节省的费用用于自己的实践中!

Introduction

简介

Redis is an in-memory data structure store often used as a distributed cache enabling rapid operations. It offers simple key-value stores but also more complicated data structures such as lists, hashes (map/dict), sorted sets, etc. This blog post assumes some understanding of Redis. Read more about Redis here.

Redis是一个内存数据结构存储,通常作为分布式缓存使用,能够实现快速操作。它提供简单的键值存储,也提供更复杂的数据结构,如列表、哈希(map/dict)、排序集等。这篇博文假定对Redis有一些了解。在这里阅读更多关于Redis的信息。

Salesforce Activity Platform apps and customers have a configurable data retention period in which we will TTL (time-to-live)/delete any data older than that set time. Our data can be either be at the Organization (parent) level or at the User (child) level. A parent level deletion job can only be recognized as complete if and only if all child level jobs are also complete. Our deletion pipeline used a Mongo set data structure to keep track of completed child jobs from fanout for parallel execution. However, this fanout introduced a massive load on Mongo as each child job will be required to update its respective parent set. Thus, the number of database calls scaled linearly with the average number of users per org. We decided to move this set to Redis in order to reduce load on Mongo.

Salesforce活动平台的应用程序和客户有一个可配置的数据保留期,在这段时间内,我们将TTL(生存时间)/删除任何超过该设置时间的数据。我们的数据可以是组织(父)级,也可以是用户(子)级。父级的删除工作...

开通本站会员,查看完整译文。

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.125.0. UTC+08:00, 2024-05-10 19:28
浙ICP备14020137号-1 $访客地图$