简体   繁体   English

AWS EC2 Micro Instance上的Redis性能

[英]Redis performance on AWS EC2 Micro Instance

I have made a funny observation on my Redis instance deployed on my AWS EC2 Micro instance ( Test environment) 我在部署在AWS EC2 Micro实例上的Redis实例上做了一个有趣的观察(测试环境)

I was measuring the execution times of various operations that have to hit Redis. 我正在测量必须击中Redis的各种操作的执行时间。 To summarise, the execution times ( average) are shown below: 总而言之,执行时间(平均值)如下所示:

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)

Now what is worrying me are the first 2 operations ( the connection and the extraction of the top element in a list). 现在令我担心的是前两个操作(连接和列表中顶部元素的提取)。

For the connection, the code is shown below: 对于连接,代码如下所示:

 Jedis redis= new Jedis("localhost");

And for the extraction of the top element in the list: 并且为了提取列表中的顶部元素:

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

Now from the Redis lrange Command documentation: 现在来自Redis lrange Command文档:

Time complexity: O(S+N) where S is the start offset and N is the number of elements in the specified range. 时间复杂度:O(S + N)其中S是起始偏移量,N是指定范围内的元素数量。

Now from my code S would be 0 and N would be 1. 现在从我的代码S将是0和N将是1。

My question then is: What is causing these execution times for these somewhat trivial operations. 我的问题是:这些有些微不足道的操作导致这些执行时间的原因。

Are there characteristics of the EC2 Micro instance that would adversely affect the performance of these operations. 是否存在EC2 Micro实例的特性会对这些操作的性能产生负面影响。

Some key information on the Redis deployment: 关于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

Thanks in advance. 提前致谢。

Are there characteristics of the EC2 Micro instance that would adversely affect the performance of these operations. 是否存在EC2 Micro实例的特性会对这些操作的性能产生负面影响。

The Amazon EC2 Instance Type t1.micro is somewhat unique and heavily throttled by definition, see Micro Instances : Amazon EC2实例类型 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. 微实例(t1.micro)提供少量一致的CPU资源,并允许您在有额外周期时以短突发方式增加CPU容量。 They are well suited for lower throughput applications and websites that require additional compute cycles periodically . 它们非常适用于需要额外计算周期的低吞吐量应用程序和网站 [emphasis mine] [强调我的]

The latter is correct in principle, but the amount of throttling catches many users by surprise - while the exact algorithm isn't specified, the documentation explains and esp. 后者原则上是正确的,但节流量令许多用户感到意外 - 虽然没有指定确切的算法,但文档解释并且特别是。 illustrates the general strategy and effect pretty well, which in practice seems to yield around ~97% so called steal time once the throttling kicks in, see section When the Instance Uses Its Allotted Resources specifically: 很好地说明了一般的策略和效果,实际上,一旦限制开始,实际上似乎产生大约97%的所谓的窃取时间 ,请参阅实例使用其分配的资源时的具体部分:

We expect your application to consume only a certain amount of CPU resources in a period of time. 我们希望您的应用程序在一段时间内仅消耗一定量的CPU资源。 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. 如果应用程序消耗的内存超过实例分配的CPU资源, 我们会暂时限制实例,使其在低CPU级别运行。 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. 我们将增加限制其CPU级别的时间,从而增加允许实例再次爆发之前的时间。 [emphasis mine] [强调我的]

This obviously renders any performance tests mood indeed, as Didier Spezia rightly commented already. 这显然使得任何表演测试的情绪确实如同Didier Spezia已正确评论 Please note that while other EC2 instance types may also exhibit steal time (which is a general artifact of virtualization platforms, where physical CPUs might be shared by various virtual machines), the respective patterns are more regular by far in case, so performance tests are possible in principle, though the following constraints apply in general: 请注意,虽然其他EC2实例类型也可能显示窃取时间 (这是虚拟化平台的一般工件,其中物理CPU可能由各种虚拟机共享),但相应的模式在更多情况下更加规则,因此性能测试是原则上可能,但以下限制一般适用:

  • you would need to run the tests on a number of instances at least to account for the varying amount of steal time due to random CPU loads on neighboring virtual machines 您需要在多个实例上运行测试,至少要考虑由于相邻虚拟机上的随机CPU负载导致的不同的窃取时间
  • you shouldn't run the benchmarking application on the same virtual machine as the benchmarked one in general, as this obviously impacts the result 您不应该在与基准测试的虚拟机相同的虚拟机上运行基准测试应用程序,因为这显然会影响结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM