Lab complete!
Now that you have completed this lab, make sure to update your Well-Architected review if you have implemented these changes in your workload.
Click here to access the Well-Architected Tool
Now that we have two EC2 machines, one Xen based EC2 and one Nitro/KVM based EC2, we can run a simple test to see the speed in which is can return time of day. This test program was installed on each machine under /tmp/time_test.py. The program will simply request the time of day from a local c-library one million times.
#!/usr/bin/python3
import time
_gettimeofday = None
def gettimeofday():
import ctypes
global _gettimeofday
if not _gettimeofday:
_gettimeofday = ctypes.cdll.LoadLibrary("libc.so.6").gettimeofday
class timeval(ctypes.Structure):
_fields_ = \
[
("tv_sec", ctypes.c_long),
("tv_usec", ctypes.c_long)
]
tv = timeval()
_gettimeofday(ctypes.byref(tv), None)
return float(tv.tv_sec) + (float(tv.tv_usec) / 1000000)
start_time = time.time()
for x in range(0,1000000):
gettimeofday()
print("--- %s seconds ---" % (time.time() - start_time))
print("Done")
If you wish to bypass using the pre-defined AWS System Manager documents below, you can also run this script interactively on each EC2 node using AWS Systems Manager Session Manager.
It will take longer to complete for one node to run than the other. The total time for both to complete should be about 2 minutes if you use the default EC2 instance types.
Now that you have completed this lab, make sure to update your Well-Architected review if you have implemented these changes in your workload.
Click here to access the Well-Architected Tool