java - Redis 在 AWS EC2 微型实例上的性能

标签 java amazon-ec2 redis jedis

我对部署在我的 AWS EC2 微型实例(测试环境)上的 Redis 实例做了一个有趣的观察

我正在测量必须命中 Redis 的各种操作的执行时间。总结一下,执行时间(平均)如下所示:

Jedis -> Redis Connection is 63 milliseconds
Read of top Element in a list using lrange(<listname>,0,1) is 44 milliseconds
Read of entire Elements of set is 5ms
Iteration over entire Set space is 60ms( Set space  approx 130 elements)
Iteration over subset of elements of set is 5ms ( Subset element size is 5)

现在让我担心的是前两个操作(列表中顶部元素的连接和提取)。

对于连接,代码如下所示:

 Jedis redis= new Jedis("localhost");

对于列表中顶部元素的提取:

 String currentDate = redis.lrange(holderDate,0,1).get(0);

现在来自 Redis lrange 命令文档:

Time complexity: O(S+N) where S is the start offset and N is the number of elements in the specified range.

现在根据我的代码,S 将为 0,N 将为 1。

那么我的问题是:是什么导致了这些微不足道的操作的执行时间。

EC2 微型实例的特征是否会对这些操作的性能产生不利影响。

关于 Redis 部署的一些关键信息:

redis_version:2.4.10
used_memory:2869280
used_memory_human:2.74M
used_memory_rss:4231168
used_memory_peak:2869480
used_memory_peak_human:2.74M
mem_fragmentation_ratio:1.47

提前致谢。

最佳答案

Are there characteristics of the EC2 Micro instance that would adversely affect the performance of these operations.

Amazon EC2 Instance Type t1.micro 有点独特,并且根据定义受到严重限制,请参阅 Micro Instances :

Micro instances (t1.micro) provide a small amount of consistent CPU resources and allow you to increase CPU capacity in short bursts when additional cycles are available. They are well suited for lower throughput applications and websites that require additional compute cycles periodically. [emphasis mine]

后者原则上是正确的,但节流的数量让许多用户感到惊讶 - 虽然没有指定确切的算法,但文档解释并特别是。很好地说明了一般策略和效果,在实践中似乎产生了大约 97% 的所谓 窃取时间 一旦节流开始,请参阅第 When the Instance Uses Its Allotted Resources 节具体来说:

We expect your application to consume only a certain amount of CPU resources in a period of time. If the application consumes more than your instance's allotted CPU resources, we temporarily limit the instance so it operates at a low CPU level. If your instance continues to use all of its allotted resources, its performance will degrade. We will increase the time we limit its CPU level, thus increasing the time before the instance is allowed to burst again. [emphasis mine]

这显然会渲染任何性能测试的情绪,正如 Didier Spezia rightly commented已经。请注意,虽然其他 EC2 实例类型也可能表现出窃取时间(这是虚拟化平台的一般产物,其中物理 CPU 可能由各种虚拟机共享),但各自的模式到目前为止更为规律以防万一,因此原则上可以进行性能测试,但通常存在以下限制条件:

  • 您至少需要在多个实例上运行测试,以考虑由于相邻虚拟机上的随机 CPU 负载而导致的不同窃取时间量
  • 一般情况下,您不应在与基准测试应用程序相同的虚拟机上运行基准测试应用程序,因为这显然会影响结果

关于java - Redis 在 AWS EC2 微型实例上的性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16465780/

相关文章:

java - Solr 3.4 和 Httpclient 4

java - 错误: Field dataSource in required a bean of type 'javax.activation.DataSource' that could not be found

java - 在 Java 中创建多列组合框

amazon-web-services - 安全组和网络接口(interface)的 AWS CloudFormation 错误,参数组合无效

json - AWS CloudFormation 用户数据\;和新行 (JSON)

python - 使用 Heroku 安装 Celery 和 Redis

java - Hibernate 与同一类的多个多对多关系

android - 如果我已经有一个 .sql 数据库,我可以使用 Apache 而不是 Redis Sever 将数据库连接到 Android 应用程序吗?

Redis 条件检索和删除记录

python - 如何查找特定标签下的保留实例总数?