AWS与localhost

时间:2019-01-17 02:26:27

标签: python-3.x amazon-web-services

我的异步脚本有一个主循环,它在本地计算机上每秒运行15万次迭代,在一个AWS实例(Windows AMI,Python 3.7)上每秒运行约18万次迭代。

当我在此循环中引入time.sleep(1 / X)时,我设法在本地主机上很好地限制了它。示例:

while t - tzero < settings.main_loop_seconds:
    for singleobject in iterable:
        singleobject.process()     
        t= time.time()
        time.sleep(1/10000)  
        """with this I expect a maximum of 10000 iterations per second, and with the time lost to 'process' I get an actual 6500 iterations per second. As expected."""
        loopcounter += 1
        """ I reset this loopcounter to 0 from another thread (using threading.Timer)  It is used for logging the number of loops per second.

现在,在AWS上,相同的代码出现了问题,只是在time.sleep(1 / X)中更改了“ X”。

X = 1#我每秒获得1个循环

X = 10#我每秒获得9个循环

X = 100#我每秒获得64个循环

X = 1000#我每秒获得64个循环

X = 10000#我每秒获得64个循环

X = 100000#我每秒获得64个循环

有人可以帮助解释这种行为吗?谢谢。

0 个答案:

没有答案