java – AWS EC2 Micro Instance上的Redis性能

我在部署在AWS EC2 Micro实例上的Redis实例上做了一个有趣的观察(测试环境)我正在测量必须击中Redis的各种操作的执行时间.总而言之,执行时间(平均值)如下所示:Jedis - Redis Connection is 63 millisecondsRead ...

我在部署在AWS EC2 Micro实例上的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 Command文档:

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 Micro实例的特性会对这些操作的性能产生负面影响.

关于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 – AWS EC2 Micro Instance上的Redis性能

基础教程推荐