Windows Server 2019 MYSQL Connection Slow with intermittent problems

215 Views Asked by At

I have a very basic Python script running on a Windows VPS. This script is connecting to a Linux private server. This script is for testing purposes:

import mysql.connector

mydb = mysql.connector.connect(
  host="***",
  user="***",
  password="***",
  database="***",
  connection_timeout=60
)

mycursor = mydb.cursor()
mycursor.close()
mydb.close()

Running this script multiple times takes the following amounts of time:

1 second
1 second
More than 21 seconds
1 second
1 second
1 second
More than 21 seconds

The problem illustrated in this test script is causing my actual script to fail. Please help me diagnose the problem. Any suggestions for the source of the problem (firewall etc.) massively appreciated.

0

There are 0 best solutions below