Why sometimes AWS EC2 works really slow

amazon ec2amazon-web-servicesperformance

I do only one thing one this server – encoding videos by ffmpeg.
And sometimes it does work ok, sometimes it's really slow.

I run the same command just for a test:

$ sudo time ffmpeg -i test.mp4 -c:a copy -vf 'drawbox= : x=0 : y=0 : color=invert : t=2' output1.mp4
ffmpeg version n2.2.15 Copyright (c) 2000-2015 the FFmpeg developers
  built on Apr 30 2015 13:20:09 with gcc 4.8.2 (GCC) 20140120 (Red Hat 4.8.2-16)
......
16.24user 0.04system 0:16.30elapsed 99%CPU (0avgtext+0avgdata 60972maxresident)k
0inputs+6088outputs (0major+15811minor)pagefaults 0swaps

After 5 hours I run it again, because I saw it starts working slow again.

$ sudo time ffmpeg -i test.mp4 -c:a copy -vf 'drawbox= : x=0 : y=0 : color=invert : t=2' output1.mp4
.......
163.41user 0.84system 2:46.90elapsed 98%CPU (0avgtext+0avgdata 60988maxresident)k
0inputs+6136outputs (0major+15814minor)pagefaults 0swaps

As you can see it took 10 times more time than the first time. (1)16.24user (2)163.41user

Any ideas how can it be fixed?

Best Answer

depending on your instance type (burstable cpu instances), you may be dealing with CPU credit.

==> https://stackoverflow.com/questions/28984106/whats-is-cpu-credit-balance-in-ec2

if you find vast fluctuations on a non-burstable instance, you may want to stop and start (not reboot) instance. this will make the instance come up on a different hypervisor (host box). it may be the current shared host has issues that will be resolved when launching vm on new host.