I have deployed a LAMP web app into two separate AWS instances (labeled prod and test). Both are t2.micro, but prod is the older Linux image and test is the new Linux 2 image. Using the chrome browser Dev Tool:
prod - total time: between 500ms and 600 ms
test - total time: between 15 seconds and 50 seconds
The TTFB on prod is less than 100 ms on all downloaded files (script, css, js, etc.)
The TTFB on test is 3 or more seconds...
Here is a link to the chrome dev tools screenshot:
Chrome Dev Tool Timing Results
In addition, the download time for each file is a lot more on the test instance.
They have virtually the same apache conf, same memory usage (~50%), same code.
I have tried to figure out why and cannot find an answer. These are additional checks I have done:
- Tried strace and it takes several seconds to take the next request (3.1s in the example below):
6645 17:28:29 read(10, 0x55ff6e9b23f8, 8000) = -1 EAGAIN (Resource temporarily unavailable) <0.000007>
...
6645 17:28:32 <... poll resumed> ) = 1 ([{fd=10, revents=POLLIN}]) <3.108490>
- Here strace also shows apache waits for a very long time for the socket (fd=10) to be available for writing again after a sendfile...
6645 17:28:32 sendfile(10, 11, [76038] => [78918], 69895) = 2880 <0.000009>
6645 17:28:32 poll([{fd=10, events=POLLOUT}], 1, 60000 <unfinished ...>
....
6645 17:28:55 <... poll resumed> ) = 1 ([{fd=10, revents=POLLOUT}]) <23.333877>
- I have tried to download a big file (3.6 MB) via scp and that is a lot faster (~1.7 MB/s). That tells me there is something wrong with apache or the sockets apache is using, perhaps?
Any ideas what is happening on test? or if that is the expected speed from an t2.micro EC2 instance?
Thanks,
Mario.