Created
July 6, 2019 06:56
-
-
Save likejazz/d7f5ad29d2cc82290de9f2779ac1b546 to your computer and use it in GitHub Desktop.
Analyzing Redis PING performance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import redis | |
for i in range(10): | |
start_time = time.time() | |
try: | |
conn = redis.StrictRedis( | |
host='xxx', | |
port=6379, | |
db=0) | |
conn.ping() | |
except Exception as ex: | |
print('Error:', ex) | |
exit('Failed to connect, terminating.') | |
elapsed_time = float("{0:.2f}".format((time.time() - start_time) * 1000)) | |
if elapsed_time > 3: | |
print(int(time.time()), elapsed_time) | |
# $ while true; do python ping.py; sleep 1; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment